Example #1
0
    def signUpAuthInfoCheck(self):
        username = request.POST['username'].strip()
        password = request.POST['password'].strip()
        secret = request.POST['secret'].strip()

        errors = []
        if not valid.text(username):
            errors.append({"selector":"#signupUsername", "message":"Enter letters and/or numbers."})
        else:
            if users.user_exists(username):
                errors.append({"selector":"#signupUsername", "message":"Username is taken."})
        if not valid.text(password):
            errors.append({"selector":"#signupPassword", "message":"Please enter a password."})
        if not valid.text(secret):
            errors.append({"selector":"#signupSecret", "message":"Please enter a valid secret."})
        
        return json.dumps({"errors":errors})
Example #2
0
 def saveResidence(self):
     residenceid = request.POST['residenceId']
     tenantid = request.POST['tenantId']
     startdate = request.POST['startdate'].strip()
     enddate = request.POST['enddate'].strip()
     street = request.POST['street'].strip()
     city = request.POST['city'].strip()
     state = request.POST['state'].strip()
     landlordname = request.POST['landlordname'].strip()
     landlordphone = request.POST['landlordphone'].strip()
     landlordemail = request.POST['landlordemail'].strip()
     reason = request.POST['reason'].strip()
     
     errors = []
     if not valid.date(startdate):
         errors.append({'selector':'#residenceStart','message':'Please enter a valid date.'})
     if not valid.date(enddate):
         errors.append({'selector':'#residenceEnd','message':'Please enter a valid date.'})
     if not valid.date(startdate, enddate):
         errors.append({'selector':'#residenceEnd','message':'The end date is greater than the start date.'})
     if not valid.street(street):
         errors.append({'selector':'#residenceStreet','message':'Please enter a valid street.'})
     if not valid.city(city):
         errors.append({'selector':'#residenceCity','message':'Please enter a valid city.'})
     if not valid.state(state):
         errors.append({'selector':'#residenceState','message':'Please enter a valid state.'})
     """
     if not valid.name(landlordname) and len(landlordname):
         errors.append({'selector':'#residenceLandlord','message':'Please enter a valid name for the landlord.'})
     """
     if not valid.phone(landlordphone) and len(landlordphone):
         errors.append({'selector':'#residenceLandlordPhone','message':'Please enter a phone number for the landlord.'})
     if not valid.email(landlordemail) and len(landlordemail):
         errors.append({'selector':'#residenceLandlordEmail','message':'Please enter a valid email for the landlord.'})
     if not valid.text(reason) and len(reason):
         errors.append({'selector':'#residenceReasonLeaving','message':'There is an error with the "reason for leaving" field.  Please double check you didn\'t enter any strange characters.'})
     if errors:
         return json.dumps({'errors':errors})
     
     startdate = startdate.split("/")
     startdate = datetime.date(int(startdate[2]), int(startdate[0]), int(startdate[1]))
     
     enddate = enddate.split("/")
     enddate = datetime.date(int(enddate[2]), int(enddate[0]), int(enddate[1]))
     
     if residenceid == '0':
         residenceid = str(uuid.uuid1())
         model.Previous_residence(residenceid, tenantid, startdate, enddate, street,\
                                  city, state, landlordname, landlordemail, landlordphone, reason) 
     else:
         model.Previous_residence.save(residenceid, tenantid, startdate, enddate, street,\
                                       city, state, landlordname, landlordemail, landlordphone, reason) 
     
     redirect_to(protocol=settings.PROTOCOL, controller='tenant', action='json', id=tenantid)
Example #3
0
 def signUpBasicInfoCheck(self):
     company = request.POST['company'].strip()
     fname = request.POST['fname'].strip()
     lname = request.POST['lname'].strip()
     email = request.POST['email'].strip()
     phone = request.POST['phone'].strip()
     
     errors = []
     if not valid.text(company):
         errors.append({"selector":"#signupCompany", "message":"Invalid characters detected."})
     if not valid.name(fname):
         errors.append({"selector":"#signupFName", "message":"Please enter a valid first name."})
     if not valid.name(lname):
         errors.append({"selector":"#signupLName", "message":"Please enter a valid last name."})
     if not valid.email(email):
         errors.append({"selector":"#signupEmail", "message":"Please enter a valid email."})
     if not valid.phone(phone):
         errors.append({"selector":"#signupPhone", "message":"Please enter a valid phone #."})
         
     return json.dumps({"errors":errors})
Example #4
0
 def saveContact(self):
     contactid = request.POST['contactId']
     tenantid = request.POST['tenantId']
     name = request.POST['name'].strip()
     phone = request.POST['phone'].strip()
     relationship = request.POST['relationship'].strip()
     
     errors = []
     """
     if not valid.name(name):
         errors.append({'selector':'#emergencyName','message':'The name is invalid.'})
     """
     if not valid.phone(phone):
         errors.append({'selector':'#emergencyPhone','message':'The phone number is not valid.'})
     if not valid.text(relationship):
         errors.append({'selector':'#emergencyRelationship','message':'Please specify a valid relationship, eg "Friend".'})
     if errors:
         return json.dumps({'errors':errors})
     
     
     if contactid == '0':
         contactid = str(uuid.uuid1())
         model.Emergency_contact.create(
                                        id=contactid,
                                        tenantid=tenantid,
                                        name=name,
                                        phone=phone,
                                        relationship=relationship)
     else:
         model.Emergency_contact.save(
                                      id=contactid,
                                      tenantid=tenantid,
                                      name=name,
                                      phone=phone,
                                      relationship=relationship)
     
     redirect_to(protocol=settings.PROTOCOL, controller='tenant', action='json', id=tenantid)