class ProposalSpaceForm(Form): name = wtforms.TextField(__("URL name"), validators=[ wtforms.validators.Required(), ValidName(), AvailableName() ]) title = wtforms.TextField(__("Title"), validators=[wtforms.validators.Required()]) datelocation = wtforms.TextField( __("Date and Location"), validators=[wtforms.validators.Required()]) date = wtforms.DateField( __("Start date (for sorting)"), validators=[ wtforms.validators.Required( __("Enter a valid date in YYYY-MM-DD format")) ], description=__("In YYYY-MM-DD format")) date_upto = wtforms.DateField( __("End date (for sorting)"), validators=[ wtforms.validators.Required( __("Enter a valid date in YYYY-MM-DD format")) ], description=__("In YYYY-MM-DD format")) tagline = wtforms.TextField( __("Tagline"), validators=[wtforms.validators.Required()], description=__("This is displayed on the card on the homepage")) description = MarkdownField(__("Description"), validators=[wtforms.validators.Required()], description=__("About Event")) content = wtforms.fields.FormField(Content) timezone = wtforms.SelectField( __("Timezone"), description=__("The timezone in which this event occurs"), validators=[wtforms.validators.Required()], choices=sorted_timezones(), default=u'UTC') status = wtforms.SelectField( __("Status"), coerce=int, choices=[ (0, __("Draft")), (1, __("Open")), (2, __("Voting")), (3, __("Jury selection")), (4, __("Feedback")), (5, __("Closed")), (6, __("Withdrawn")), ], description=__(u"Proposals can only be submitted in the “Open” state. " u"“Closed” and “Withdrawn” are hidden from homepage")) def validate_date_upto(self, date_upto): if self.date_upto.data < self.date.data: raise wtforms.ValidationError( _("End date cannot be before Start date"))
class SectionForm(Form): name = wtforms.TextField(__("URL name"), validators=[ wtforms.validators.Required(), ValidName(), AvailableName(scoped=True) ]) title = wtforms.TextField(__("Title"), validators=[wtforms.validators.Required()]) description = wtforms.TextAreaField( __("Description"), validators=[wtforms.validators.Required()]) public = wtforms.BooleanField(__("Public?"), default=True)
class UserGroupForm(forms.Form): name = forms.StringField(__("URL name"), validators=[ forms.validators.DataRequired(), forms.validators.ValidName(), AvailableName() ]) title = forms.StringField(__("Title"), validators=[forms.validators.DataRequired()]) users = forms.TextAreaField( __("Users"), validators=[forms.validators.DataRequired()], description=__("Usernames or email addresses, one per line"))
class UserGroupForm(Form): name = wtforms.TextField(__("URL name"), validators=[ wtforms.validators.Required(), ValidName(), AvailableName(scoped=True) ]) title = wtforms.TextField(__("Title"), validators=[wtforms.validators.Required()]) users = wtforms.TextAreaField( __("Users"), validators=[wtforms.validators.Required()], description=__("Usernames or email addresses, one per line"))
class BoardForm(forms.Form): """ Edit board settings. """ title = forms.StringField(__("Title"), validators=[ forms.validators.DataRequired(__("The board needs a name")), forms.validators.Length(min=1, max=80, message=__("%%(max)d characters maximum"))], filters=[forms.filters.strip()]) caption = forms.StringField(__("Caption"), description=__("The title and caption appear at the top of the page. Keep them concise"), validators=[ forms.validators.Optional(), forms.validators.Length(min=0, max=80, message=__("%%(max)d characters maximum"))], filters=[forms.filters.strip(), forms.filters.none_if_empty()]) name = forms.AnnotatedTextField(__("URL Name"), prefix='https://', suffix=u'.hasjob.co', description=__(u"Optional — Will be autogenerated if blank"), validators=[ forms.validators.ValidName(), forms.validators.Length(min=0, max=63, message=__("%%(max)d characters maximum")), AvailableName(__(u"This name has been taken by another board"), model=Board)]) description = forms.TinyMce4Field(__(u"Description"), description=__(u"The description appears at the top of the board, above all jobs. " u"Use it to introduce your board and keep it brief"), content_css=content_css, validators=[forms.validators.DataRequired(__("A description of the job board is required")), forms.validators.AllUrlsValid()]) userid = forms.SelectField(__(u"Owner"), validators=[forms.validators.DataRequired(__("Select an owner"))], description=__(u"Select the user, organization or team who owns this board. " "Owners can add jobs to the board and edit these settings")) require_login = forms.BooleanField(__(u"Prompt users to login"), default=True, description=__(u"If checked, users must login to see all jobs available. " u"Logging in provides users better filtering for jobs that may be of interest to them, " u"and allows employers to understand how well their post is performing")) options = forms.FormField(BoardOptionsForm, __(u"Direct posting options")) autotag = forms.FormField(BoardTaggingForm, __(u"Automatic posting options")) def validate_name(self, field): if field.data: if field.data in Board.reserved_names: raise forms.ValidationError(_(u"This name is reserved. Please use another name"))
class ProposalSpaceForm(Form): name = wtforms.TextField(__("URL name"), validators=[ wtforms.validators.Required(), ValidName(), AvailableName() ]) title = wtforms.TextField(__("Title"), validators=[wtforms.validators.Required()]) datelocation = wtforms.TextField( __("Date and Location"), validators=[wtforms.validators.Required()]) date = wtforms.DateField( __("Date (for sorting)"), validators=[ wtforms.validators.Required( __("Enter a valid date in YYYY-MM-DD format")) ], description=__("In YYYY-MM-DD format")) tagline = wtforms.TextField( __("Tagline"), validators=[wtforms.validators.Required()], description=__("This is displayed on the card on the homepage")) description = MarkdownField( __("Description"), validators=[wtforms.validators.Required()], description=__("Instructions for proposers, with Markdown formatting")) status = wtforms.SelectField( __("Status"), coerce=int, choices=[ (0, __("Draft")), (1, __("Open")), (2, __("Voting")), (3, __("Jury selection")), (4, __("Feedback")), (5, __("Closed")), (6, __("Withdrawn")), ], description=__(u"Proposals can only be submitted in the “Open” state. " u"“Closed” and “Withdrawn” are hidden from homepage"))
class ProjectNameForm(forms.Form): name = forms.AnnotatedTextField( __("Custom URL"), description=__( "Customize the URL of your project. " "Use lowercase letters, numbers and dashes only. " "Including a date is recommended" ), validators=[ forms.validators.DataRequired(), forms.validators.Length(max=Project.__name_length__), forms.validators.ValidName( __( "This URL contains unsupported characters. It can contain " "lowercase letters, numbers and hyphens only." ) ), AvailableName(), ], prefix="https://hasgeek.com/<profile>/", widget_attrs={'autocorrect': 'none', 'autocapitalize': 'none'}, )
class ProposalSpaceForm(forms.Form): name = forms.StringField(__("URL name"), validators=[ forms.validators.DataRequired(), forms.ValidName(), AvailableName() ]) title = forms.StringField(__("Title"), validators=[forms.validators.DataRequired()]) datelocation = forms.StringField(__("Date and Location"), validators=[ forms.validators.DataRequired(), forms.validators.Length(max=50) ]) date = forms.DateField( __("Start date (for sorting)"), validators=[forms.validators.DataRequired(__("This is required"))]) date_upto = forms.DateField( __("End date (for sorting)"), validators=[forms.validators.DataRequired(__("This is required"))]) tagline = forms.StringField( __("Tagline"), validators=[forms.validators.DataRequired()], description=__("This is displayed on the card on the homepage")) website = forms.URLField(__("Website"), validators=[forms.validators.Optional()]) description = forms.MarkdownField( __("Description"), validators=[forms.validators.DataRequired()], description=__("About Event")) timezone = forms.SelectField( __("Timezone"), description=__("The timezone in which this event occurs"), validators=[forms.validators.DataRequired()], choices=sorted_timezones(), default=u'UTC') bg_image = forms.URLField( __("Background image URL"), description=u"Background image for the mobile app", validators=[forms.validators.Optional()]) bg_color = forms.StringField( __("Background color"), description=__( "RGB color for the event, shown on the mobile app. Enter without the '#'. E.g. CCCCCC." ), validators=[ forms.validators.Optional(), forms.validators.Length(max=6) ], default=u"CCCCCC") explore_url = forms.URLField( __("Explore tab URL"), description=__( u"Page containing the explore tab’s contents, for the mobile app"), validators=[forms.validators.Optional()]) parent_space = QuerySelectField(__(u"Parent space"), get_label='title', allow_blank=True, blank_text=__(u"None")) status = forms.SelectField( __("Status"), coerce=int, choices=[ (0, __("Draft")), (1, __("Open")), (2, __("Voting")), (3, __("Jury selection")), (4, __("Feedback")), (5, __("Closed")), (6, __("Withdrawn")), ], description=__(u"Proposals can only be submitted in the “Open” state. " u"“Closed” and “Withdrawn” are hidden from homepage")) admin_team = QuerySelectField( u"Admin Team", validators=[ forms.validators.DataRequired(__(u"Please select a team")) ], query_factory=profile_teams, get_label='title', allow_blank=False, description=__(u"The administrators of this proposal space")) review_team = QuerySelectField( u"Review Team", validators=[ forms.validators.DataRequired(__(u"Please select a team")) ], query_factory=profile_teams, get_label='title', allow_blank=False, description=__( u"Reviewers can see contact details of proposers, but can’t change settings" )) allow_rsvp = forms.BooleanField( __("Allow site visitors to RSVP (login required)")) buy_tickets_url = forms.URLField(__("URL to buy tickets"), description=__(u"Eg: Explara, Instamojo"), validators=[forms.validators.Optional()]) def validate_date_upto(self, date_upto): if self.date_upto.data < self.date.data: raise forms.ValidationError( _("End date cannot be before start date")) def validate_bg_color(self, field): if not valid_color_re.match(field.data): raise forms.ValidationError("Please enter a valid color code")
class ProposalSpaceForm(Form): name = wtforms.TextField(__("URL name"), validators=[ wtforms.validators.Required(), ValidName(), AvailableName() ]) title = wtforms.TextField(__("Title"), validators=[wtforms.validators.Required()]) datelocation = wtforms.TextField( __("Date and Location"), validators=[wtforms.validators.Required()]) date = wtforms.DateField( __("Start date (for sorting)"), validators=[ wtforms.validators.Required( __("Enter a valid date in YYYY-MM-DD format")) ], description=__("In YYYY-MM-DD format")) date_upto = wtforms.DateField( __("End date (for sorting)"), validators=[ wtforms.validators.Required( __("Enter a valid date in YYYY-MM-DD format")) ], description=__("In YYYY-MM-DD format")) tagline = wtforms.TextField( __("Tagline"), validators=[wtforms.validators.Required()], description=__("This is displayed on the card on the homepage")) website = wtforms.fields.html5.URLField( __("Website"), validators=[wtforms.validators.Optional()]) description = MarkdownField(__("Description"), validators=[wtforms.validators.Required()], description=__("About Event")) timezone = wtforms.SelectField( __("Timezone"), description=__("The timezone in which this event occurs"), validators=[wtforms.validators.Required()], choices=sorted_timezones(), default=u'UTC') bg_image = wtforms.fields.html5.URLField( __("Background image URL"), description=u"Background image for the mobile app", validators=[wtforms.validators.Optional()]) bg_color = wtforms.TextField( __("Background color"), description=__( "RGB color for the event, shown on the mobile app. Enter without the '#'. E.g. CCCCCC." ), validators=[ wtforms.validators.Optional(), wtforms.validators.length(max=6) ], default=u"CCCCCC") explore_url = wtforms.fields.html5.URLField( __("Explore tab URL"), description=__( u"Page containing the explore tab’s contents, for the mobile app"), validators=[wtforms.validators.Optional()]) status = wtforms.SelectField( __("Status"), coerce=int, choices=[ (0, __("Draft")), (1, __("Open")), (2, __("Voting")), (3, __("Jury selection")), (4, __("Feedback")), (5, __("Closed")), (6, __("Withdrawn")), ], description=__(u"Proposals can only be submitted in the “Open” state. " u"“Closed” and “Withdrawn” are hidden from homepage")) content = wtforms.fields.FormField(Content) def validate_date_upto(self, date_upto): if self.date_upto.data < self.date.data: raise wtforms.ValidationError( _("End date cannot be before Start date")) def validate_bg_color(self, field): if not valid_color_re.match(field.data): raise wtforms.ValidationError("Please enter a valid color code")
class EventForm(Form): title = wtforms.TextField("Title", description="Name of the Event", validators=[ wtforms.validators.Required(), wtforms.validators.NoneOf(values=["new"]), wtforms.validators.length(max=250) ]) name = wtforms.TextField( "URL name", validators=[ wtforms.validators.Optional(), ValidName(), AvailableName(u"There’s another event with the same name", scoped=True), wtforms.validators.length(max=250) ], description="URL identifier, leave blank to autogenerate") blurb = wtforms.TextField( "Blurb", description="Single line blurb introducing the event", validators=[wtforms.validators.length(max=250)]) description = RichTextField( "Description", description="Detailed description of the event", linkify=False, content_css="/static/css/editor.css", tinymce_options={ "valid_elements": "p,br,strong/b,em/i,sup,sub,h3,h4,h5,h6,ul,ol,li,a[!href|title|target|class],blockquote,pre,code,img[!src|alt|class|width|height|align]", "theme_advanced_buttons1": "bold,italic,|,sup,sub,|,bullist,numlist,|,link,unlink,|,blockquote,|,removeformat,code,image", "theme": "advanced" }, sanitize_tags=[ 'p', 'br', 'strong', 'em', 'sup', 'sub', 'h3', 'h4', 'h5', 'h6', 'ul', 'ol', 'li', 'a', 'span', 'blockquote', 'pre', 'code', 'img', 'table', 'thead', 'tbody', 'tfoot', 'tr', 'th', 'td', 'iframe' ], sanitize_attributes={ 'a': ['href', 'title', 'target', 'class'], 'span': ['class'], 'img': ['src', 'alt', 'class', 'width', 'height', 'align'] }, ) 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 = QuerySelectField( "Venue", description=Markup( 'Venue for this event (<a href="/venue/new">make new</a>)'), query_factory=lambda: Venue.query, get_label='title', allow_blank=True, blank_text="Online event", ) start_datetime = DateTimeField( "Start date/time", description="The date and time at which this event begins", validators=[wtforms.validators.Required()]) end_datetime = DateTimeField( "End date/time", description="The date and time at which this event ends", validators=[wtforms.validators.Required()]) ticket_price = wtforms.TextField( "Ticket price", description="Entry fee, if any, to be paid at the venue", validators=[wtforms.validators.length(max=250)]) maximum_participants = wtforms.IntegerField( "Venue capacity", description="The number of people this venue can accommodate.", default=50, validators=[wtforms.validators.Required()]) website = wtforms.fields.html5.URLField( "Website", description="Related Website (Optional)", validators=[ wtforms.validators.Optional(), wtforms.validators.length(max=250), wtforms.validators.URL() ]) status = wtforms.SelectField( "Event status", description="Current status of this hacknight", coerce=int, choices=STATUS_CHOICES) sync_service = wtforms.SelectField( "Sync service name", description="Name of the ticket sync service like doattend", choices=SYNC_CHOICES, validators=[ wtforms.validators.Optional(), wtforms.validators.length(max=100) ]) sync_eventsid = wtforms.TextField( "Sync event ID", description= "Sync events id like DoAttend event ID. More than one event ID is allowed separated by ,.", validators=[ wtforms.validators.Optional(), wtforms.validators.length(max=100) ]) sync_credentials = wtforms.TextField( "Sync credentials", description="Sync credentials like API Key for the event", validators=[ wtforms.validators.Optional(), wtforms.validators.length(max=100) ]) def validate_end_datetime(self, field): if field.data < self.start_datetime.data: raise wtforms.ValidationError( u"Your event can’t end before it starts.") def validate_sync_credentials(self, field): # Remove extra space in front and end. # TODO: Find better way to do it, because this code doesn't validate rather sanitizes. field.data = field.data.strip() def validate_sync_eventsid(self, field): if self.sync_service.data == SYNC_SERVICE.DOATTEND: #Event id in doattend is 5 digit integer, in future it may increase or change. event_id_pattern = r"\d{5,}" events_id = field.data.strip().split(',') for event_id in events_id: if not re.match(event_id_pattern, event_id.strip()): raise wtforms.ValidationError( u"Event id {event_id} is invalid".format( event_id=event_id)) if events_id: field.data = ",".join(events_id)
class SectionForm(forms.Form): name = forms.StringField(__("URL name"), validators=[forms.validators.DataRequired(), forms.ValidName(), AvailableName()]) title = forms.StringField(__("Title"), validators=[forms.validators.DataRequired()]) description = forms.TextAreaField(__("Description"), validators=[forms.validators.DataRequired()]) public = forms.BooleanField(__("Public?"), default=True)