class AddTemplateForm(Form): next = HiddenField() name = TextField(_(u'Choose the template name'), [Required(), Length(NAME_LEN_MIN, NAME_LEN_MAX)], description=_(u"Don't worry. you can change it later.")) # image_id = IntegerField(_(u'Choose the image attached on this template'), [Required()]) image_id = SelectField(_(u'Choose the image attached on this template'), choices=[]) vcpu_desc = _("Choose the VCPU number (From %(min)d to %(max)d)", min=VCPU_NUM_MIN, max=VCPU_NUM_MAX) vcpu = IntegerField(vcpu_desc, [Required(), NumberRange(VCPU_NUM_MIN, VCPU_NUM_MAX)]) pcpu_desc = _("Input the CPU value (1 physical CPU = 100 CPU value)") pcpu = IntegerField(pcpu_desc, [Required()]) memory_desc = _("Choose the memory size (From %(min)dM to %(max)dM)", min=MEM_SIZE_MIN, max=MEM_SIZE_MAX) memory = IntegerField(memory_desc, [Required(), NumberRange(MEM_SIZE_MIN, MEM_SIZE_MAX)]) disk_desc = _("Choose the disk size (From %(min)dM to %(max)dM)", min=DISK_SIZE_MIN, max=DISK_SIZE_MAX) disk = IntegerField(disk_desc, [Required(), NumberRange(DISK_SIZE_MIN, DISK_SIZE_MAX)]) submit = SubmitField(_('Save')) def validate_name(self, field): if Template.query.filter_by(name=field.data).first() is not None: raise ValidationError(_(u'This template name is taken')) def validate_image_id(self, field): if Image.query.filter_by(id=field.data).first() is None: raise ValidationError(_(u'This Image is not found'))
class RegisterForm(Form): # userobj = mod.User() # userobj.name = TextField('Username', validators = [Required(), Length(min=6, max=20)]) # userobj.email = TextField('Email', validators = [Required(), Length(min=6, max=30)]) # userobj.password = PasswordField('Password', validators = [Required(), Length(min=6, max=30)]) # userobj.confirm = PasswordField('Repeat Password', [Required(), EqualTo('password', message='Passwords must match')]) # userobj.institution = TextField('Institution', validators = [Required(), Length(min=4, max=40)]) # userobj.security_question= TextField('Security Question', validators = [Required(), Length(min=10, max=40)]) # userobj.security_answer = TextField('Security Answer', validators = [Required(), Length(min=4, max=40)]) # print " comes RegisterForm" # print "name:", userobj.name, "\n","email:",userobj.email name = TextField('Username', validators = [Required(), Length(min=6, max=20)]) email = TextField('Email', validators = [Required(), Length(min=6, max=30)]) password = PasswordField('Password', validators = [Required(), Length(min=6, max=30)]) confirm = PasswordField('Repeat Password', [Required(), EqualTo('password', message='Passwords must match')]) institution = TextField('Institution', validators = [Required(), Length(min=4, max=40)]) security_question= TextField('Security Question', validators = [Required(), Length(min=10, max=40)]) security_answer = TextField('Security Answer', validators = [Required(), Length(min=4, max=40)])
class ChangePasswordForm(Form): old = PasswordField("Current Password", validators = [PasswordValidator()]) new = PasswordField("New Password", validators=[Length(min = 6, message = "Please enter a password of at least 6 characters.")]) new2 = PasswordField("New Password, again", validators=[EqualTo("new", "Passwords do not match.")])
class TechnicianForm(Form): name = TextField("Name", validators=[Required(), Length(max=40)]) login = TextField("Login", validators=[Required(), Length(max=10)]) active = BooleanField('Active', default=True)
class ForgotForm(Form): email = TextField('Email', validators = [Required(), Length(min=6, max=40)])
class ReleaseEventsAPIForm(Form): sent = DateTimeField('Sent:', validators=[InputRequired('Sent is required.')]) event_name = StringField('Event Name:', validators=[InputRequired('Event Name is required.'), Length(0, 150)]) platform = StringField('Platform:') results = IntegerField('Results:', default=0, validators=[InputRequired('Results is required.')]) chunkNum = IntegerField('Chunk Number:', default=1) chunkTotal = IntegerField('Chunk Total:', default=1) group = StringField('Group:', default='other')
class RemoveAdminForm(Form): """Form for removing a build admin.""" user_id = HiddenField(validators=[Length(min=1, max=200)]) build_id = HiddenField(validators=[NumberRange(min=1)]) revoke = SubmitField('Revoke')
class EditForm(Form): nickname = TextField('nickname', validators=[Required()]) about_me = TextAreaField('about_me', validators=[Length(min=0, max=140)])
class EditForm(Form): fname = TextField('*First Name', validators=[Required()]) bio = TextAreaField('Bio', validators=[Length(min=0, max=140)])
class WriteComment(Form): text = TextAreaField("Comment", validators=[Required(), Length(max=65535)])
class SubmitEditEntry(Form): title = TextField("Entry title", validators=[Required(), Length(max=128)]) description = TextAreaField("Description", validators=[Required()])
class ContactForm(Form): name = TextField(u'Name', [Required(), Length(min=2, max=128)]) email = TextField(u'E-mail', [Required(), Email()]) message = TextAreaField(u'Your message', [Required()])
class ItemForm(Form): content = TextField(u'Content', [Required(), Length(max=255)]) details = TextAreaField(u'Details', [Length(max=2048)]) is_done = BooleanField(u'Is done?') due = ExtDateTimeField(u'Due')
def __call__(self, form, field): if current_app.security.datastore.find_user(email=field.data): raise ValidationError(self.message) validators = { 'email': [ Required(), Email(), UniqueUser(message='Email address is associated with ' 'an existing account') ], 'password': [ Required(), Length(min=6, max=50), EqualTo('confirm', message='Passwords must match'), Regexp(r'[A-Za-z0-9@#$%^&+=]', message='Password contains invalid characters') ] } class RegisterForm(Form): email = TextField('Email', validators['email']) password = PasswordField( 'Password', validators['password'], ) confirm = PasswordField('Confirm Password')
class TempDtlForm(Form): act_type = SelectField(u'Transaction Type:', choices=[('upd', 'Update'), ('hir', 'Hire'), ('xtn', 'Extension'), ('cnv', 'Convert'), ('ter', 'Terminate')], validators=[validate_empid]) effdt = DateField('Effective Date:', id='effdt', validators=[Required()], format='%Y-%m-%d') first_name = TextField('First Name:', id='first_name', validators=[Required()]) last_name = TextField('Last Name:', id='last_name', validators=[Required()]) type = SelectField(u'Temp Type:', choices=[('C', 'Consultant'), ('F', 'Fixed Term Contractors'), ('T', 'Temporary Contractor'), ('W', 'Temporary Worker'), ('O', 'Other')]) classification = SelectField(u'Classification:', choices=[('Structural', 'Structural'), ('Full term', 'Full term'), ('Project', 'Project'), ('Interim', 'Interim'), ('Intermittent', 'Intermittent'), ('Short Term', 'Short Term')]) reason = SelectField(u'Action Reason:', choices=[('LOA', 'LOA'), ('Add', 'Add'), ('Short', 'Short'), ('Seasonal', 'Seasonal'), ('Project', 'Project'), ('Replace', 'Replace'), ('Other', 'Other')]) busn_email = TextField( 'Work Email:', id='email', validators=[ Length(min=6, message=(u'Little short for an email address?')), Email(message=(u'That\'s not a valid email address.')) ]) req_num = TextField('Requisition Number:', id='reqnum') mgr = TextField('Supervisor:', id='mgr', validators=[Required()]) supervisor = HiddenField('Supervisor ID:', id='supervisor', validators=[Required()]) it_end_date = DateField('IT End Date:', id='end_dt', validators=[Required()], format='%Y-%m-%d') finance = TextField('Finance Division:', id='finance', validators=[Required()]) finance_org = TextField('Financial Org:', id='finorg', validators=[Required()]) hr_contact = HiddenField(id='hr_contact') hr_name = TextField('HR Contact:', id='hr_name', validators=[Required()]) business_title = TextField('Business Title:', id='bus_tit') legal_entity = TextField('Legal Entity:', id='legal', validators=[Required()]) dept = TextField('Department:', id='dept', validators=[Required()]) location = TextField('Location:', id='location', validators=[Required()]) remote = BooleanField('Remote:', id='remote') busn_phone = TextField('Work Phone:', id='bus_phn') vendor_id = TextField('Vendor ID:', id='vndrid') it_end_date = DateField('IT End Date:', id='it_end_date', validators=[Required()], format='%Y-%m-%d') emplid = HiddenField('Employee ID:', id='emplid') action_type = HiddenField(id='action_type') id = HiddenField(id='id') emplid = TextField('Employee ID:', id='emplid') bill_rate = TextField('Bill Rate:', id='brate') hourly_rate = TextField('Hourly Rate:', id='hrate') comments = TextAreaField('Comments', id='comments') mlsnd = BooleanField('Send Mail:', id='mlsnd') mailr = QuerySelectMultipleField(query_factory=enabled_categories, get_label='name', allow_blank=False) submit = SubmitField('Update')
class SignupForm(Form): email = TextField("E-Mail", validators=[Required(), Email()]) password = PasswordField("Choose Password", validators=[Required(), Length(min=4, max=50)])
class AddVMForm(Form): next = HiddenField() name = TextField(_(u'Choose virtualmachine name'), [Required(), Length(1, NAME_LEN_MAX)]) template_id = SelectField(_(u'Choose the template'), choices=[]) submit = SubmitField(_('Save'))
class SubscriptionForm(Form): """Subscription form""" email = EmailField(label="Email address", validators=[Length(min=6, max=120), Email()])
class ReauthForm(Form): next = HiddenField() password = PasswordField( u'Password', [Required(), Length(PASSWORD_LEN_MIN, PASSWORD_LEN_MAX)]) submit = SubmitField('Reauthenticate')
class Edit_Form(Form): description = TextAreaField('description', validators=[ Length(max=5000, message="Description can't be longer than 5000 characters")]) submit = SubmitField("Submit")
class CreateApiKeyForm(Form): """Form for creating an API key.""" build_id = HiddenField(validators=[NumberRange(min=1)]) purpose = TextField('Purpose', validators=[Length(min=1, max=200)]) create = SubmitField('Create')
class BuildForm(Form): """Form for creating or editing a build.""" name = TextField(validators=[Length(min=1, max=200)])
class TagForm(Form): name = TextField('Name', [ Required(), Length(min=2, max=32), Regexp('^[a-z]+$', message='Tags must be [a-z].') ])
class ListingForm(Form): """Form for new job posts""" job_headline = TextField( "Headline", description= "A single-line summary. This goes to the front page and across the network", validators=[ Required("A headline is required"), Length(min=1, max=100, message="%(max)d characters maximum") ]) job_type = RadioField( "Type", coerce=int, validators=[Required("The job type must be specified")]) job_category = RadioField("Category", coerce=int, validators=[Required("Select a category")]) job_location = TextField( "Location", description= u'“Bangalore”, “Chennai”, “Pune”, etc or “Anywhere” (without quotes)', validators=[ Required( u"If this job doesn’t have a fixed location, use “Anywhere”") ]) job_relocation_assist = BooleanField("Relocation assistance available") job_description = TextAreaField( "Description", description= u"Our apologies for the mismatched font you see here. We’re (still) working on it", validators=[Required("A description of the job is required")]) job_perks = BooleanField("Job perks are available") job_perks_description = TextAreaField( "Describe job perks", description=u"Stock options, free lunch, free conference passes, etc") job_how_to_apply = TextAreaField( "How do people apply for this job?", description=u'Example: "Send a resume to [email protected]". ' u"Don’t worry about spambots seeing your email address. " u"We’ll secure it", validators=[ Required( u"HasGeek does not offer screening services. Please specify how candidates may apply" ) ]) hr_contact = RadioField( u"Is it okay for recruiters and other " u"intermediaries to contact you about this listing?", coerce=boolint, description=u"We’ll display a notice to this effect on the listing", default=0, choices=[(0, u"No, it is NOT OK"), (1, u"Yes, recruiters may contact me")]) company_name = TextField( "Name", description=u"The name of the organization where the position is. " u"No intermediaries or unnamed stealth startups. Use your own real name if the company isn’t named " u"yet. We do not accept listings from third parties such as HR consultants. Such listings may be " u"removed without notice.", validators=[ Required( u"This is required. Posting any name other than that of the actual organization is a violation of the ToS" ) ]) company_logo = FileField( "Logo", description= u"Optional — Your company logo will appear at the top of your listing. " u"170px wide is optimal. We’ll resize automatically if it’s wider", ) # validators=[file_allowed(uploaded_logos, "That image type is not supported")]) company_logo_remove = BooleanField("Remove existing logo") company_url = TextField("URL", description=u"Example: http://www.google.com", validators=[optional_url]) poster_email = EmailField( "Email", description=u"This is where we’ll send your confirmation email. " u"Use your company email id: " u"listings are classified by your email domain. " u"Your full email address will not be revealed to applicants.", validators=[ Required( "We need to confirm your email address before the job can be listed" ), Email("That does not appear to be a valid email address") ]) def validate_company_logo(form, field): if not request.files['company_logo']: return try: g.company_logo = process_image(request.files['company_logo']) except IOError, e: raise ValidationError(e.message) except KeyError, e: raise ValidationError("Unknown file format")
class UserForm(Form): name = StrippedTextField(u'User Name', \ validators=[Unique(), Length(min=0,max=100), Required()]) email = StrippedTextField(u'Email', \ validators=[Unique(), Length(min=0,max=100), Required()]) next = HiddenField()
class LoginForm(Form): next = HiddenField() login = TextField(u'Username or email', [Required()]) password = PasswordField('Password', [Required(), Length(PASSWORD_LEN_MIN, PASSWORD_LEN_MAX)]) remember = BooleanField('Remember me') submit = SubmitField('Sign in')
class RegisterForm(Form): name = TextField('Username', validators = [Required(), Length(min=6, max=25)]) email = TextField('Email', validators = [Required(), Length(min=6, max=40)]) password = PasswordField('Password', validators = [Required(), Length(min=6, max=40)]) confirm = PasswordField('Repeat Password', [Required(), EqualTo('password', message='Passwords must match')])
class ProfileForm(Form): multipart = True next = HiddenField() email = EmailField(_('Email'), [Required(), Email()]) # Don't use the same name as model because we are going to use populate_obj(). avatar_file = FileField(_("Avatar"), [Optional()]) sex_code = RadioField(_("Sex"), [AnyOf([str(val) for val in SEX_TYPE.keys()])], choices=[(str(val), label) for val, label in SEX_TYPE.items()]) age = IntegerField(_('Age'), [Optional(), NumberRange(AGE_MIN, AGE_MAX)]) phone = TelField(_('Phone'), [Length(max=64)]) url = URLField(_('URL'), [Optional(), URL()]) deposit = DecimalField( _('Deposit'), [Optional(), NumberRange(DEPOSIT_MIN, DEPOSIT_MAX)]) location = TextField(_('Location'), [Length(max=64)]) bio = TextAreaField(_('Bio'), [Length(max=1024)]) submit = SubmitField(_('Save')) def validate_name(form, field): user = User.get_by_id(current_user.id) if not user.check_name(field.data): raise ValidationError(_("Please pick another name.")) def validate_avatar_file(form, field): if field.data and not allowed_file(field.data.filename): raise ValidationError( _("Please upload files with extensions:") + " %s" % "/".join(ALLOWED_AVATAR_EXTENSIONS)) def create_profile(self, request, user): if self.avatar_file.data: upload_file = request.files[self.avatar_file.name] if upload_file and allowed_file(upload_file.filename): # Don't trust any input, we use a random string as filename. # or use secure_filename: # http://flask.pocoo.org/docs/patterns/fileuploads/ user_upload_dir = os.path.join( current_app.config['UPLOAD_FOLDER'], "user_%s" % user.id) current_app.logger.debug(user_upload_dir) make_dir(user_upload_dir) root, ext = os.path.splitext(upload_file.filename) today = datetime.now().strftime('_%Y-%m-%d') # Hash file content as filename. hash_filename = hashlib.sha1( upload_file.read()).hexdigest() + "_" + today + ext user.avatar = hash_filename avatar_ab_path = os.path.join(user_upload_dir, user.avatar) # Reset file curso since we used read() upload_file.seek(0) upload_file.save(avatar_ab_path) self.populate_obj(user) self.populate_obj(user.user_detail) db.session.add(user) db.session.commit()
class LoginForm(Form): username = TextField('Username', validators=[Required(), Length(max=32)])
class LoginForm(Form): email = TextField(u'用户名或Email', validators=[Required()]) password = PasswordField(u'密码', validators=[Required(), Length(min=5, max=60)])