Esempio n. 1
0
 def form_valid(self, form):
     data = form.cleaned_data
     me = utils.get_user_obj(self.request)
     house = models.House(owner=me,
                          house_name=data['location_area'],
                          house_size=int(data['house_size']))
     house.save()
     return portal(self.request)
Esempio n. 2
0
 def form_valid(self, form):
     user = utils.get_user_obj(self.request)
     data = form.cleaned_data
     if models.Vip.objects.filter(text=data['text']):
         user.is_vip = True
         user.save()
         content = 'You have been VIP client!'
         sendmessage(self.request, content)
         return vip(self.request)
Esempio n. 3
0
def account_payrent_list(request):
    user = utils.get_user_obj(request)

    renters = []
    passive_renters = user.landlordrenterinfo_set.all()
    active_renters = user.renterrentprofile_set.all()

    renters.extend(passive_renters)
    renters.extend(active_renters)
    renters.sort(key=lambda x: x.created_at)
    renters.reverse()
    return utils.render('account/payrentlist.html',
                        {'renters': renters})
    user = utils.get_user_obj(request)

    if user.is_vip == False:
        return vipconfirm(request)
    else:
        return utils.render('account/vip.html', {'message': 'Welcome,VIP!'})
Esempio n. 4
0
 def form_valid(self, form):
     user = utils.get_user_obj(self.request)
     data = form.cleaned_data
     if user and user.password == data['password'] and \
        data['new_password'] == data['confirm_new_password']:
         user.password = data['new_password']
         user.save()
         return info(self.request)
     else:
     #LOG.debug("%s password modify failed." % user)
         return utils.render('password_modify.html',
                             {'errors': 'password is wrong',
                              'form': form})
Esempio n. 5
0
 def form_valid(self, form):
     user = utils.get_user_obj(self.request)
     data = form.cleaned_data
     if user:
         user.real_name = data['real_name']
         user.real_id = data['real_id']
         user.save()
         return info(self.request)
     else:
     #LOG.debug("%s name certificate failed." % user)
         return utils.render('name_certificate.html',
                             {'errors': 'failed',
                              'form': form})
Esempio n. 6
0
 def form_valid(self, form):
     user = utils.get_user_obj(self.request)
     data = form.cleaned_data
     if user and data['verification_code'] == str(user.verifycode):
         user.phone = data['newphone']
         user.is_active = False
         user.save()
         return info(self.request)
     else:
         user.is_active = False
         user.save()
         return utils.render('phone_modify.html',
                            {'errors': 'verifycode is wrong!',
                             'form': form})
Esempio n. 7
0
 def form_valid(self, form):
     user = utils.get_user_obj(self.request)
     data = form.cleaned_data
     print user.verifycode
     if user and data['phone'] and \
        data['verification_code'] == str(user.verifycode):
         user.phone = data['phone']
         user.save()
         return safe(self.request)
     else:
     #LOG.debug("%s phone modify failed." % user)
         return utils.render('phone_modify.html',
                             {'errors': 'phone number is wrong',
                              'form': form})
Esempio n. 8
0
 def form_valid(self, form):
     user = utils.get_user_obj(self.request)
     data = form.cleaned_data
     if user and data['phone']:
         user.verifycode = random.randrange(0, 999999)
         user.save()
         content = 'verifycode:' + str(user.verifycode)
         utils.send_msg(data['phone'], content)
         return phonemodify(self.request)
     else:
     #LOG.debug("%s phone modify failed." % user)
         return utils.render('send_verifycode.html',
                             {'errors': 'failed',
                              'form': form})
Esempio n. 9
0
 def form_valid(self, form):
     user = utils.get_user_obj(self.request)
     data = form.cleaned_data
     if user and data['problem_one'] and \
        data['problem_two'] and data['problem_three']:
         user.problem_one = data['problem_one']
         user.problem_two = data['problem_two']
         user.problem_three = data['problem_three']
         user.save()
         return safe(self.request)
     else:
     #LOG.debug("%s failed." % user)
         return utils.render('security_problem.html',
                             {'errors': 'failed',
                              'form': form})
