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
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
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
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