class ConfigRegistrarForm(BaseForm): id = HiddenField() name = StringField(l_('Name'), validators=[InputRequired(), Length(max=128)]) main_host = StringField(l_('Main registrar host'), validators=[InputRequired(), Length(max=128)]) main_port = IntegerField(l_('Main registrar port')) backup_host = StringField(l_('Backup registrar host'), validators=[Length(max=128)]) backup_port = IntegerField(l_('Backup registrar port')) proxy_main_host = StringField( l_('Main proxy host'), validators=[InputRequired(), Length(max=128)]) proxy_main_port = IntegerField(l_('Main proxy port')) proxy_backup_host = StringField(l_('Backup proxy host'), validators=[Length(max=128)]) proxy_backup_port = IntegerField(l_('Backup proxy port')) submit = SubmitField(l_('Submit'))
class EmailEventPersonsForm(IndicoForm): from_address = SelectField(_('From'), [DataRequired()]) subject = StringField(_('Subject'), [DataRequired()]) body = TextAreaField(_('Email body'), [DataRequired()], widget=CKEditorWidget(simple=True)) recipients = IndicoStaticTextField(_('Recipients')) person_id = HiddenFieldList() user_id = HiddenFieldList() submitted = HiddenField() def __init__(self, *args, **kwargs): register_link = kwargs.pop('register_link') super(EmailEventPersonsForm, self).__init__(*args, **kwargs) from_addresses = ['{} <{}>'.format(session.user.full_name, email) for email in sorted(session.user.all_emails, key=lambda x: x != session.user.email)] self.from_address.choices = zip(from_addresses, from_addresses) self.body.description = render_placeholder_info('event-persons-email', event=None, person=None, register_link=register_link) def is_submitted(self): return super(EmailEventPersonsForm, self).is_submitted() and 'submitted' in request.form
class AdvancedSearchForm(Form): """Replacement for the 'classic' advanced search interface.""" # pylint: disable=too-few-public-methods advanced = HiddenField("Advanced", default=1) """Used to indicate whether the form should be shown.""" terms = FieldList(FormField(FieldForm), min_entries=1) classification = FormField(ClassificationForm) date = FormField(DateForm) size = SelectField( "results per page", default=50, choices=[("25", "25"), ("50", "50"), ("100", "100"), ("200", "200")], ) order = SelectField( "Sort results by", choices=[ ("-announced_date_first", "Announcement date (newest first)"), ("announced_date_first", "Announcement date (oldest first)"), ("-submitted_date", "Submission date (newest first)"), ("submitted_date", "Submission date (oldest first)"), ("", "Relevance"), ], validators=[validators.Optional()], default="-announced_date_first", ) include_older_versions = BooleanField("Include older versions of papers") HIDE_ABSTRACTS = "hide" SHOW_ABSTRACTS = "show" abstracts = RadioField( "Abstracts", choices=[ (SHOW_ABSTRACTS, "Show abstracts"), (HIDE_ABSTRACTS, "Hide abstracts"), ], default=SHOW_ABSTRACTS, )
class NoticeNewForm(Form): """ 新建 Notice 的表单 """ title = TextField(_("notices.title"), description=u'标题', validators=[ required(message=_("title is required")), length(min=2, max=50, message=_("Length range: 2 - 50")) ]) content = TextField(_("notices.content"), description=u'内容', validators=[ required(message=_("content is required")), length(min=2, max=400, message=_("Length range: 2 - 400")) ]) deadline = TextField(_("notices.deadline"), description=u'截止时间', validators=[ required(message=_("deadline is required")), ]) notice_status = SelectField(_("notices.notice_status"), description=u'状态:0-未发布、1-发布、2-已删除', choices=[ ('0', _(u"未发布")), ('1', _(u"发布")), ('2', _(u"已删除")), ], validators=[]) next = HiddenField() submit = SubmitField(_("Submit"))
class EnpointSipForm(BaseForm): id = HiddenField() name = StringField(l_('Name'), validators=[InputRequired(), Length(max=40)]) username = StringField(l_('Username'), validators=[InputRequired(), Length(max=40)]) secret = StringField(l_('Password'), validators=[Length(max=80)], widget=PasswordInput(hide_value=False)) type = SelectField(l_('Type'), choices=[('user', l_('User')), ('peer', l_('Peer')), ('friend', l_('Friend'))]) host = SelectField(l_('Host'), validators=[InputRequired(), Length(max=255)], choices=[('dynamic', l_('Dynamic')), ('static', l_('Static'))]) host_value = StringField('', validators=[Length(max=255)]) options = FieldList(FormField(OptionsForm))
class InvitationForm(IndicoForm): from_address = SelectField(_('From'), [DataRequired()]) subject = StringField(_('Subject'), [DataRequired()]) body = TextAreaField(_('Email body'), [DataRequired()], widget=CKEditorWidget(simple=True)) recipients = EmailListField(_('Recipients'), [DataRequired()], description=_('One email address per line.')) copy_for_sender = BooleanField(_('Send copy to me'), widget=SwitchWidget()) submitted = HiddenField() def __init__(self, *args, **kwargs): event = kwargs.pop('event') super().__init__(*args, **kwargs) self.from_address.choices = list(event.get_allowed_sender_emails().items()) self.body.description = render_placeholder_info('survey-link-email', event=None, survey=None) def is_submitted(self): return super().is_submitted() and 'submitted' in request.form def validate_body(self, field): missing = get_missing_placeholders('survey-link-email', field.data, event=None, survey=None) if missing: raise ValidationError(_('Missing placeholders: {}').format(', '.join(missing)))
class EmailEventPersonsForm(fossirForm): from_address = SelectField(_('From'), [DataRequired()]) subject = StringField(_('Subject'), [DataRequired()]) body = TextAreaField(_('Email body'), [DataRequired()], widget=CKEditorWidget(simple=True)) recipients = fossirEmailRecipientsField(_('Recipients')) copy_for_sender = BooleanField(_('Send copy to me'), widget=SwitchWidget(), description=_('Send copy of each email to my mailbox')) person_id = HiddenFieldList() user_id = HiddenFieldList() submitted = HiddenField() def __init__(self, *args, **kwargs): register_link = kwargs.pop('register_link') event = kwargs.pop('event') super(EmailEventPersonsForm, self).__init__(*args, **kwargs) self.from_address.choices = event.get_allowed_sender_emails().items() self.body.description = render_placeholder_info('event-persons-email', event=None, person=None, register_link=register_link) def is_submitted(self): return super(EmailEventPersonsForm, self).is_submitted() and 'submitted' in request.form
class IDForm(FlaskForm): id = HiddenField() def __init__(self, *args, model, pk='id', **kwargs): self.model = model self.pk = pk if 'obj' in kwargs: attr = getattr(kwargs['obj'], pk) if attr is not None: kwargs['pk'] = attr super().__init__(*args, **kwargs) def validate_id(self, field): try: instance = self.model.query.get(int(field.data)) if instance is None: raise ValueError except ValueError: raise ValidationError('No such object.') self.instance = instance
class SplitCategoryForm(IndicoForm): first_category = StringField(_('Category name #1'), [DataRequired()], description=_('Selected events will be moved into a new sub-category with this ' 'title.')) second_category = StringField(_('Category name #2'), [DataRequired()], description=_('Events that were not selected will be moved into a new sub-category ' 'with this title.')) event_id = HiddenFieldList() all_selected = BooleanField(widget=HiddenCheckbox()) submitted = HiddenField() def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) if self.all_selected.data: self.event_id.data = [] self.first_category.label.text = _('Category name') self.first_category.description = _('The events will be moved into a new sub-category with this title.') del self.second_category def is_submitted(self): return super().is_submitted() and 'submitted' in request.form
class MinimalForm(BaseForm): mrpledge_id = HiddenField("MrPledge ID", [validators.Optional()]) stage_name = HiddenField("Stage Name", [validators.Optional()]) close_date = HiddenField("Close Date", [validators.Optional()]) opportunity_id = HiddenField("Opportunity ID", [validators.Optional()]) recurring_id = HiddenField("Recurring Donation ID", [validators.Optional()]) opportunity_type = HiddenField("Opportunity Type", [validators.Optional()]) opportunity_subtype = HiddenField("Opportunity Sub-Type", [validators.Optional()]) redirect_url = HiddenField("Opportunity Type", [validators.Optional()]) display_as = StringField(u"Preferred name", [validators.Optional()]) anonymous = BooleanField(u"Anonymous?", false_values=(False, 'false', 0, '0', None, "None")) additional_donation = StringField( u"Additional Donation Amount", validators=[ validators.Optional(), validate_amount, ], filters=[format_amount], )
class TimetablePDFExportForm(IndicoForm): _pdf_options_fields = {'pagesize', 'fontsize', 'firstPageNumber'} advanced = BooleanField(_("Advanced timetable"), widget=SwitchWidget(), description=_("Advanced customization options")) document_settings = IndicoSelectMultipleCheckboxBooleanField(_('Document settings'), [HiddenUnless('advanced')], choices=_DOCUMENT_SETTINGS_CHOICES) contribution_info = IndicoSelectMultipleCheckboxBooleanField(_('Contributions related info'), [HiddenUnless('advanced')], choices=_CONTRIBUTION_CHOICES) session_info = IndicoSelectMultipleCheckboxBooleanField(_('Sessions related info'), [HiddenUnless('advanced')], choices=_SESSION_CHOICES) visible_entries = IndicoSelectMultipleCheckboxBooleanField(_('Breaks and contributions'), [HiddenUnless('advanced')], choices=_VISIBLE_ENTRIES_CHOICES) other = IndicoSelectMultipleCheckboxBooleanField(_('Miscellaneous'), choices=_OTHER_CHOICES) pagesize = SelectField(_('Page size'), choices=[('A0', 'A0'), ('A1', 'A1'), ('A2', 'A2'), ('A3', 'A3'), ('A4', 'A4'), ('A5', 'A5'), ('Letter', 'Letter')], default='A4') fontsize = SelectField(_('Font size'), choices=[('xxx-small', _('xxx-small')), ('xx-small', _('xx-small')), ('x-small', _('x-small')), ('smaller', _('smaller')), ('small', _('small')), ('normal', _('normal')), ('large', _('large')), ('larger', _('larger'))], default='normal') firstPageNumber = IntegerField(_('Number for the first page'), [NumberRange(min=1)], default=1, widget=NumberInput(step=1)) submitted = HiddenField() def is_submitted(self): return 'submitted' in request.args @property def data_for_format(self): if not self.advanced.data: fields = ('visible_entries',) else: fields = set(get_form_field_names(TimetablePDFExportForm)) - self._pdf_options_fields - {'csrf_token', 'advanced'} data = {} for fieldname in fields: data.update(getattr(self, fieldname).data) return data
class EmailRegistrantsForm(IndicoForm): from_address = SelectField(_("From"), [DataRequired()]) cc_addresses = EmailListField( _("CC"), description=_( "Beware, addresses in this field will receive one mail per " "registrant.")) subject = StringField(_("Subject"), [DataRequired()]) body = TextAreaField(_("Email body"), [DataRequired()], widget=CKEditorWidget(simple=True)) recipients = IndicoEmailRecipientsField(_('Recipients')) copy_for_sender = BooleanField( _('Send copy to me'), widget=SwitchWidget(), description=_('Send copy of each email to my mailbox')) registration_id = HiddenFieldList() submitted = HiddenField() def __init__(self, *args, **kwargs): self.regform = kwargs.pop('regform') event = self.regform.event super(EmailRegistrantsForm, self).__init__(*args, **kwargs) self.from_address.choices = event.get_allowed_sender_emails().items() self.body.description = render_placeholder_info('registration-email', regform=self.regform, registration=None) def validate_body(self, field): missing = get_missing_placeholders('registration-email', field.data, regform=self.regform, registration=None) if missing: raise ValidationError( _('Missing placeholders: {}').format(', '.join(missing))) def is_submitted(self): return super(EmailRegistrantsForm, self).is_submitted() and 'submitted' in request.form
class CourseForm(FlaskForm): crn = StringField("CRN", validators=[InputRequired(), Length(min=5, max=5)]) code = StringField("Code", validators=[InputRequired(), Length(min=3, max=3)]) name = StringField("Course Name", validators=[InputRequired(), Length(max=100)]) start_time = TimeField("Start Time", validators=[InputRequired()]) end_time = TimeField("End Time", validators=[InputRequired()]) def validate_end_time(self, field): if self.start_time.data >= field.data: raise ValidationError( "End time can not be equal or lower than Start Time") day = SelectField("Day", choices=[('Monday', 'Monday'), ('Tuesday', 'Tuesday'), ('Wednesday', 'Wednesday'), ('Thursday', 'Thursday'), ('Friday', 'Friday')]) capacity = IntegerField("Capacity", validators=[InputRequired()], render_kw={'type': 'number'}) enrolled = HiddenField("Enrolled", default=0) credits = DecimalField("Credits", validators=[InputRequired()], places=1) language = StringField("Language", validators=[Length(max=2)]) classroom_id = IntegerField("Classroom ID", validators=[InputRequired()], render_kw={'type': 'number'}) instructor_id = IntegerField("Instructor ID", validators=[InputRequired()], render_kw={'type': 'number'}) department_id = IntegerField("Department ID", validators=[InputRequired()], render_kw={'type': 'number'}) info = TextAreaField("Course Information", validators=[InputRequired()]) syllabus = FileField("Syllabus", render_kw={'accept': '.pdf'})
class SeedSubgraphForm(FlaskForm): """Builds the form for seeding by subgraph""" node_list = HiddenField('Nodes') seed_method = fields.RadioField( 'Expansion Method', choices=[ (SEED_TYPE_INDUCTION, 'Induce a subgraph over the given nodes'), (SEED_TYPE_NEIGHBORS, 'Induce a subgraph over the given nodes and expand to their first neighbors' ), (SEED_TYPE_DOUBLE_NEIGHBORS, 'Induce a subgraph over the given nodes and expand to their second neighbors' ), (SEED_TYPE_PATHS, 'Induce a subgraph over the nodes in all shortest paths between the given nodes' ), (SEED_TYPE_UPSTREAM, 'Generate an upstream candidate mechanism'), (SEED_TYPE_DOWNSTREAM, 'Generate a downstream candidate mechanism'), ], default=SEED_TYPE_INDUCTION) filter_pathologies = BooleanField('Filter pathology nodes', default=False) submit_subgraph = fields.SubmitField('Submit Subgraph')
class ProfileForm(ModelForm): """Form for editing :class:`~pygotham.models.User` instances.""" id = HiddenField() twitter_handle = TwitterField('Twitter', validators=(Unique(User.twitter_handle), Optional())) class Meta: model = User only = ('name', 'email', 'bio') field_args = { 'name': { 'label': 'Name' }, 'email': { 'label': 'Email', 'validators': (Email(), Unique(User.email)), }, 'bio': { 'label': 'Biography' }, }
class CommentForm(FlaskForm): name = StringField('Name', validators=[DataRequired()]) email = EmailField('Email', validators=[DataRequired(), Email()]) url = StringField('URL', validators=[Optional(), URL()]) body = TextAreaField('Comment', validators=[DataRequired(), Length(min=10, max=3000)]) entry_id = HiddenField(validators=[DataRequired()]) def validate(self): if not super().validate(): return False # Ensure that entry_id maps to a public Entry. entry = Entry.query.filter( (Entry.status == Entry.STATUS_PUBLIC) & (Entry.id == self.entry_id.data)).first() if not entry: return False return True
class BadgeSettingsForm(IndicoForm): template = SelectField(_('Template')) save_values = BooleanField( _("Save values for next time"), widget=SwitchWidget(), description=_("Save these values in the event settings")) dashed_border = BooleanField( _("Dashed border around each badge"), widget=SwitchWidget(), description=_("Display a dashed border around each badge")) page_size = IndicoEnumSelectField(_('Page size'), enum=PageSize) page_orientation = IndicoEnumSelectField(_('Page orientation'), enum=PageOrientation) top_margin = FloatField(_('Top margin'), [InputRequired()]) left_margin = FloatField(_('Left margin'), [InputRequired()]) right_margin = FloatField(_('Right margin'), [InputRequired()]) bottom_margin = FloatField(_('Bottom margin'), [InputRequired()]) margin_columns = FloatField(_('Margin between columns'), [InputRequired()]) margin_rows = FloatField(_('Margin between rows'), [InputRequired()]) submitted = HiddenField() def __init__(self, event, **kwargs): all_templates = set( event.designer_templates) | get_inherited_templates(event) badge_templates = [ tpl for tpl in all_templates if tpl.type.name == 'badge' ] super(BadgeSettingsForm, self).__init__(**kwargs) self.template.choices = sorted( ((unicode(tpl.id), tpl.title) for tpl in badge_templates), key=itemgetter(1)) def is_submitted(self): return super(BadgeSettingsForm, self).is_submitted() and 'submitted' in request.form
class AdvancedSearchForm(Form): """Replacement for the 'classic' advanced search interface.""" # pylint: disable=too-few-public-methods advanced = HiddenField('Advanced', default=1) """Used to indicate whether the form should be shown.""" terms = FieldList(FormField(FieldForm), min_entries=1) classification = FormField(ClassificationForm) date = FormField(DateForm) size = SelectField('results per page', default=50, choices=[ ('50', '50'), ('100', '100'), ('200', '200') ]) order = SelectField('Sort results by', choices=[ ('-announced_date_first', 'Announcement date (newest first)'), ('announced_date_first', 'Announcement date (oldest first)'), ('-submitted_date', 'Submission date (newest first)'), ('submitted_date', 'Submission date (oldest first)'), ('', 'Relevance') ], validators=[validators.Optional()], default='-announced_date_first') include_older_versions = BooleanField('Include older versions of papers')
class assignForm(Form): hf = HiddenField() name = TextField(label='name') select = SelectField(label='groups')
class FilterForm(InvenioBaseForm): """Filter forms contains hidden fields to keep sorting.""" sort_by = HiddenField() order = HiddenField()
class UserForm(BaseForm): uuid = HiddenField() firstname = HiddenField() lastname = HiddenField()
class BulkAbstractJudgmentForm(AbstractJudgmentFormBase): _order = ('judgment', 'accepted_track', 'override_contrib_type', 'accepted_contrib_type', 'session', 'duplicate_of', 'merged_into', 'merge_persons', 'judgment_comment', 'send_notifications') judgment = HiddenEnumField(enum=AbstractAction, skip={AbstractAction.change_tracks}) abstract_id = HiddenFieldList() submitted = HiddenField() override_contrib_type = BooleanField( _("Override contribution type"), [HiddenUnless('judgment', AbstractAction.accept)], widget=SwitchWidget(), description=_( "Override the contribution type for all selected abstracts")) def __init__(self, *args, **kwargs): self.event = kwargs.pop('event') super(BulkAbstractJudgmentForm, self).__init__(*args, **kwargs) if self.accepted_track: self.accepted_track.description = _( "The abstracts will be accepted in this track") if self.accepted_contrib_type: self.accepted_contrib_type.description = _( "The abstracts will be converted into a contribution of this " "type") else: del self.override_contrib_type if self.session: self.session.description = _( "The generated contributions will be allocated in this session" ) self.duplicate_of.description = _( "The selected abstracts will be marked as duplicate of the specified " "abstract") self.merged_into.description = _( "The selected abstracts will be merged into the specified abstract" ) self.merge_persons.description = _( "Authors and speakers of the selected abstracts will be added to the " "specified abstract") self.duplicate_of.excluded_abstract_ids = set(kwargs['abstract_id']) self.merged_into.excluded_abstract_ids = set(kwargs['abstract_id']) if kwargs['judgment']: self._remove_unused_fields(kwargs['judgment']) def _remove_unused_fields(self, judgment): for field in list(self): validator = next( (v for v in field.validators if isinstance(v, HiddenUnless) and v.field == 'judgment'), None) if validator is None: continue if not any(v.name == judgment for v in validator.value): delattr(self, field.name) def is_submitted(self): return super(BulkAbstractJudgmentForm, self).is_submitted() and 'submitted' in request.form @classmethod def _add_contrib_type_hidden_unless(cls): # In the bulk form we need to hide/disable the contrib type selector unless we want to # override the type specified in the abstract. However, multiple HiddenUnless validators # are not supported in the client-side JS so we only add it to this form - it removes # inactive fields on the server side so it still works (the JavaScript picks up the last # HiddenUnless validator) inject_validators(BulkAbstractJudgmentForm, 'accepted_contrib_type', [HiddenUnless('override_contrib_type')])
class F(Form): a = HiddenField(default="LE DEFAULT")
class ConnectForm(FlaskForm): connect_condition = HiddenField() to_user_id = HiddenField() submit = SubmitField()
class CreateVoteChoiceForm(FlaskForm): value = RadioField(lazy_gettext("Value"), coerce=int, validators=[Optional()]) amount = DecimalField(lazy_gettext("Amount"), validators=[Optional()], default=0) comment = TextField(lazy_gettext("Comment")) choice_id = HiddenField("choice id", validators=[Required()])
class volumeSliderForm(Form): hf = HiddenField() name = TextField(label='name') slider = IntegerRangeField(label='volume')
class TransportForm(BaseForm): uuid = SelectField(l_('Transport'), choices=[]) name = HiddenField()
class streamSelectForm(Form): hf = HiddenField() name = TextField(label='name') clients = TextField(label='clients') select = SelectField(label='streams')
class TemplateForm(BaseForm): uuid = HiddenField()
class _ContextForm(BaseForm): id = HiddenField() label = HiddenField()