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 ItemForm(forms.Form): title = forms.StringField(__("Item title"), validators=[forms.validators.DataRequired(__("Please specify a title")), forms.validators.Length(max=250)], filters=[forms.filters.strip()]) description = forms.TextAreaField(__("Description"), filters=[format_description], validators=[forms.validators.DataRequired(__("Please specify a description"))]) restricted_entry = forms.BooleanField(__("Restrict entry?")) seq = forms.IntegerField(__("Sequence"), description=__("The sequence of the ticket on the listing"), validators=[forms.validators.DataRequired(__("Please specify the sequence order"))]) category = QuerySelectField(__("Category"), get_label='title', validators=[forms.validators.DataRequired(__("Please select a category"))]) quantity_total = forms.IntegerField(__("Quantity available"), validators=[forms.validators.DataRequired(__("Please specify the quantity available for sale"))]) assignee_details = forms.TextAreaField(__("Assignee details"), filters=[format_json], validators=[validate_json], default=ASSIGNEE_DETAILS_PLACEHOLDER) event_date = forms.DateField(__("Event date"), description=__("The date on which this item will be invoiced"), validators=[forms.validators.DataRequired(__("Please specify a date for the event"))]) transferable_until = forms.DateTimeField(__("Transferable until"), validators=[forms.validators.Optional()], naive=False) cancellable_until = forms.DateTimeField(__("Cancellable until"), validators=[forms.validators.Optional()], naive=False) place_supply_state_code = forms.SelectField(__("State"), description=__("State of supply"), coerce=int, default=indian_states_dict['KA']['short_code'], validators=[forms.validators.DataRequired(__("Please select a state"))]) place_supply_country_code = forms.SelectField(__("Country"), description=__("Country of supply"), default='IN', validators=[forms.validators.DataRequired(__("Please select a country"))]) def set_queries(self): self.place_supply_state_code.choices = [(0, '')] + [(state['short_code'], state['name']) for state in sorted(indian_states, key=lambda k: k['name'])] self.place_supply_country_code.choices = [('', '')] + localized_country_list() self.category.query = Category.query.join(ItemCollection).filter( Category.item_collection == self.edit_parent).options(db.load_only('id', 'title')) def validate_place_supply_state_code(self, field): if field.data <= 0: # state short codes start from 1, # and 0 means empty value as mentioned above in set_queries raise forms.ValidationError(__("Please select a state")) def validate_transferable_until(self, field): if field.data and field.data.date() > self.event_date.data: raise forms.ValidationError(__("Ticket transfer deadline cannot be after event date"))