class ConfigUpdateForm(i18n.Form): analytics_id = wtf.StringField('Tracking ID', filters=[util.strip_filter]) announcement_html = wtf.TextAreaField('Announcement HTML', filters=[util.strip_filter]) announcement_type = wtf.SelectField( 'Announcement Type', choices=[(t, t.title()) for t in model.Config.announcement_type._choices]) brand_name = wtf.StringField('Brand Name', [wtf.validators.required()], filters=[util.strip_filter]) facebook_app_id = wtf.StringField('App ID', filters=[util.strip_filter]) facebook_app_secret = wtf.StringField('App Secret', filters=[util.strip_filter]) feedback_email = wtf.StringField( 'Feedback Email', [wtf.validators.optional(), wtf.validators.email()], filters=[util.email_filter]) flask_secret_key = wtf.StringField('Secret Key', [wtf.validators.optional()], filters=[util.strip_filter]) locale = wtf.SelectField('Default Locale', choices=config.LOCALE_SORTED) notify_on_new_user = wtf.BooleanField( 'Send an email notification when a user signs up') twitter_consumer_key = wtf.StringField('Consumer Key', filters=[util.strip_filter]) twitter_consumer_secret = wtf.StringField('Consumer Secret', filters=[util.strip_filter])
class InventoryItemForm(wtf.Form): """Represents the admin inventory item form""" group = wtf.SelectField() name = wtf.TextField(validators=[wtf.required()]) identifier = wtf.TextField() status = wtf.SelectField(choices=INVENTORY_STATUS, coerce=int) comment = wtf.TextAreaField() def __init__(self, formdata=None, obj=None, prefix='', **kwargs): super(InventoryItemForm, self).__init__(request.form, obj, prefix, **kwargs) self.csrf_enabled = False self.group.choices = [(str(grp.id), grp.name) for grp in InventoryGroup.objects] # select the group if request.args.get('id') and not self.is_submitted(): item = InventoryItem.objects(id=request.args.get('id')).get() self.group.data = str(item.group.id) def validate(self, extra_validators=None): success = True # run validation for fields for field in (self.name, self.status): if not field.validate(self.data): success = False self.errors[field.name] = field.errors return success def process(self, formdata=None, obj=None, **kwargs): super(InventoryItemForm, self).process(formdata, obj, **kwargs) if self.is_submitted(): # convert to admin model friendly types self.status.data = int(self.status.data)
class VenueForm(Form): title = wtf.TextField("Name", description="Name of the venue", validators=[wtf.Required()]) description = RichTextField("Notes", description="Notes about the venue", content_css="/static/css/editor.css") address1 = wtf.TextField("Address (line 1)", validators=[wtf.Required()]) address2 = wtf.TextField("Address (line 2)", validators=[wtf.Optional()]) city = wtf.TextField("City", validators=[wtf.Required()]) state = wtf.TextField("State", validators=[wtf.Optional()]) postcode = wtf.TextField("Post code", validators=[wtf.Optional()]) country = wtf.SelectField("Country", validators=[wtf.Required()], choices=country_codes, default="IN") latitude = wtf.DecimalField( "Latitude", places=None, validators=[wtf.Optional(), wtf.NumberRange(-90, 90)]) longitude = wtf.DecimalField( "Longitude", places=None, validators=[wtf.Optional(), wtf.NumberRange(-180, 180)]) profile_id = wtf.SelectField("Owner", description="The owner of this listing", coerce=int, validators=[wtf.Required()])
class ConfigUpdateForm(wtf.Form): analytics_id = wtf.StringField('Analytics ID', filters=[util.strip_filter]) announcement_html = wtf.TextAreaField('Announcement HTML', filters=[util.strip_filter]) announcement_type = wtf.SelectField( 'Announcement Type', choices=[(t, t.title()) for t in model.Config.announcement_type._choices]) brand_name = wtf.StringField('Brand Name', [wtf.validators.required()], filters=[util.strip_filter]) facebook_app_id = wtf.StringField('Facebook App ID', filters=[util.strip_filter]) facebook_app_secret = wtf.StringField('Facebook App Secret', filters=[util.strip_filter]) feedback_email = wtf.StringField( 'Feedback Email', [wtf.validators.optional(), wtf.validators.email()], filters=[util.email_filter]) flask_secret_key = wtf.StringField('Flask Secret Key', [wtf.validators.required()], filters=[util.strip_filter]) twitter_consumer_key = wtf.StringField('Twitter Consumer Key', filters=[util.strip_filter]) twitter_consumer_secret = wtf.StringField('Twitter Consumer Secret', filters=[util.strip_filter])
class NewTodoForm(wtf.Form): title = wtf.TextField("Title", description="Name of the task", validators=[wtf.validators.Required()]) status = wtf.SelectField("Task status", description="Current status of this task", coerce=int, choices=STATUS_CHOICES)
class SubscribeForm(BaseContactsForm): """ Subscribe form. """ phone = wtf.TextField(_('Phone'), validators=[Required()]) skype = wtf.TextField(_('Skype'), validators=[Required()]) flow = wtf.SelectField(_('Flow'), choices=FLOW_CHOICES, validators=[Required()]) comments = wtf.TextField(_('Additional comments'), widget=wtf.TextArea()) template = 'mails/subscribe.txt' title = _('Flow subscription')
class FolderForm(Form): name = wtf.TextField( u"URL name", validators=[wtf.Optional(), valid_name], description=u"Folder name as it appears in the URL (without slashes)") title = wtf.TextField( u"Title", description=u"Folder title, used in the per-folder blog feed") theme = wtf.SelectField(u"Theme") def validate_name(self, field): # TODO pass
class EventForm(ContentForm): start_datetime = DateTimeField(u"Start date/time", validators=[wtf.Required()]) end_datetime = DateTimeField(u"End date/time", validators=[wtf.Required()]) timezone = wtf.SelectField(u"Timezone", choices=timezone_list, validators=[wtf.Required()]) location_name = wtf.TextField(u"Location name", validators=[wtf.Required()]) location_address = wtf.TextField(u"Address", validators=[wtf.Required()]) map = wtf.QuerySelectField(u"Map", get_label='title', allow_blank=True) mapmarker = wtf.TextField(u"Map marker") capacity = wtf.IntegerField(u"Capacity", validators=[wtf.Required()]) allow_waitlisting = wtf.BooleanField(u"Allow wait-listing if over capacity", default=False) allow_maybe = wtf.BooleanField(u"Allow “Maybe” responses", default=True) participant_list = wtf.QuerySelectField(u"Participant list", get_label='title', allow_blank=True) properties = DictField(u"Properties")
class ProposalSpaceForm(wtf.Form): name = wtf.TextField('URL name', validators=[wtf.Required()]) title = wtf.TextField('Title', validators=[wtf.Required()]) datelocation = wtf.TextField('Date and Location', validators=[wtf.Required()]) date = wtf.DateField('Date (for sorting)', validators=[wtf.Required()]) tagline = wtf.TextField('Tagline', validators=[wtf.Required()]) description = wtf.TextAreaField('Description', validators=[wtf.Required()]) status = wtf.SelectField('Status', coerce=int, choices=[ (0, 'Draft'), (1, 'Open'), (2, 'Voting'), (3, 'Jury selection'), (4, 'Feedback'), (5, 'Closed'), (6, 'Rejected'), ])
class ProfileUpdateForm(i18n.Form): name = wtf.StringField( _('Name'), [wtf.validators.required()], filters=[util.strip_filter], ) email = wtf.StringField( _('Email'), [wtf.validators.optional(), wtf.validators.email()], filters=[util.email_filter], ) locale = wtf.SelectField( _('Language'), choices=config.LOCALE_SORTED, filters=[util.strip_filter], )
class NewPaste(wtf.Form): text = wtf.TextField('uid') # honeypot field paste = wtf.TextAreaField('text', validators=[wtf.Required()]) title = wtf.TextField('title', validators=[wtf.Optional()]) password = wtf.PasswordField('password', validators=[wtf.Optional()]) unlisted = wtf.BooleanField('Unlisted') submit = wtf.SubmitField('Paste') language = wtf.SelectField( 'language', choices=[ ('', ''), ('text', 'Text'), ('c', 'C'), ('csharp', 'C#'), ('cpp', 'C++'), ('css', 'CSS'), ('erlang', 'Erlang'), ('go', 'GO'), ('html', 'HTML'), ('java', 'Java'), ('javascript', 'Javascript'), ('json', 'JSON'), ('objectivec', 'Objective-C'), ('perl', 'Perl'), ('python', 'Python (2.X)'), ('python3', 'Python (3.X)'), ('pycon', 'Python Console'), ('pytb', 'Python 2 Traceback'), ('py3tb', 'Python 3 Traceback'), ('ruby', 'Ruby'), ('sql', 'SQL'), ('vbnet', 'VB.NET'), ] ) def validate_uid(form, field): """ This ensures the hidden honeypot field is left blank, only automated spambots should attempt to fill it in """ if field.data != '': raise wtf.validators.ValidationError()
class SettingsForm(Form): """Simple settings form.""" name = wtf.TextField('Name', validators=[ wtf.Required(), wtf.Length(max=100), ], description='e.g. Johnny') email = wtf.TextField('E-mail', validators=[ wtf.Required(), wtf.Email(), wtf.Length(max=100), ]) timezone = wtf.SelectField('My timezone is', choices=tz_choices(), validators=[ wtf.Required(), ])
class ParticipantListForm(ContentForm): source = wtf.SelectField( u"Data Source", choices=[('', ''), ('doattend', 'DoAttend')], description=u"Source from which the participant list will be retrieved." ) sourceid = wtf.TextField( u"Event id", description=u"Id of this event at the selected data source.") api_key = wtf.TextField( u"API Key", description=u"API key to retrieve data from the selected data source.") participant_template = wtf.TextField( "Participant template", validators=[wtf.Required()], default='participant.html', description= u"Template with which a participant’s directory entry will be rendered." ) properties = DictField(u"Properties")
class WebsiteForm(Form): title = wtf.TextField(u"Title", validators=[wtf.Required()]) name = wtf.TextField(u"URL name", validators=[wtf.Required(), valid_name]) url = wtf.html5.URLField(u"Website URL", validators=[wtf.Required()]) hostnames = HostnamesField( u"Hostnames", validators=[wtf.Required()], description= u"Hostnames at which this website will be accessed, comma separated") theme = wtf.SelectField(u"Website theme", validators=[wtf.Required()]) typekit_code = wtf.TextField(u"Typekit code") googleanalytics_code = wtf.TextField(u"Google Analytics code") def validate_name(self, field): # TODO: Ensure name is unique pass def validate_hostnames(self, field): # TODO: Validate that names match hostname:port pass
class UserUpdateForm(i18n.Form): username = wtf.StringField( _('Username'), [wtf.validators.required(), wtf.validators.length(min=3)], filters=[util.email_filter], ) name = wtf.StringField( _('Name'), [wtf.validators.required()], filters=[util.strip_filter], ) email = wtf.StringField( _('Email'), [wtf.validators.optional(), wtf.validators.email()], filters=[util.email_filter], ) locale = wtf.SelectField( _('Language'), choices=config.LOCALE_SORTED, filters=[util.strip_filter], ) admin = wtf.BooleanField(_('Admin')) active = wtf.BooleanField(_('Active')) permissions = wtf.SelectMultipleField( _('Permissions'), filters=[util.sort_filter], ) _permission_choices = set() def __init__(self, *args, **kwds): super(UserUpdateForm, self).__init__(*args, **kwds) self.permissions.choices = [ (p, p) for p in sorted(UserUpdateForm._permission_choices) ] @auth.permission_registered.connect def _permission_registered_callback(sender, permission): UserUpdateForm._permission_choices.add(permission)
class ExpenseReportForm(Form): """ Create or edit an expense report. """ title = wtf.TextField(u"Title", validators=[wtf.Required()], description=u"What are these expenses for?") budget = wtf.QuerySelectField( u"Budget", validators=[wtf.Optional()], query_factory=sorted_budgets, get_label='title', allow_blank=True, description=u"The budget source for these expenses") currency = wtf.SelectField( u"Currency", validators=[wtf.Required()], description=u"Currency for expenses in this report", choices=CURRENCIES) description = RichTextField(u"Description", validators=[wtf.Optional()], description=u"Notes on the expenses")
class ProfileForm(Form): fullname = wtf.TextField('Full name', validators=[wtf.Required()]) email = wtf.html5.EmailField('Email address', validators=[wtf.Required(), wtf.Email()]) username = wtf.TextField('Username', validators=[wtf.Required()]) description = wtf.TextAreaField('Bio') timezone = wtf.SelectField('Timezone', validators=[wtf.Required()], choices=timezones) def __init__(self, *args, **kwargs): super(ProfileForm, self).__init__(*args, **kwargs) self.existing_email = None def validate_username(self, field): ## Usernames are now mandatory. This should be commented out: # if not field.data: # field.data = None # return if not valid_username(field.data): raise wtf.ValidationError("Invalid characters in username") if field.data in RESERVED_USERNAMES: raise wtf.ValidationError("That name is reserved") existing = User.query.filter_by(username=field.data).first() if existing is not None and existing.id != self.edit_id: raise wtf.ValidationError("That username is taken") existing = Organization.query.filter_by(name=field.data).first() if existing is not None: raise wtf.ValidationError("That username is taken") def validate_email(self, field): existing = UserEmail.query.filter_by(email=field.data).first() if existing is not None and existing.user != self.edit_obj: raise wtf.ValidationError( "This email address has been claimed by another user.")
class HookDetailsForm(wtf.Form): service_id = wtf.SelectField('Service', validators=[wtf.Required()], coerce=int)
class ProfileForm(Form): type = wtf.SelectField(u"Profile type", coerce=int, validators=[wtf.Required()]) description = RichTextField(u"Description/Bio", content_css="/static/css/editor.css")
class EventForm(Form): title = wtf.TextField("Title", description="Name of the Event", validators=[ wtf.Required(), wtf.NoneOf(values=["new"]), wtf.validators.length(max=250) ]) name = wtf.TextField( "URL name", validators=[ wtf.Optional(), ValidName(), AvailableName(u"There’s another event with the same name", scoped=True), wtf.validators.length(max=250) ], description="URL identifier, leave blank to autogenerate") blurb = wtf.TextField( "Blurb", description="Single line blurb introducing the event", validators=[wtf.validators.length(max=250)]) description = RichTextField( "Description", description="Detailed description of the event", content_css="/static/css/editor.css") apply_instructions = RichTextField( "Instructions for participants", description= "This will be shown to participants on the hacknight joining form", content_css="/static/css/editor.css") venue = wtf.QuerySelectField( "Venue", description=Markup( 'Venue for this event (<a href="/venue/new">make new</a>)'), query_factory=lambda: Venue.query, get_label='title', ) start_datetime = DateTimeField( "Start date/time", description="The date and time at which this event begins", validators=[wtf.Required()]) end_datetime = DateTimeField( "End date/time", description="The date and time at which this event ends", validators=[wtf.Required()]) ticket_price = wtf.TextField( "Ticket price", description="Entry fee, if any, to be paid at the venue", validators=[wtf.validators.length(max=250)]) total_participants = wtf.IntegerField( "Venue capacity", description= "The number of people this venue can accommodate. Registrations will be closed after that. Use 0 to indicate unlimited capacity", default=50, validators=[wtf.Required()]) website = wtf.html5.URLField( "Website", description="Related Website (Optional)", validators=[wtf.Optional(), wtf.validators.length(max=250), wtf.URL()]) status = wtf.SelectField("Event status", description="Current status of this hacknight", coerce=int, choices=STATUS_CHOICES) def validate_end_datetime(self, field): if field.data < self.start_datetime.data: raise wtf.ValidationError( u"Your event can’t end before it starts.")
class ChannelForm(Form): type = wtf.SelectField(u"Channel type", coerce=int, validators=[wtf.Required()]) description = RichTextField(u"Description")
class TweetForm(wtf.Form): name = wtf.TextField('Name') user_id = wtf.SelectField('User', widget=Select2Widget()) text = wtf.TextField('Text')
class PlaylistAddForm(Form): playlist = wtf.SelectField('Add to playlist', coerce=int)