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 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(__("Enter a valid date in YYYY-MM-DD format"))]) date_upto = forms.DateField(__("End date (for sorting)"), validators=[forms.validators.DataRequired(__("Enter a valid date in YYYY-MM-DD format"))]) 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 ProjectForm(forms.Form): title = forms.StringField( __("Title"), validators=[forms.validators.DataRequired()], filters=[forms.filters.strip()], ) tagline = forms.StringField( __("Tagline"), validators=[forms.validators.DataRequired(), forms.validators.Length(max=250)], filters=[forms.filters.strip()], description=__("One line description of the project"), ) location = forms.StringField( __("Location"), description=__( '“Online” if this is online-only, else the city or region (without quotes)' ), validators=[ forms.validators.DataRequired( __("If this project is online-only, use “Online”") ), forms.validators.Length( min=3, max=50, message=__("%(max)d characters maximum") ), ], filters=[forms.filters.strip()], ) timezone = forms.SelectField( __("Timezone"), description=__("The timezone in which this event occurs"), validators=[forms.validators.DataRequired()], choices=sorted_timezones(), default='UTC', ) bg_image = forms.URLField( __("Banner image URL"), description=( "From images.hasgeek.com, with 16:9 aspect ratio." " Should be < 100 kB in size" ), validators=[ forms.validators.Optional(), forms.validators.Length(max=2000), image_url_validator(), ], ) description = forms.MarkdownField( __("Project description"), validators=[forms.validators.DataRequired()], description=__("Landing page contents"), ) def validate_location(self, field): if re.search(double_quote_re, field.data) is not None: raise forms.ValidationError( __("Quotes are not necessary in the location name") )
# -*- coding: utf-8 -*- from flask import current_app from coaster.utils import sorted_timezones from baseframe import _, __ import baseframe.forms as forms from lastuser_core.models import Name, User, UserEmail, getuser timezones = sorted_timezones() class PasswordResetRequestForm(forms.Form): username = forms.StringField(__("Username or Email"), validators=[forms.validators.DataRequired()], widget_attrs={'autocorrect': 'none', 'autocapitalize': 'none'}) def validate_username(self, field): user = getuser(field.data) if user is None: raise forms.ValidationError(_("Could not find a user with that id")) self.user = user class PasswordResetForm(forms.Form): username = forms.StringField(__("Username or Email"), validators=[forms.validators.DataRequired()], description=__("Please reconfirm your username or email address"), widget_attrs={'autocorrect': 'none', 'autocapitalize': 'none'}) password = forms.PasswordField(__("New password"), validators=[forms.validators.DataRequired()]) confirm_password = forms.PasswordField(__("Confirm password"), validators=[forms.validators.DataRequired(), forms.validators.EqualTo('password')])
class VenueForm(Form): title = wtforms.TextField("Name", description="Name of the venue", validators=[ wtforms.validators.Required(), wtforms.validators.length(max=250) ]) description = RichTextField("Notes", description="Notes about the venue", content_css="/static/css/editor.css") address1 = wtforms.TextField("Address (line 1)", validators=[ wtforms.validators.Required(), wtforms.validators.length(max=80) ]) address2 = wtforms.TextField("Address (line 2)", validators=[ wtforms.validators.Optional(), wtforms.validators.length(max=80) ]) city = wtforms.TextField("City", validators=[ wtforms.validators.Required(), wtforms.validators.length(max=30) ]) state = wtforms.TextField("State", validators=[ wtforms.validators.Optional(), wtforms.validators.length(max=30) ]) postcode = wtforms.TextField("Post code", validators=[ wtforms.validators.Optional(), wtforms.validators.length(max=20) ]) country = wtforms.SelectField("Country", validators=[ wtforms.validators.Required(), wtforms.validators.length(max=2) ], choices=country_codes, default="IN") timezone = wtforms.SelectField('Timezone', validators=[wtforms.validators.Required()], choices=sorted_timezones()) latitude = wtforms.DecimalField("Latitude", places=None, validators=[ wtforms.validators.Optional(), wtforms.validators.NumberRange( -90, 90) ]) longitude = wtforms.DecimalField("Longitude", places=None, validators=[ wtforms.validators.Optional(), wtforms.validators.NumberRange( -180, 180) ]) profile_id = wtforms.SelectField( "Owner", description="The owner of this listing", coerce=int, validators=[wtforms.validators.Required()])
def test_sorted_timezones(self): self.assertTrue(isinstance(sorted_timezones(), list))
# -*- coding: utf-8 -*- from flask import current_app from coaster.utils import sorted_timezones from baseframe import _, __ import baseframe.forms as forms from lastuser_core.models import Name, User, UserEmail, getuser timezones = sorted_timezones() class PasswordResetRequestForm(forms.Form): username = forms.StringField(__("Username or Email"), validators=[forms.validators.DataRequired()], widget_attrs={ 'autocorrect': 'none', 'autocapitalize': 'none' }) def validate_username(self, field): user = getuser(field.data) if user is None: raise forms.ValidationError( _("Could not find a user with that id")) self.user = user class PasswordResetForm(forms.Form): username = forms.StringField( __("Username or Email"),
def test_sorted_timezones(self): self.assertTrue(isinstance(sorted_timezones(), list))
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")
def test_sorted_timezones(self): assert isinstance(sorted_timezones(), list)