예제 #1
0
파일: company.py 프로젝트: weixiyen/Rentfox
 def validate(self):
     name = request.POST['name'].strip()
     street = request.POST['street'].strip()
     city = request.POST['city'].strip()
     state = request.POST['state'].strip()
     zip = request.POST['zip'].strip()
     email = request.POST['email'].strip()
     phone = request.POST['phone'].strip()
     
     errorslist = []
     
     if not valid.label(name):
         errorslist.append({'selector':'#update-name', "message":"Please enter a valid company name"})
     elif street and not valid.street(street):
         errorslist.append({'selector':'#update-street', "message":"Please enter a valid street address"})
     elif phone and not valid.phone(phone):
         errorslist.append({'selector':'#update-phone', "message":"Please enter a valid phone"})
     elif email and not valid.email(email):
         errorslist.append({'selector':'#update-email', "message":"Please enter a valid email"})
     elif city or state or zip:
     	if not valid.city(city):
     		errorslist.append({'selector':'#update-city', "message":"Please enter a valid city"})
     	if not valid.state(state):
     		errorslist.append({'selector':'#update-state', "message":"Please enter a valid state"})
     	if not valid.zip(zip):
     		errorslist.append({'selector':'#update-zip', "message":"Please enter a valid zip"})
     
     return errorslist
예제 #2
0
파일: tenant.py 프로젝트: weixiyen/Rentfox
 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)
예제 #3
0
 def validate(self, action=None):
     name = request.POST['name'].strip()
     street = request.POST['street'].strip()
     city = request.POST['city'].strip()
     state = request.POST['state'].strip()
     zip = request.POST['zip'].strip()
     
     errorslist = []
     
     if action == 'create':
         record = model.Unit.get_num_units(request.environ.get('COMPANY_ID'))
         unitCount = record[0]
         maxUnits = record[1]
         if unitCount >= maxUnits:
             errorslist.append({"message":"You have reached the max units allowed for your account ("+str(maxUnits)+"). If you would like to add \
                                                         more, please contact us at [email protected] so that we can better accommodate you."})
             return errorslist
     
     if not valid.label(name):
         errorslist.append({'selector':'#propertyName', "message": "Please enter a valid property name"})
     elif action=='create' or (action=='save' and model.Property.get_name_by_id(request.POST['id']) != name):
         if model.Property.property_name_exist(name, request.environ.get("COMPANY_ID")):
             errorslist.append({'selector':'#propertyName', "message": "Property name already exists"})
     
     if not valid.street(street):
         errorslist.append({'selector':'#propertyStreet', "message":"Please enter a valid street"})
     
     if not valid.city(city):
         errorslist.append({'selector':'#propertyCity', "message":"Please enter a valid city"})
     
     if not valid.state(state):
         errorslist.append({'selector':'#propertyState', "message":"Please enter a valid state"})
     
     if not valid.zip(zip):
         errorslist.append({'selector':'#propertyZip', "message":"Please enter a valid zip code"})
     
     '''
     split_zip = zip.split('-')
     address = usps() 
     address.address2 = street
     address.city = city
     address.state = state
     address.zip5 = split_zip[0]
     address.zip4 = split_zip[1] if len(split_zip) == 2 else ''
     address = address.verify() 
     if not address: 
         errorslist.append({"message":"Sorry, USPS could not verify your address is real.\
              We only support USPS verified addresses right now.  If you believe this \
              to be a mistake, please contact us at {0}.".format(settings.EMAIL_SUPPORT)})
     '''
     
     return errorslist
예제 #4
0
 def validate(self):
     label = request.POST['label']
     address = request.POST['address']
     city = request.POST['city']
     state = request.POST['state']
     zip = request.POST['zip']
     phone = request.POST['phone']
     email = request.POST['email']
     type = request.POST['type'].strip()
     description = request.POST['description']
     
     errorslist = []
     
     if not valid.label(label):
         errorslist.append({'selector':'#name', "message":"Please enter a valid name"})
     
     if not email and not phone:
         errorslist.append({'selector':'#email,#phone', "message":"You must enter either an email or a phone number"})
     
     if email and not valid.email(email):
         errorslist.append({'selector':'#email', "message":"Please enter a valid email"})
     
     if phone and not valid.phone(phone):
         errorslist.append({'selector':'#phone', "message":"Please enter a valid phone"})
     
     if int(request.POST['newtype']) and not valid.label(type):
         errorslist.append({'selector':'#new-type-label', "message":"Please enter a valid type name"})
     
     if address and not valid.street(address):
         errorslist.append({'selector':'#street', "message":"Please enter a valid street"})
     
     if city and not valid.city(city):
         errorslist.append({'selector':'#city', "message":"Please enter a valid city"})
     
     if state and not valid.state(state):
         errorslist.append({'selector':'#state', "message":"Please enter a valid state"})
     
     if zip and not valid.zip(zip):
         errorslist.append({'selector':'#zip', "message":"Please enter a valid zip code"})
     
     if description and not valid.description(description):
         errorslist.append({'selector':'#description', "message":'Please enter description without special characters\
     																		such as "<","^","@", etc'})
     
     if not type:
         errorslist.append({'selector':'#new-type-label', "message":"Please enter a valid category"})
     
     return errorslist
예제 #5
0
 def validate(self, action=None):
     name = request.POST['name'].strip()
     address = request.POST['street'].strip()
     city = request.POST['city'].strip()
     state = request.POST['state'].strip()
     zip = request.POST['zip'].strip()
     
     errorslist = []
     
     if action == 'create':
         record = model.Unit.get_num_units(request.environ.get('COMPANY_ID'))
         unitCount = record[0]
         maxUnits = record[1]
         if unitCount >= maxUnits:
             errorslist.append({"message":"You have reached the max units allowed for your account ("+str(maxUnits)+"). If you would like to add \
                                                         more, please contact us at [email protected] so that we can better accommodate you."})
             return errorslist
     
     if not valid.label(name):
         errorslist.append({'selector':'#propertyName', "message": "Please enter a valid property name"})
     elif action=='create' or (action=='save' and model.Property.get_name_by_id(request.POST['id']) != name):
         if model.Property.property_name_exist(name, request.environ.get("COMPANY_ID")):
             errorslist.append({'selector':'#propertyName', "message": "Property name already exists"})
     
     if not valid.street(address):
         errorslist.append({'selector':'#propertyStreet', "message":"Please enter a valid street"})
     
     if not valid.city(city):
         errorslist.append({'selector':'#propertyCity', "message":"Please enter a valid city"})
     
     if not valid.state(state):
         errorslist.append({'selector':'#propertyState', "message":"Please enter a valid state"})
     
     if not valid.zip(zip):
         errorslist.append({'selector':'#propertyZip', "message":"Please enter a valid zip code"})
     
     return errorslist