class UploadVideoForm(FlaskForm): title = wtf.StringField( 'title', validators=[wtf.validators.DataRequired()] ) description = wtf.TextAreaField( 'description', validators=[wtf.validators.DataRequired()] ) price = wtf.DecimalField( 'price', validators=[wtf.validators.DataRequired()] ) labels = wtf.StringField( 'labels', validators=[wtf.validators.DataRequired()] ) video_file = fwtff.FileField( 'vfile', validators=[ fwtff.FileRequired(), fwtff.FileAllowed(['mp4']) ] ) submit = wtf.SubmitField('submit')
class MediaCommentForm(wtforms.Form): comment_content = wtforms.TextAreaField( _('Comment'), [wtforms.validators.InputRequired()], description=_( u'You can use ' u'<a href="http://daringfireball.net/projects/markdown/basics" target="_blank">' u'Markdown</a> for formatting.'))
class QuestionEditorForm(EditorForm): order_number = wtf.IntegerField(_l('Order Number'), validators=[wtf.validators.DataRequired()]) time = wtf.IntegerField(_l('Time'), validators=[wtf.validators.DataRequired()]) show_choices = wtf.BooleanField(_l('Show Choices'), validators=[wtf.validators.Optional()]) content = wtf.TextAreaField() submit = wtf.SubmitField(_l('Save'), render_kw={'class_': 'btn btn-success'}) delete = wtf.SubmitField(_l('Remove'), render_kw={'class_': 'btn btn-danger'}) def __init__(self, question: model.Question = None, block: model.Block = None, *args, **kwargs): if question is None: if block is None or block.id is None: raise ValueError('Block must be provided for new question!') else: latest = block.questions\ .order_by(model.Question.order_number.desc())\ .first() if latest is None: order_number = 1 else: order_number = latest.order_number + 1 question = model.Question(block_id=block.id, order_number=order_number) super().__init__(question, *args, **kwargs)
class DonationForm(FlaskForm): first_name = form.StringField( 'First Name', validators=[validator.DataRequired(), validator.Length(max=100)], render_kw={"placeholder": "Your First Name"}) last_name = form.StringField( 'Last Name', validators=[validator.DataRequired(), validator.Length(max=100)], render_kw={"placeholder": "Your Last Name"}) phone_number = form.StringField( 'Phone Number', validators=[validator.Length(max=50)], render_kw={"placeholder": "Your Phone Number"}) email = form.StringField('Email Address', render_kw={"placeholder": "Your Email Address"}, validators=[ validator.DataRequired(), validator.Email(), validator.Length(max=50) ]) amount = form.FloatField( 'Enter Amount', validators=[validator.DataRequired(), validator.NumberRange(min=0)], render_kw={"placeholder": "Enter an Amount"}) message = form.TextAreaField( 'Message', validators=[validator.Optional()], render_kw={"placeholder": "Send a message to the newly-weds"})
class UserSettingsForm(PagureForm): ''' Form to create or edit project. ''' ssh_key = wtforms.TextAreaField( 'Public SSH keys <span class="error">*</span>', [wtforms.validators.Required(), ssh_key_validator] )
class MirrorForm(FlaskForm): """ Form to configure the mirror hook. """ active = wtforms.BooleanField("Active", [wtforms.validators.Optional()]) target = wtforms.StringField( "Git repo to mirror to", [RequiredIf("active"), CustomRegexp(ssh_urlpattern, optional=True)], ) public_key = wtforms.TextAreaField( "Public SSH key", [wtforms.validators.Optional()] ) last_log = wtforms.TextAreaField( "Log of the last sync:", [wtforms.validators.Optional()] )
class ConfigUpdateForm(wtf.Form): analytics_id = wtforms.StringField('Tracking ID', filters=[util.strip_filter]) announcement_html = wtforms.TextAreaField('Announcement HTML', filters=[util.strip_filter]) announcement_type = wtforms.SelectField( 'Announcement Type', choices=[(t, t.title()) for t in model.Config.announcement_type._choices]) anonymous_recaptcha = wtforms.BooleanField( 'Use reCAPTCHA in forms for unauthorized users') brand_name = wtforms.StringField('Brand Name', [wtforms.validators.required()], filters=[util.strip_filter]) check_unique_email = wtforms.BooleanField( 'Check for uniqueness of the verified emails') email_authentication = wtforms.BooleanField( 'Email authentication for sign in/sign up') feedback_email = wtforms.StringField( 'Feedback Email', [wtforms.validators.optional(), wtforms.validators.email()], filters=[util.email_filter]) flask_secret_key = wtforms.StringField('Flask Secret Key', [wtforms.validators.optional()], filters=[util.strip_filter]) notify_on_new_user = wtforms.BooleanField( 'Send an email notification when a user signs up') recaptcha_private_key = wtforms.StringField('Private Key', filters=[util.strip_filter]) recaptcha_public_key = wtforms.StringField('Public Key', filters=[util.strip_filter]) salt = wtforms.StringField('Salt', [wtforms.validators.optional()], filters=[util.strip_filter]) verify_email = wtforms.BooleanField('Verify user emails')
class AddSiteForm(FlaskForm): """ Form to add or edit a site. """ name = wtforms.TextField( 'Site name', [wtforms.validators.InputRequired()] ) password = wtforms.TextField( 'Site Password', [wtforms.validators.InputRequired()] ) org_url = wtforms.TextField( 'Organisation URL', [wtforms.validators.InputRequired()], ) private = wtforms.BooleanField( 'Private', default=False ) admin_active = wtforms.BooleanField( 'Admin active', default=True ) user_active = wtforms.BooleanField( 'User active', default=True ) all_sites_can_pull_from_me = wtforms.BooleanField( 'All sites can pull from me?', default=False ) downstream_comments = wtforms.TextAreaField( 'Comments for downstream siteadmins', )
class KeyPairImportForm(BaseSecureForm): """Key Pair Import form """ name_error_msg = _(u'Name is required') key_material_error_msg = _(u'Public Key Contents are required') name = wtforms.TextField( id=u'key-name', label=_(u'Name'), validators=[ validators.InputRequired(message=name_error_msg), validators.Length(min=1, max=255) ], ) key_material = wtforms.TextAreaField( id=u'key-import-contents', label=_(u'Public SSH Key Contents'), validators=[ validators.InputRequired(message=key_material_error_msg), validators.Length(min=1) ], ) def __init__(self, request, keypair=None, **kwargs): super(KeyPairImportForm, self).__init__(request, **kwargs) self.request = request self.name.error_msg = self.name_error_msg # Used for Foundation Abide error message self.key_material.error_msg = self.key_material_error_msg if keypair is not None: self.name.data = keypair.name
class ParticipantForm(Form): name = wtforms.TextField( u'Name', description=u"Please enter full name of the Participant", validators=[wtforms.validators.Required('A name is required')]) email = wtforms.fields.html5.EmailField( u'e-mail', validators=[ wtforms.validators.Required('Please enter the email'), wtforms.validators.Email() ]) phone = wtforms.TextField(u'Phone') company = wtforms.TextField(u'Company') job = wtforms.TextField(u'Job Title') city = wtforms.TextField(u'City') twitter = wtforms.TextField( u'twitter handle', description=u"Twitter handle of the participant without the @ symbol") notes = wtforms.TextAreaField('Notes') nfc_id = wtforms.HiddenField('NFC') def __init__(self, event): self.event = event super(ParticipantForm, self).__init__() def validate_email(self, field): if Participant.query.filter_by(email=field.data, event_id=self.event.id).first(): raise wtforms.ValidationError( u'The email address %s already exists' % field.data) def validate_nfc_id(self, field): if not field.data: field.data = None
class EditForm(FlaskForm): name = wtforms.StringField( 'Title', validators=[validators.DataRequired('Title is required')]) content = wtforms.TextAreaField('Content', validators=[validators.Optional()]) slug = wtforms.StringField('Slug', validators=[validators.Optional()]) submit = wtforms.SubmitField('Update')
class NPSForm(flask_wtf.FlaskForm): nps = wtforms.RadioField( label= "How likely is it that you would recommend the Backgammon Network to a friend?", choices=[ (1, "1"), (2, "2"), (3, "3"), (4, "4"), (5, "5"), (6, "6"), (7, "7"), (8, "8"), (9, "9"), (10, "10"), ], coerce=int, validators=[ wtforms.validators.DataRequired(), wtforms.validators.NumberRange(1, 10), ], ) comments = wtforms.TextAreaField( label="Any other feedback? (Optional)", validators=[ wtforms.validators.Optional(), wtforms.validators.Length(max=511) ], )
class Contact(flask_wtf.FlaskForm): email = wtforms.StringField( label="Email", render_kw={"placeholder": "Email..."}, validators=[ validators.InputRequired(message="Please enter an email address."), validators.Email(message="Please enter a valid email address."), ], ) enquiry = wtforms.StringField( label="Enquiry", render_kw={"placeholder": "Enquiry..."}, validators=[ validators.InputRequired(message="Please fill in your enquiry."), validators.Length( min=4, max=150, message="Enquiry must be between 4 and 150 characters long.", ), ], ) body = wtforms.TextAreaField( label="Body", render_kw={"placeholder": "Body..."}, validators=[ validators.InputRequired( message="Please write something for this enquiry.") ], ) submit = wtforms.SubmitField(label="Submit")
class SpecimenForm(wtforms.Form): ui_selected = wtforms.BooleanField() id = wtforms.IntegerField(widget=wtforms.widgets.HiddenInput()) tubes = wtforms.IntegerField(validators=[ wtforms.validators.input_required(), wtforms.validators.NumberRange(min=1) ]) collect_date = DateField(validators=[conditionally_required]) collect_time = TimeField( # There doesn't seem to be a nice way to add the colon if the # user forgets to do so, might need to make our own Field type format='%H:%M', validators=[conditionally_required]) location_id = wtforms.SelectField(choices=locations, coerce=int, validators=[conditionally_required]) notes = wtforms.TextAreaField( validators=[wtforms.validators.optional()])
class IssueForm(FlaskForm): title = fields.StringField('Title', [validators.DataRequired()]) description = fields.TextAreaField('Description', [validators.DataRequired(), validators.length(max=500)]) locationBulding = fields.SelectField('locationBulding', [validators.DataRequired()], choices=[('1', '1'), ('16', '16'), ('18', '18'), ('2', '2'), ('20', '20'), ('25', '25'), ('32', '32'), ('34', '34'), ('36', '36'), ('38', '38'), ('39', '39'), ('40', '40'), ('42', '42'), ('44', '44'), ('45', '45'), ('46', '46'), ('48', '48'), ('5', '5'), ('50', '50'), ('52', '52'), ('53', '53'), ('54', '54'), ('57', '57'), ('58', '58'), ('59', '59'), ('67', '67'), ('7', '7'), ('8', '8'), ('85', '85')]) location = fields.StringField('Location', [validators.DataRequired()]) image = fields.StringField('Image URL') submit = fields.SubmitField(label='Submit')
class RestaurantForm(FlaskForm): name = f.StringField('Name', validators=[DataRequired()]) lat = f.FloatField('Latitude', validators=[DataRequired()]) lon = f.FloatField('Longitude', validators=[DataRequired()]) phone = f.StringField('Phone', validators=[DataRequired()]) # Note: the capacity is automatically derived from tables settings cuisine_type = f.SelectMultipleField( 'Cuisine types', choices = Restaurant.CUISINE_TYPES.choices(), coerce = Restaurant.CUISINE_TYPES.coerce, validators=[DataRequired()] ) prec_measures = f.TextAreaField('Precautionary measures',validators=[DataRequired()]) avg_time_of_stay = f.IntegerField('Average time of stay (in minutes)', validators=[DataRequired(), NumberRange(min=15)]) workingdays = f.FieldList(f.FormField(WorkingDayForm), min_entries=1, max_entries=7) tables = f.FieldList(f.FormField(TableForm), min_entries=1, max_entries=100) dishes = f.FieldList(f.FormField(DishForm), min_entries=1, max_entries=100) display = ['name', 'lat', 'lon', 'phone', 'cuisine_type', 'prec_measures', 'avg_time_of_stay'] def validate_workingdays(form, field): days_already_added = [] for wd in field.data: if wd['day'] in days_already_added: raise ValidationError("There cannot be two working days with the same day") else: days_already_added.append(wd['day'])
class EntryForm(wtforms.Form): title = wtforms.StringField('Название', validators=[DataRequired()]) body = wtforms.TextAreaField('Контент', validators=[DataRequired()]) tags = TagField('Тэги', description="Теги разделяются точкой с запятой") status = wtforms.SelectField('Статус', choices=((EntryService.VALID_STATUSES[0], 'Черновое'), (EntryService.VALID_STATUSES[1], 'Обобществлённое')), coerce=int) type = wtforms.SelectField('Тип', choices=((EntryService.VALID_TYPES[0], 'Твит'), (EntryService.VALID_TYPES[1], 'Пост')), coerce=int) def save_entry(self): entry = EntryService.get_new_entry() entry = self.modify_entry(entry) return entry def modify_entry(self, entry): self.populate_obj(entry) entry = EntryService.save_entry(entry) return entry def save_new_tags(self): new_tags = self.tags.get_new_tags() TagService.save_tag_list(new_tags) return new_tags
class CommentForm(wtforms.Form): author = wtforms.TextField(label='Your Name', validators=[validators.Required(), NoHTML()]) email = wtforms.TextField( label='Email', validators=[validators.Required(), validators.Email()], description='Never displayed') body = wtforms.TextAreaField( description= 'No HTML, but feel free to use <a href="http://daringfireball.net/projects/markdown/">Markdown</a>', validators=[validators.Required(), NoHTML()]) def __init__(self, formdata=None, *args, **kwargs): super(CommentForm, self).__init__(formdata, *args, **kwargs) self.commenter = None if 'plogcmt' in request.cookies: self.commenter = Commenter.objects( cookie=request.cookies['plogcmt']).first() if self.commenter and formdata is None: del self.email self.author.data = self.commenter.author def validate(self): if self.commenter: self.email.data = self.commenter.email return super(CommentForm, self).validate()
class SubscribeForm(FlaskForm): name = wtforms.StringField( _('Ваше име'), validators=[ wtforms.validators.DataRequired('asdsada'), wtforms.validators.InputRequired(), wtforms.validators.Length(min=5, max=40), ] ) email = wtforms.StringField( _('Ваша е-пошта'), validators=[ wtforms.validators.DataRequired(), wtforms.validators.InputRequired(), wtforms.validators.Length(min=5, max=40), wtforms.validators.Email(), ] ) message = wtforms.TextAreaField( _('Ваша порука'), validators=[ wtforms.validators.DataRequired(), wtforms.validators.InputRequired(), wtforms.validators.Length(max=1000), ] )
class AddReportForm(PagureForm): """ Form to verify that comment is not empty """ report_name = wtforms.TextAreaField( 'Report name<span class="error">*</span>', [wtforms.validators.Required()] )
class AddPullRequestCommentForm(wtf.Form): ''' Form to add a comment to a pull-request. ''' commit = wtforms.HiddenField('commit identifier') row = wtforms.HiddenField('row') requestid = wtforms.HiddenField('requestid') comment = wtforms.TextAreaField('Comment<span class="error">*</span>', [wtforms.validators.Required()])
class PurchaseForm(wtforms.Form): quote_amount = wtforms.FormField(custom_fields.MoneyForm, widget=custom_fields.form_field_widget) supplier = custom_fields.SelectField( coerce=data_models.create_key, validators=[wtforms.validators.InputRequired()]) description = wtforms.TextAreaField()
class AddUrlForm(wtforms.Form): """Validation and fields for the form/page which allows a user to save/add a URL/link. """ url = wtforms.StringField( 'url', [ wtforms.validators.URL(require_tld=True), ], render_kw={ "placeholder": "URL/Link", "class": "form-control input-lg", "id": "url", "autofocus": True }, ) description = wtforms.TextAreaField( 'description', [ wtforms.validators.Length(max=140), ], render_kw={ "placeholder": "Description/about URL", "class": "form-control input-lg", "id": "description", "maxlength": 140, }, )
class NewsItemForm(Form): title = wtforms.StringField('Title', validators=[validators.Required()]) content = wtforms.TextAreaField('Content', render_kw = {"rows": 15}, validators=[validators.Required()]) members_only = wtforms.BooleanField()
class EditCommentForm(wtf.Form): """ Form to verify that comment is not empty """ update_comment = wtforms.TextAreaField( 'Comment<span class="error">*</span>', [wtforms.validators.Required()] )
class UpdateIssueForm(wtf.Form): ''' Form to add a comment to an issue. ''' tag = wtforms.TextField( 'tag', [ wtforms.validators.Optional(), wtforms.validators.Regexp(TAGS_REGEX, flags=re.IGNORECASE) ] ) depends = wtforms.TextField( 'dependency issue', [wtforms.validators.Optional()] ) blocks = wtforms.TextField( 'blocked issue', [wtforms.validators.Optional()] ) comment = wtforms.TextAreaField( 'Comment', [wtforms.validators.Optional()] ) assignee = wtforms.TextAreaField( 'Assigned to', [wtforms.validators.Optional()] ) status = wtforms.SelectField( 'Status', [wtforms.validators.Optional()], choices=[(item, item) for item in []] ) priority = wtforms.SelectField( 'Priority', [wtforms.validators.Optional()], choices=[(item, item) for item in []] ) def __init__(self, *args, **kwargs): """ Calls the default constructor with the normal argument but uses the list of collection provided to fill the choices of the drop-down list. """ super(UpdateIssueForm, self).__init__(*args, **kwargs) if 'status' in kwargs: self.status.choices = [ (status, status) for status in kwargs['status'] ] if 'priorities' in kwargs: self.priority.choices = [ (key, val) for key, val in kwargs['priorities'].iteritems() ]
class LaunchMoreInstancesForm(BaseSecureForm): """Form class for launch more instances like this one""" number_error_msg = _( u'Number of instances must be a whole number greater than 0') number = wtforms.IntegerField( label=_(u'How many instances would you like to launch?'), validators=[ validators.InputRequired(message=number_error_msg), validators.NumberRange( min=1, max=10 ), # Restrict num instances that can be launched in one go ], ) userdata = wtforms.TextAreaField(label=_(u'User data')) userdata_file_helptext = _(u'User data file may not exceed 16 KB') userdata_file = wtforms.FileField(label=_(u'')) kernel_id = wtforms.SelectField(label=_(u'Kernel ID')) ramdisk_id = wtforms.SelectField(label=_(u'RAM disk ID (RAMFS)')) monitoring_enabled = wtforms.BooleanField( label=_(u'Enable detailed monitoring')) private_addressing = wtforms.BooleanField( label=_(u'Use private addressing only')) def __init__(self, request, image=None, instance=None, conn=None, **kwargs): super(LaunchMoreInstancesForm, self).__init__(request, **kwargs) self.image = image self.instance = instance self.conn = conn self.choices_manager = ChoicesManager(conn=conn) self.set_error_messages() self.set_help_text() self.set_choices() self.set_initial_data() def set_error_messages(self): self.number.error_msg = self.number_error_msg def set_help_text(self): self.userdata_file.help_text = self.userdata_file_helptext def set_choices(self): self.kernel_id.choices = self.choices_manager.kernels(image=self.image) self.ramdisk_id.choices = self.choices_manager.ramdisks( image=self.image) def set_initial_data(self): self.monitoring_enabled.data = self.instance.monitored self.private_addressing.data = self.enable_private_addressing() self.number.data = 1 def enable_private_addressing(self): if self.instance.private_ip_address == self.instance.ip_address: return True return False
class AddPullRequestFlagForm(wtf.Form): ''' Form to add a flag to a pull-request. ''' username = wtforms.TextField('Username', [wtforms.validators.Required()]) percent = wtforms.TextField('Percentage of completion', [wtforms.validators.Required()]) comment = wtforms.TextAreaField('Comment', [wtforms.validators.Required()]) url = wtforms.TextField('URL', [wtforms.validators.Required()]) uid = wtforms.TextField('UID', [wtforms.validators.optional()])
class UpdateIssueForm(wtf.Form): ''' Form to add a comment to an issue. ''' tag = wtforms.TextField('tag', [ wtforms.validators.Optional(), wtforms.validators.Regexp(TAGS_REGEX, flags=re.IGNORECASE), wtforms.validators.Length(max=255), ]) depends = wtforms.TextField('dependency issue', [wtforms.validators.Optional()]) blocks = wtforms.TextField('blocked issue', [wtforms.validators.Optional()]) comment = wtforms.TextAreaField('Comment', [wtforms.validators.Optional()]) assignee = wtforms.TextAreaField('Assigned to', [wtforms.validators.Optional()]) status = wtforms.SelectField('Status', [wtforms.validators.Optional()], choices=[]) priority = wtforms.SelectField('Priority', [wtforms.validators.Optional()], choices=[]) milestone = wtforms.SelectField('Milestone', [wtforms.validators.Optional()], choices=[]) private = wtforms.BooleanField( 'Private', [wtforms.validators.optional()], ) def __init__(self, *args, **kwargs): """ Calls the default constructor with the normal argument but uses the list of collection provided to fill the choices of the drop-down list. """ super(UpdateIssueForm, self).__init__(*args, **kwargs) if 'status' in kwargs: self.status.choices = [(status, status) for status in kwargs['status']] self.priority.choices = [] if 'priorities' in kwargs: for key in sorted(kwargs['priorities']): self.priority.choices.append((key, kwargs['priorities'][key])) self.milestone.choices = [] if 'milestones' in kwargs: for key in sorted(kwargs['milestones']): self.milestone.choices.append((key, key)) self.milestone.choices.insert(0, ('', ''))
class ContactForm(MyBaseForm): name = wtforms.StringField("Name", [wtforms.validators.DataRequired()]) email = html5.EmailField("Email", [wtforms.validators.Email(), wtforms.validators.DataRequired()]) phone = wtforms.StringField("Phone") message = wtforms.TextAreaField("Message", [wtforms.validators.DataRequired()]) submit = wtforms.SubmitField("Submit")