class CampaignForm(forms.Form): title = forms.StringField( __("Title"), description=__("A reference name for looking up this campaign again"), validators=[ forms.validators.DataRequired(__("A title is required")), forms.validators.StripWhitespace() ]) start_at = forms.DateTimeField(__("Start at"), timezone=lambda: g.user.timezone if g.user else None) end_at = forms.DateTimeField(__("End at"), timezone=lambda: g.user.timezone if g.user else None) public = forms.BooleanField(__("This campaign is live")) position = forms.RadioField(__("Display position"), choices=CAMPAIGN_POSITION.items(), coerce=int) priority = forms.IntegerField( __("Priority"), default=0, description=__( "A larger number is higher priority when multiple campaigns are running on the " "same dates. 0 implies lowest priority")) boards = QuerySelectMultipleField( __("Boards"), widget=ListWidget(), option_widget=CheckboxInput(), query_factory=lambda: Board.query.order_by('title'), get_label='title', validators=[forms.validators.Optional()], description=__(u"Select the boards this campaign is active on")) geonameids = forms.GeonameSelectMultiField( "Locations", description=__( "This campaign will be targetted at users and jobs with matching locations" )) user_required = forms.RadioField(__("User is required"), coerce=getbool, choices=[(None, __("N/A")), (True, __("Yes")), (False, __("No"))]) flags = forms.RadioMatrixField( "Flags", coerce=getbool, fields=Campaign.flag_choices, description=__( "All selected flags must match the logged in user for the campaign to be shown" ), choices=[('None', __("N/A")), ('True', __("True")), ('False', __("False"))]) content = forms.FormField(CampaignContentForm, __("Campaign content")) def validate_geonameids(self, field): field.data = [int(x) for x in field.data if x.isdigit()] def validate_end_at(self, field): if field.data <= self.start_at.data: raise forms.ValidationError( __(u"The campaign can’t end before it starts"))
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 CampaignForm(forms.Form): title = forms.StringField( __("Title"), description=__("A reference name for looking up this campaign again"), validators=[forms.validators.DataRequired(__("A title is required"))], filters=[forms.filters.strip()], ) start_at = forms.DateTimeField(__("Start at"), naive=False) end_at = forms.DateTimeField( __("End at"), validators=[ forms.validators.GreaterThan( 'start_at', __("The campaign can’t end before it starts") ) ], naive=False, ) public = forms.BooleanField(__("This campaign is live")) position = forms.RadioField( __("Display position"), choices=list(CAMPAIGN_POSITION.items()), coerce=int ) priority = forms.IntegerField( __("Priority"), default=0, description=__( "A larger number is higher priority when multiple campaigns are running on the " "same dates. 0 implies lowest priority" ), ) boards = QuerySelectMultipleField( __("Boards"), widget=ListWidget(), option_widget=CheckboxInput(), query_factory=lambda: Board.query.order_by(Board.featured.desc(), Board.title), get_label='title_and_name', validators=[forms.validators.Optional()], description=__("Select the boards this campaign is active on"), ) geonameids = forms.GeonameSelectMultiField( "Locations", description=__( "This campaign will be targetted at users and jobs with matching locations" ), ) user_required = forms.RadioField( __("User is required"), coerce=getbool, choices=[ (None, __("N/A – Don’t target by login status")), (True, __("Yes – Show to logged in users only")), (False, __("No – Show to anonymous users only")), ], ) flags = forms.RadioMatrixField( "Flags", coerce=getbool, fields=Campaign.flag_choices, description=__( "All selected flags must match the logged in user for the campaign to be shown" ), choices=[('None', __("N/A")), ('True', __("True")), ('False', __("False"))], ) content = forms.FormField(CampaignContentForm, __("Campaign content")) def validate_geonameids(self, field): field.data = [int(x) for x in field.data if x.isdigit()]
class ProposalForm(forms.Form): speaking = forms.RadioField( __("Are you speaking?"), coerce=int, choices=[ (1, __("I will be speaking")), (0, __("I’m proposing a topic for someone to speak on")), ], ) title = forms.StringField( __("Title"), validators=[forms.validators.DataRequired()], filters=[forms.filters.strip()], description=__("The title of your session"), ) abstract = forms.MarkdownField( __("Abstract"), validators=[forms.validators.DataRequired()], description=__( "A brief description of your session with target audience and key takeaways" ), ) outline = forms.MarkdownField( __("Outline"), validators=[forms.validators.DataRequired()], description=__( "A detailed description of the session with the sequence of ideas to be presented" ), ) requirements = forms.MarkdownField( __("Requirements"), description=__( "For workshops, what must participants bring to the session?"), ) slides = forms.URLField( __("Slides"), validators=[ forms.validators.Optional(), forms.validators.URL(), forms.validators.ValidUrl(), ], description=__( "Link to your slides. These can be just an outline initially. " "If you provide a Slideshare/Speakerdeck link, we'll embed slides in the page" ), ) video_url = forms.URLField( __("Preview Video"), validators=[ forms.validators.Optional(), forms.validators.URL(), forms.validators.ValidUrl(), ], description=__( "Link to your preview video. Use a video to engage the community and give them a better " "idea about what you are planning to cover in your session and why they should attend. " "If you provide a YouTube/Vimeo link, we'll embed it in the page"), ) links = forms.TextAreaField( __("Links"), description=__( "Other links, one per line. Provide links to your profile and " "slides and videos from your previous sessions; anything that'll help " "folks decide if they want to attend your session"), ) bio = forms.MarkdownField( __("Speaker bio"), validators=[forms.validators.DataRequired()], description=__( "Tell us why you are the best person to be taking this session"), ) email = forms.EmailField( __("Your email address"), validators=[ forms.validators.DataRequired(), EmailAddressAvailable(purpose='use'), ], description=__( "An email address we can contact you at. Not displayed anywhere"), ) phone = forms.StringField( __("Phone number"), validators=[ forms.validators.DataRequired(), forms.validators.Length(max=80) ], description=__( "A phone number we can call you at to discuss your proposal, if required. " "Will not be displayed"), ) location = forms.StringField( __("Your location"), validators=[ forms.validators.DataRequired(), forms.validators.Length(max=80) ], description=__( "Your location, to help plan for your travel if required"), ) formlabels = forms.FormField(forms.Form, __("Labels")) def set_queries(self): label_form = proposal_label_form(project=self.edit_parent, proposal=self.edit_obj) if label_form is not None: self.formlabels.form = label_form else: del self.formlabels
class ProposalLabelsAdminForm(forms.Form): formlabels = forms.FormField(forms.Form, __("Labels")) def set_queries(self): self.formlabels.form = proposal_label_admin_form( project=self.edit_parent, proposal=self.edit_obj)