def validate(self, action=None, floorplanid=None, propertyid=None): name = request.POST['name'].strip() sqft = request.POST['sqft'].strip() beds = request.POST['beds'].strip() baths = request.POST['baths'].strip() description = request.POST['description'].strip() errorslist = [] if not valid.label(name): errorslist.append({'selector':'#floorPlanName', "message":"Please enter only letters and numbers for the floorplan name"}) elif action=='create' or (action=='save' and model.Floorplan.get_name_by_id(floorplanid) != name): if model.Floorplan.floorplan_name_exist(name, propertyid): errorslist.append({'selector':'#floorPlanName', "message": "Floorplan name already exist"}) if not valid.floorplan_numbers(sqft) or not valid.sqft(sqft): errorslist.append({'selector':'#sqft', "message":"Please enter a valid value for sqft"}) if not valid.floorplan_numbers(beds) or not valid.beds(beds): errorslist.append({'selector':'#beds', "message":"Please enter a valid value for beds"}) if not valid.floorplan_numbers(baths) or not valid.baths(baths): errorslist.append({'selector':'#baths', "message":"Please enter a valid value for baths"}) if description and not valid.description(description): errorslist.append({'selector':'#floorPlanDescription', "message":'Please enter description without special characters\ such as "<","^","@", etc'}) return errorslist
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