Esempio n. 10
0
 def form_valid(self, form):
     user = utils.get_user_obj(self.request)
     data = form.cleaned_data
     if user and data['email']:
         para = user.username
         content = 'click here to active ' + \
                 '<a href="http://localhost:8000/z/account/activate_mailbox/?username='******'">' + \
                 'http://www.active.com</a>'
         utils.send_mail(data['email'], content)    
         for i in range(120):
             time.sleep(1)
             user = utils.get_user_obj(self.request)
             if user.is_active == True: 
                 user.email = data['email']
                 user.is_active = False
                 user.save()
                 break
         return info(self.request)
     else:
     #LOG.debug("%s mailbox modify failed." % user)
         return utils.render('mailbox_modify.html',
                             {'errors': 'failed',
                              'form': form})
Esempio n. 11
0
 def form_valid(self, form):
     user = utils.get_user_obj(self.request)
     data = form.cleaned_data
     if user and data['email']:
         content = 'click here to active ' + \
                 '<a href="http://www.zufangbao.com/chargerent/">' \
                 'http://www.active.com</a>'
         utils.send_mail(data['email'], content)
         user.email = data['email']
         user.save()
         return safe(self.request)
     else:
     #LOG.debug("%s mailbox modify failed." % user)
         return utils.render('mailbox_modify.html',
                             {'errors': 'failed',
                              'form': form})
Esempio n. 12
0
 def form_valid(self, form):
     user = utils.get_user_obj(self.request)
     data = form.cleaned_data
     if user and data['newphone']:
         if user.is_active == False:
             user.verifycode = random.randrange(0, 999999)
             user.is_active = True               
             user.save()
             print user.verifycode
             content = 'verifycode:' + str(user.verifycode)
             utils.send_msg(data['newphone'], content)
             return phonemodify(self.request)
         else:
             return phonemodify(self.request)
     else:           
         return utils.render('phone_modify.html',
                             {'errors': 'failed',
                              'form': form})
Esempio n. 13
0
 def form_valid(self, form):
     user = utils.get_user_obj(self.request)
     form.instance.landlord = user
     form.save()
     return redirect('charge_renter_add', form.instance.pk)
Esempio n. 14
0
def sendmessage(request, content):
    user = utils.get_user_obj(request)
    message = models.Message(owner_id=user.id, content=content)
    message.save()
Esempio n. 15
0
def account_chargeent_list(request):
    user = utils.get_user_obj(request)
    charge_rents = user.landlordrentprofile_set.all()
    return utils.render('account/chargerentlist.html',
                        {'charge_rents': charge_rents})
Esempio n. 16
0
def activatemailbox(request):
    user = utils.get_user_obj(request)
    user.is_active = True
    user.save()
    print 'activate have been worked'
    return utils.render('activate_mailbox.html', {})
Esempio n. 17
0
def messages(request):
    user = utils.get_user_obj(request)
    message = user.message_set.all()
    return utils.render('account/account_messages.html',
                        {'message': message})
Esempio n. 18
0
def portal(req):
    user = utils.get_user_obj(req)
    houses = user.house_set.all()
    orders = user.order_set.all()
    return utils.render('portal.html', {'houses': houses,
                                        'orders': orders})
Esempio n. 19
0
 def form_valid(self, form):
     user = utils.get_user_obj(self.request)
     form.instance.renter = user
     form.save()
     return redirect('pay_rent_option_create', form.instance.pk)
Esempio n. 20
0
def cardmanage(request):
    user = utils.get_user_obj(request)
    #user_id = user.id
    #cards = BankCard.objects.filter(owner_id = user_id)
    cards = user.bankcard_set.all()
    return utils.render('account/bankcards.html', {'cards': cards})