class SignForm(Form): identity_id = HiddenInput("identity_id") signed = TextAreaField(_('Signed enrollment'), validators = [Required(), validate_en])
class SimulationSessionSelectionForm(Form): simulationSessoinId = IntegerField('simulationSessoinId', validators=[DataRequired()], widget=HiddenInput()) gameBackgroundId = IntegerField('gameBackgroundId', validators=[DataRequired()], widget=HiddenInput())
class BlogUpdateForm(BlogCreateForm): id = IntegerField(widget=HiddenInput())
class UpdateProfileForm(FlaskForm): """Class for handling profile update data.""" age = IntegerField('Age', validators=[Optional()]) gender = SelectField( 'Gender', choices=[ ('', 'Select Gender'), ('Female', 'Female'), ('Male', 'Male'), ('Choose Not to Identify', 'Choose Not To Identify') ], default='', validators=[Optional()] ) skill = SelectField( 'Skill', choices=[ ('', 'Select Skill'), ('Beginner', 'Beginner'), ('Intermediate', 'Intermediate'), ('Advanced', 'Adavanced') ], default='', validators=[Optional()] ) handicap = SelectField( 'Handicap', choices=[ ('', 'Select Handicap'), ('0-4', '0-4'), ('5-9', '5-9'), ('10-14', '10-14'), ('15-19', '15-19'), ('20-24', '20-24'), ('25+', '25+'), ("Don't Know", "Don't Know") ], default='', validators=[Optional()] ) plays = SelectField( 'Plays', choices=[ ('', 'Select Play Frequency'), ('Once a year', 'Once a year'), ('Twice a year', 'Twice a year'), ('Once every three months', 'Once every three months'), ('Once a month', 'Once a month'), ('Once a week', 'Once a week'), ('A few times a week', 'A few times a week') ], default='', validators=[Optional()] ) location = StringField('Location', id='location') city = HiddenField('City') county = HiddenField('County') state = HiddenField('State') country = HiddenField('Country') zip_code = HiddenField('Zip') lat = FloatField('Lat', widget=HiddenInput()) lng = FloatField('Lng', widget=HiddenInput())
class LiteratureForm(INSPIREForm): """Literature form fields.""" doi = fields.DOIField( label=_('DOI'), processors=[], export_key='doi', description='e.g. 10.1086/305772 or doi:10.1086/305772', placeholder='', validators=[DOISyntaxValidator("The provided DOI is invalid - it should look similar to '10.1086/305772'."), duplicated_doi_validator], ) arxiv_id = ArXivField( label=_('arXiv ID'), export_key="arxiv_id", validators=[arxiv_syntax_validation, duplicated_arxiv_id_validator], ) categories_arXiv = fields.TextField( widget=HiddenInput(), export_key='categories', ) # isbn = ISBNField( # label=_('ISBN'), # widget_classes='form-control', # ) import_buttons = fields.SubmitField( label=_(' '), widget=import_buttons_widget ) types_of_doc = [("article", _("Article/Conference paper")), ("thesis", _("Thesis"))] # ("chapter", _("Book Chapter")), # ("book", _("Book")), # ("proceedings", _("Proceedings"))] type_of_doc = fields.SelectField( label='Type of Document', choices=types_of_doc, default="article", # widget=radiochoice_buttons, widget_classes='form-control', validators=[validators.DataRequired()], ) title = fields.TitleField( label=_('Title'), widget_classes="form-control", validators=[validators.DataRequired()], export_key='title', ) title_crossref = fields.TitleField( export_key='title_crossref', widget=HiddenInput(), ) title_arXiv = fields.TitleField( export_key='title_arXiv', widget=HiddenInput(), ) title_translation = fields.TitleField( label=_('Translated Title'), description='Original title translated to english language.', widget_classes="form-control", export_key='title_translation', ) authors = fields.DynamicFieldList( fields.FormField( AuthorInlineForm, widget=ExtendedListWidget( item_widget=ItemWidget(), html_tag='div', ), ), label='Authors', add_label='Add another author', min_entries=1, widget_classes='', export_key='authors', validators=[AuthorsValidation], ) collaboration = fields.TextField( label=_('Collaboration'), export_key="collaboration", widget_classes="form-control" + ARTICLE_CLASS ) experiment = fields.TextField( placeholder=_("Start typing for suggestions"), export_key="experiment", label=_('Experiment'), widget_classes="form-control", autocomplete="experiment" ) subject = fields.SelectMultipleField( label=_('Subject'), widget_classes="form-control", export_key='subject_term', filters=[clean_empty_list], validators=[validators.DataRequired()] ) abstract = fields.TextAreaField( label=_('Abstract'), default='', widget_classes="form-control", export_key='abstract', ) languages = [("en", _("English")), ("rus", _("Russian")), ("ger", _("German")), ("fre", _("French")), ("ita", _("Italian")), ("spa", _("Spanish")), ("chi", _("Chinese")), ("por", _("Portuguese")), ("oth", _("Other"))] language = fields.LanguageField( label=_("Language"), export_key="language", choices=languages ) other_language = fields.TextField( label=_("Other Language"), export_key="other_language", widget_classes="form-control", description="What is the language of the publication?" ) conf_name = fields.TextField( placeholder=_("Start typing for suggestions"), label=_('Conference Information'), description=_('Conference name, acronym, place, date'), widget_classes="form-control" + ARTICLE_CLASS, autocomplete='conference' ) conference_id = fields.TextField( export_key='conference_id', widget=HiddenInput(), ) license_url = fields.TextField( label=_('License URL'), export_key='license_url', widget=HiddenInput(), ) report_numbers = fields.DynamicFieldList( fields.FormField( ReportNumberInlineForm, widget=ExtendedListWidget( item_widget=ItemWidget(), html_tag='div', ), ), add_label=_('Add another report number'), min_entries=1, widget_classes='', widget=UnsortedDynamicListWidget(), ) # ============== # Thesis related # ============== supervisors = fields.DynamicFieldList( fields.FormField( AuthorInlineForm, widget=ExtendedListWidget( item_widget=ItemWidget(), html_tag='div', ), ), label=_('Supervisors'), add_label=_('Add another supervisor'), min_entries=1, widget_classes=THESIS_CLASS, ) thesis_date = fields.TextField( label=_('Date of Submission'), description='Format: YYYY-MM-DD, YYYY-MM or YYYY.', validators=[date_validator], widget=defensedate_widget, ) defense_date = fields.TextField( label=_('Date of Defense'), description='Format: YYYY-MM-DD, YYYY-MM or YYYY.', validators=[date_validator], widget=defensedate_widget, ) degree_type = fields.SelectField( label=_('Degree Type'), widget_classes="form-control" + THESIS_CLASS, ) institution = fields.TextField( autocomplete='affiliation', placeholder='Start typing for suggestions', label=_('Institution'), widget_classes="form-control" + THESIS_CLASS, ) # license = fields.SelectField( # label=_('License'), # default='', # widget_classes="form-control" + THESIS_CLASS, # ) # ============ # Journal Info # ============ journal_title = fields.TextField( placeholder=_("Start typing for suggestions"), label=_('Journal Title'), widget_classes="form-control" + ARTICLE_CLASS, autocomplete='journal' ) page_range_article_id = fields.TextField( label=_('Page Range/Article ID'), description=_('e.g. 1-100'), widget_classes="form-control" + ARTICLE_CLASS ) volume = fields.TextField( label=_('Volume'), widget_classes="form-control" + ARTICLE_CLASS ) year = fields.TextField( label=_('Year'), widget_classes="form-control" + ARTICLE_CLASS ) issue = fields.TextField( label=_('Issue'), widget_classes="form-control" + ARTICLE_CLASS ) nonpublic_note = fields.TextAreaField( label=_('Proceedings'), description='Editors, title of proceedings, publisher, year of publication, page range, URL', widget=wrap_nonpublic_note, widget_classes="form-control" + ARTICLE_CLASS ) note = fields.TextAreaField( widget=HiddenInput(), export_key='note', ) # ============ # References # ============ references = fields.TextAreaField( label=_('References'), description='Please paste the references in plain text', widget_classes="form-control" ) # ==================== # Preprint Information # ==================== preprint_created = fields.TextField( widget=HiddenInput(), export_key='preprint_created', ) # ==================== # Fulltext Information # ==================== # file_field = fields.FileUploadField( # label="", # widget=plupload_widget, # widget_classes="form-control" + THESIS_CLASS, # export_key=False # ) # url = fields.DynamicFieldList( # fields.FormField( # UrlInlineForm, # widget=ExtendedListWidget( # item_widget=ItemWidget(), # html_tag='div', # ), # ), # #validators=[validators.URL(), validators.Optional, ], # label=_('If available, please provide us with an accessible URL for the pdf'), # add_label=_('Add another url'), # min_entries=1, # export_key='url', # widget_classes='', # ) url = fields.TextField( label=_('Link to PDF'), description=_('Where can we find a PDF to check the references?'), placeholder='http://www.example.com/document.pdf', validators=[pdf_validator], widget_classes="form-control", ) additional_url = fields.TextField( label=_('Link to additional information (e.g. abstract)'), description=_('Which page should we link from INSPIRE?'), placeholder='http://www.example.com/splash-page.html', # validators=[pdf_validator], widget_classes="form-control", ) # ==================== # Extra comments # ==================== extra_comments = fields.TextAreaField( label=_('Comments'), description='Any extra comments related to your submission', widget_classes="form-control" ) # ok_to_upload = fields.BooleanField( # label="", # default=False, # widget=CheckboxButton(msg=_('I confirm I have read the License Agreement')), # validators=[required_if_files('file_field', # message=_("Please, check this box to upload material.") # ), # ] # ) # # Form Configuration # _title = _("Suggest content") # Group fields in categories groups = [ ('Import information', ['arxiv_id', 'doi', 'import_buttons']), ('Document Type', ['type_of_doc', ]), ('Links', ['url', 'additional_url']), ('Basic Information', ['title', 'title_arXiv', 'categories_arXiv', 'language', 'other_language', 'title_translation', 'subject', 'authors', 'collaboration', 'experiment', 'abstract', 'report_numbers']), ('Thesis Information', ['supervisors', 'thesis_date', 'defense_date', 'degree_type', 'institution', 'license_url']), # ('Licenses and copyright', # ['license', 'license_url'], {'classes': 'collapse'}), ('Journal Information', ['journal_title', 'volume', 'issue', 'year', 'page_range_article_id']), ('Conference Information', ['conf_name', 'conference_id'], {'classes': 'collapse'}), ('Proceedings Information (if not published in a journal)', ['nonpublic_note'], {'classes': 'collapse'}), ('References', ['references'], {'classes': 'collapse'}), # ('Upload files', # ['file_field', 'ok_to_upload']), ('Additional comments', ['extra_comments'], {'classes': 'collapse'}), ] field_sizes = { 'type_of_doc': 'col-xs-12 col-md-3', 'wrap_nonpublic_note': 'col-md-9', 'defense_date': 'col-xs-12 col-md-4', 'thesis_date': 'col-xs-12 col-md-4', 'degree_type': 'col-xs-12 col-md-3', } def __init__(self, *args, **kwargs): """Constructor.""" super(LiteratureForm, self).__init__(*args, **kwargs) self.subject.choices = [ (val, val) for val in current_app.config['INSPIRE_CATEGORIES'] ] self.degree_type.choices = [ (val, val) for val in current_app.config['INSPIRE_DEGREE_TYPES'] ]
class DeleteClipForm(FlaskForm): """ DeleteClipForm is used to delete a clip """ clip_id = IntegerField(u'Clip ID', [DataRequired()], id='delete-clip-id', widget=HiddenInput())
class ReportForm(FlaskForm): """ ReportForm is the form used by users to report inappropriate clips """ clip_id = IntegerField(u'Clip ID', [DataRequired()], id='report-clip-id', widget=HiddenInput()) reason = RadioField(u'Reason', [DataRequired()], id='report-reason', choices=[('content', 'Sexual or violent content'), ('not_speedrun', 'Not related to speedrunning'), ('spam', 'Spam'), ('other', 'Other')]) description = TextAreaField(u'Description', [Length(max=cn.REPORT_DESCRIPTION_LENGTH)], id='report-description')
class EditScheduledChangeNewPermissionForm(ScheduledChangeTimeForm): """When editing an existing Scheduled Change for a Permission, any field may be changed.""" permission = StringField('Permission', validators=[Length(0, 50), Optional()]) username = StringField('Username', validators=[Length(0, 100), Optional()]) options = JSONStringField(None, 'Options') sc_data_version = IntegerField('sc_data_version', validators=[InputRequired()], widget=HiddenInput())
class EditScheduledChangeDeleteRuleForm(ScheduledChangeTimeForm, ScheduledChangeUptakeForm): sc_data_version = IntegerField('sc_data_version', validators=[InputRequired()], widget=HiddenInput())
_field_args = { 'sids': { 'multiple': True }, 'sysid': { 'multiple': True }, 'type': { 'coerce': int }, 'state': { 'coerce': int }, 'id': { 'widget': HiddenInput() }, } RewardSetForm = model_form(ActivitySetting, field_args=_field_args, exclude=['name']) LangIDForm = model_form(LangConf, field_args={ 'id': { 'label': u'语言id' }, 'lang_name': { 'label': u'名称' } })
class ProjectAddContributableUsersForm(Form): id = IntegerField(label=None, widget=HiddenInput()) users_ids = SelectMultipleField(lazy_gettext('User(s)'), coerce=int, option_widget=CheckboxInput(), widget=ListWidget(prefix_label=False))
class LiteratureForm(INSPIREForm): """Literature form fields.""" doi = fields.DOIField( label='DOI', processors=[], export_key='doi', description='e.g. 10.1086/305772 or doi:10.1086/305772', placeholder='', validators=[DOISyntaxValidator("The provided DOI is invalid - it should look similar to '10.1086/305772'."), duplicated_doi_validator], ) arxiv_id = fields.ArXivField( label='arXiv ID', export_key="arxiv_id", validators=[arxiv_syntax_validation, duplicated_arxiv_id_validator], ) categories_arXiv = fields.TextField( widget=HiddenInput(), export_key='categories', ) import_buttons = fields.SubmitField( label=' ', widget=import_buttons_widget ) types_of_doc = [("article", "Article/Conference paper"), ("thesis", "Thesis"), ('book', 'Book'), ('chapter', 'Book chapter')] # ("proceedings", _("Proceedings")) type_of_doc = fields.SelectField( label='Type of Document', choices=types_of_doc, default="article", # widget=radiochoice_buttons, widget_classes='form-control', validators=[validators.DataRequired()], ) title = fields.TitleField( label='Title', widget_classes="form-control", validators=[validators.DataRequired()], export_key='title', ) title_crossref = fields.TitleField( export_key='title_crossref', widget=HiddenInput(), ) title_arXiv = fields.TitleField( export_key='title_arXiv', widget=HiddenInput(), ) title_translation = fields.TitleField( label='Translated Title', description='Original title translated to english language.', widget_classes="form-control", export_key='title_translation', ) authors = fields.DynamicFieldList( fields.FormField( AuthorInlineForm, widget=ExtendedListWidget( item_widget=ItemWidget(), html_tag='div', ), ), label='Authors', add_label='Add another author', min_entries=1, widget_classes='', export_key='authors', validators=[AuthorsValidation], ) collaboration = fields.TextField( label='Collaboration', export_key="collaboration", widget_classes="form-control" + ARTICLE_CLASS ) experiment = fields.TextField( placeholder="Start typing for suggestions", export_key="experiment", label='Experiment', widget_classes="form-control", autocomplete="experiment" ) subject = fields.SelectMultipleField( label='Subject', widget_classes="form-control", export_key='subject_term', filters=[clean_empty_list], validators=[validators.DataRequired()] ) abstract = fields.TextAreaField( label='Abstract', default='', widget_classes="form-control", export_key='abstract', ) language_choices = [ (language, Locale('en').languages.get(language)) for language in FORM_LANGUAGES ] language_choices.sort(key=lambda x: x[1]) language_choices.append( ('oth', 'Other') ) language = fields.LanguageField( label="Language", export_key="language", default="en", choices=language_choices ) def _is_other_language(language): return language[0] not in FORM_LANGUAGES and len(language[0]) == 2 other_language_choices = filter( _is_other_language, Locale('en').languages.items() ) other_language_choices.sort(key=lambda x: x[1]) other_language = fields.LanguageField( label="Other Language", export_key="other_language", widget_classes="form-control", choices=other_language_choices, description="What is the language of the publication?" ) conf_name = fields.TextField( placeholder="Start typing for suggestions", label='Conference Information', description='Conference name, acronym, place, date', widget_classes="form-control" + ARTICLE_CLASS, autocomplete='conference' ) conference_id = fields.TextField( export_key='conference_id', widget=HiddenInput(), ) license_url = fields.TextField( label='License URL', export_key='license_url', widget=HiddenInput(), ) report_numbers = fields.DynamicFieldList( fields.FormField( ReportNumberInlineForm, widget=ExtendedListWidget( item_widget=ItemWidget(), html_tag='div', ), ), add_label='Add another report number', min_entries=1, widget_classes='', widget=UnsortedDynamicListWidget(), ) # ============== # Thesis related # ============== supervisors = fields.DynamicFieldList( fields.FormField( AuthorInlineForm, widget=ExtendedListWidget( item_widget=ItemWidget(), html_tag='div', ), ), label='Supervisors', add_label='Add another supervisor', min_entries=1, widget_classes=THESIS_CLASS, ) thesis_date = fields.TextField( label='Date of Submission', description='Format: YYYY-MM-DD, YYYY-MM or YYYY.', validators=[date_validator], widget_classes='form-control' + THESIS_CLASS, ) defense_date = fields.TextField( label='Date of Defense', description='Format: YYYY-MM-DD, YYYY-MM or YYYY.', validators=[date_validator], widget_classes='form-control' + THESIS_CLASS, ) degree_type = fields.SelectField( label='Degree Type', default='phd', widget_classes="form-control" + THESIS_CLASS, ) institution = fields.TextField( autocomplete='affiliation', placeholder='Start typing for suggestions', label='Institution', widget_classes="form-control" + THESIS_CLASS, ) # ========= # Book Info # ========= publisher_name = fields.TextField( label='Publisher', widget_classes="form-control" + BOOK_CLASS, ) publication_place = fields.TextField( label='Publication Place', widget_classes="form-control" + BOOK_CLASS, ) series_title = fields.TextField( label='Series Title', widget_classes="form-control" + BOOK_CLASS, autocomplete='journal' ) series_volume = fields.TextField( label='Volume', widget_classes="form-control" + BOOK_CLASS, ) publication_date = fields.TextField( label='Publication Date', description='Format: YYYY-MM-DD, YYYY-MM or YYYY.', widget_classes="form-control" + BOOK_CLASS, validators=[date_validator], ) # ================= # Book Chapter Info # ================= book_title = fields.TextField( label='Book Title', widget_classes="form-control" + CHAPTER_CLASS, ) start_page = fields.TextField( placeholder='Start page of the chapter', widget_classes="form-control" + CHAPTER_CLASS, ) end_page = fields.TextField( placeholder='End page of the chapter', widget_classes="form-control" + CHAPTER_CLASS, ) find_book = fields.TextField( placeholder="Start typing for suggestions", label='Find Book', description='Book name, ISBN, Publisher', widget_classes="form-control" + CHAPTER_CLASS, ) parent_book = fields.TextField( widget=HiddenInput(), ) # ============ # Journal Info # ============ journal_title = fields.TextField( placeholder="Start typing for suggestions", label='Journal Title', widget_classes="form-control" + ARTICLE_CLASS, autocomplete='journal' ) page_range_article_id = fields.TextField( label='Page Range/Article ID', description='e.g. 1-100', widget_classes="form-control" + ARTICLE_CLASS ) volume = fields.TextField( label='Volume', widget_classes="form-control" + ARTICLE_CLASS ) year = fields.TextField( label='Year', widget_classes="form-control" + ARTICLE_CLASS, validators=[year_validator], ) issue = fields.TextField( label='Issue', widget_classes="form-control" + ARTICLE_CLASS ) nonpublic_note = fields.TextAreaField( label='Proceedings', description='Editors, title of proceedings, publisher, year of publication, page range, URL', widget=wrap_nonpublic_note, widget_classes="form-control" + ARTICLE_CLASS ) note = fields.TextAreaField( widget=HiddenInput(), export_key='note', ) # ========== # References # ========== references = fields.TextAreaField( label='References', description='Please paste the references in plain text', widget_classes="form-control" ) # ==================== # Preprint Information # ==================== preprint_created = fields.TextField( widget=HiddenInput(), export_key='preprint_created', ) # ==================== # Fulltext Information # ==================== url = fields.TextField( label='Link to PDF', description='Where can we find a PDF to check the references?', placeholder='http://www.example.com/document.pdf', validators=[pdf_validator], widget_classes="form-control", ) additional_url = fields.TextField( label='Link to additional information (e.g. abstract)', description='Which page should we link from INSPIRE?', placeholder='http://www.example.com/splash-page.html', validators=[no_pdf_validator], widget_classes="form-control", ) # ============== # Extra comments # ============== extra_comments = fields.TextAreaField( label='Comments', description='Any extra comments related to your submission', widget_classes="form-control" ) # # Form Configuration # _title = "Suggest content" # Group fields in categories groups = [ ('Import information', ['arxiv_id', 'doi', 'import_buttons']), ('Document Type', ['type_of_doc', ]), ('Links', ['url', 'additional_url']), ('Publication Information', ['find_book', 'parent_book', 'book_title', 'start_page', 'end_page']), ('Basic Information', ['title', 'title_arXiv', 'categories_arXiv', 'language', 'other_language', 'title_translation', 'subject', 'authors', 'collaboration', 'experiment', 'abstract', 'report_numbers']), ('Thesis Information', ['degree_type', 'thesis_date', 'defense_date', 'institution', 'supervisors', 'license_url']), ('Publication Information', ['journal_title', 'volume', 'issue', 'year', 'page_range_article_id']), ('Publication Information', ['series_title', 'series_volume', 'publication_date', 'publisher_name', 'publication_place']), ('Conference Information', ['conf_name', 'conference_id'], {'classes': 'collapse'}), ('Proceedings Information (if not published in a journal)', ['nonpublic_note'], {'classes': 'collapse'}), ('References', ['references'], {'classes': 'collapse'}), ('Additional comments', ['extra_comments'], {'classes': 'collapse'}), ] field_sizes = { 'type_of_doc': 'col-xs-12 col-md-3', 'wrap_nonpublic_note': 'col-md-9', 'publisher_name': 'col-xs-12 col-md-9', 'publication_date': 'col-xs-12 col-md-4', 'thesis_date': 'col-xs-12 col-md-4', 'defense_date': 'col-xs-12 col-md-4', 'degree_type': 'col-xs-12 col-md-3', 'start_page': 'col-xs-12 col-md-3', 'end_page': 'col-xs-12 col-md-3', } def __init__(self, *args, **kwargs): """Constructor.""" super(LiteratureForm, self).__init__(*args, **kwargs) inspire_categories_schema = load_schema('elements/inspire_field.json') categories = inspire_categories_schema['properties']['term']['enum'] self.subject.choices = [(val, val) for val in categories] degree_type_schema = load_schema('elements/degree_type.json') degree_choices = [ (val, val.capitalize()) if val != 'phd' else ('phd', 'PhD') for val in degree_type_schema['enum'] ] degree_choices.sort(key=lambda x: x[1]) self.degree_type.choices = degree_choices
class RaceResultsForm(FlaskForm): time_to_finish = IntegerField('Time to Finish', validators=[DataRequired()]) id_race_participants = IntegerField('Participant ID', widget=HiddenInput()) did_not_finish = BooleanField('Did Not Finish') submit = SubmitField('Submit Result')
class RatingForm(Form): job_id = TextField(_('Select job'), validators = [Required()], default='') user_id = TextField(_('Select user'), validators = [Required(), avoid_self_rating], default='') rated_by_id = TextField(_('Your SIN'), validators = [Required()], default='') rating = TextField(_('Rating'), validators=[Required()], default=0, widget=HiddenInput()) comments = TextAreaField(_('Comments'), validators = [], default='')
class TaskPresenterForm(Form): id = IntegerField(label=None, widget=HiddenInput()) editor = TextAreaField('') guidelines = TextAreaField('')
class ScheduledChangeDeleteReleaseForm(ScheduledChangeTimeForm): """Name must be provided when Scheduling a Change that deletes an existing Permission so that we can find it.""" name = StringField('Name', validators=[InputRequired()]) data_version = IntegerField('data_version', validators=[InputRequired()], widget=HiddenInput()) change_type = SelectField("Change Type", choices=[('insert', 'insert'), ('update', 'update'), ('delete', 'delete')])
class BulkTaskDropboxImportForm(Form): form_name = TextField(label=None, widget=HiddenInput(), default='dropbox') files = FieldList(TextField(label=None, widget=HiddenInput())) def get_import_data(self): return {'type': 'dropbox', 'files': self.files.data}
class EditScheduledChangeNewReleaseForm(ScheduledChangeTimeForm): """Any Release field may be changed when editing an Scheduled Change for a new Release.""" name = StringField('Name', validators=[Optional()]) product = StringField('Product', validators=[Optional()]) data = JSONStringField(None, 'Data', validators=[Optional()], widget=FileInput()) sc_data_version = IntegerField('sc_data_version', validators=[InputRequired()], widget=HiddenInput())
class BanUserForm(FlaskForm): """ BanUserForm is used for banning a user """ user_id = IntegerField(u'User ID', [DataRequired()], widget=HiddenInput())
class FlightForm(Form): id = IntegerField(widget=HiddenInput())
class JobForm(Form): """A `JobForm` is used for creating and updating posted jobs.""" #: Job id (populated if used for updating). id = IntegerField('Id', widget=HiddenInput(), validators=[Optional()]) #: Job title. title = TextField('Title', validators=[DataRequired(), Length(max=100)]) #: Job description. description = TextField('Description', widget=TextArea(), validators=[DataRequired()], filters=[clean_html]) #: Job Type (full time, part time, contract or internship). job_type = SelectField('Job Type', validators=[DataRequired()], choices=Job.JOB_TYPES.items(), coerce=int) #: Does the company accept remote workers? remote_work = SelectField('Remote Work?', validators=[DataRequired()], choices=Job.REMOTE_WORK_OPTIONS.items(), coerce=int) #: Company id (populated if used for updating). company__id = IntegerField('Company id', widget=HiddenInput(), validators=[Optional()]) #: Company name (freetext). company__name = TextField('Company Name', validators=[DataRequired(), Length(max=75)]) #: Company website (freetext). company__website = TextField('Company Website', validators=[Optional(), Length(max=200)]) #: Location id (populated if used for updating). location__id = IntegerField('Location id', widget=HiddenInput(), validators=[Optional()]) #: Location city (freetext). location__city = TextField('City', validators=[DataRequired(), Length(max=75)]) #: Location country (country ISO code). location__country_code = SelectField('Country', validators=[DataRequired(), Length(max=3)], choices=Location.COUNTRIES.items()) #: Contact method (email or url). contact_method = SelectField('Contact Method', validators=[DataRequired()], choices=Job.CONTACT_METHODS.items(), coerce=int) #: Contact email (if contact method is email). contact_email = TextField('Contact Email', validators=[Optional(), Email(), Length(max=150)]) #: Contact url (if contact method is url). contact_url = TextField('Contact Link', validators=[Optional(), Length(max=200)]) #: Recruiter name (freetext). recruiter_name = TextField('Recruiter Name', validators=[DataRequired(), Length(max=100)]) #: Recruiter email (email obviously). recruiter_email = TextField('Recruiter Email', validators=[Email(), Length(max=150)]) #: Job tags. tags = TagListField('Tags', validators=[Optional()])
class DbEditableForm(Form): data_version = IntegerField('data_version', validators=[Required()], widget=HiddenInput())
class AuthorUpdateForm(INSPIREForm): """Author update form.""" # Hidden field to hold author id information bai = fields.StringField(widget=HiddenInput()) inspireid = fields.StringField(widget=HiddenInput()) # Hidden field to hold record id information recid = fields.IntegerField( widget=HiddenInput(), validators=[validators.Optional()], ) given_names = fields.StringField(label=_('Given Names'), description=u'e.g. Diego', validators=[validators.DataRequired()], widget_classes="form-control") family_name = fields.StringField(label=_('Family Name'), description=u'e.g. Martínez Santos', widget_classes="form-control") display_name = fields.StringField( label=_('Display Name'), description= u'How should the author be addressed throughout the site? e.g. Diego Martínez', validators=[validators.DataRequired()], widget_classes="form-control") native_name = fields.StringField( label=_('Native Name'), description=u'For non-Latin names e.g. 麦迪娜 or Эдгар Бугаев', widget_classes="form-control") public_email = fields.StringField( label=_('Public Email'), description= u"This email will be displayed online in the INSPIRE Author Profile.", widget_classes="form-control", validators=[validators.Optional(), validators.Email()], ) orcid = fields.StringField( label= 'ORCID <img src="/static/images/orcid_icon_24.png" style="height:20px">', widget_classes="form-control", description= u"""ORCID provides a persistent digital identifier that distinguishes you from other researchers. Learn more at <a href="http://orcid.org" tabIndex="-1" target="_blank">orcid.org</a>""", widget=WrappedInput(wrapper=""" <div class="input-group"> <span class="input-group-addon" id="sizing-addon2">orcid.org/</span> %(field)s </div> """), placeholder="0000-0000-0000-0000", validators=[ validators.Optional(), RegexpStopValidator( "\d{4}-\d{4}-\d{4}-\d{3}[\dX]", message= "A valid ORCID iD consists of 16 digits separated by dashes.", ), ORCIDValidator ]) status_options = [("active", _("Active")), ("retired", _("Retired")), ("departed", _("Departed")), ("deceased", _("Deceased"))] status = fields.SelectField( label='Status', choices=status_options, default="active", validators=[validators.DataRequired()], widget_classes='form-control', ) blog_url = fields.StringField( label=_('Blog'), placeholder='http://www.example.com', icon="fa fa-wordpress", widget_classes="form-control", ) twitter_url = fields.StringField( label=_('Twitter'), placeholder='https://twitter.com/inspirehep', icon="fa fa-twitter", widget_classes="form-control", ) linkedin_url = fields.StringField( label=_('Linkedin'), placeholder= 'https://www.linkedin.com/pub/john-francis-lampen/16/750/778', icon="fa fa-linkedin-square", widget_classes="form-control", ) websites = fields.DynamicFieldList(fields.FormField( WebpageInlineForm, widget=ExtendedListWidget( item_widget=ItemWidget(), html_tag='div', ), ), add_label=_('Add another website'), min_entries=1, widget_classes='ui-disable-sort', icon="fa fa-globe", widget=DynamicUnsortedWidget()) research_field_options = [ ("ACC-PHYS", _("acc-phys")), ("ASTRO-PH", _("astro-ph")), ("ATOM-PH", _("atom-ph")), ("CHAO-DYN", _("chao-dyn")), ("CLIMATE", _("climate")), ("COMP", _("comp")), ("COND-MAT", _("cond-mat")), ("GENL-TH", _("genl-th")), ("GR-QC", _("gr-qc")), ("HEP-EX", _("hep-ex")), ("HEP-LAT", _("hep-lat")), ("HEP-PH", _("hep-ph")), ("HEP-TH", _("hep-th")), ("INSTR", _("instr")), ("LIBRARIAN", _("librarian")), ("MATH", _("math")), ("MATH-PH", _("math-ph")), ("MED-PHYS", _("med-phys")), ("NLIN", _("nlin")), ("NUCL-EX", _("nucl-ex")), ("NUCL-TH", _("nucl-th")), ("PHYSICS", _("physics")), ("PLASMA-PHYS", _("plasma-phys")), ("Q-BIO", _("q-bio")), ("QUANT-PH", _("quant-ph")), ("SSRL", _("ssrl")), ("OTHER", _("other")) ] research_field = fields.SelectMultipleField( label=_('Field of Research'), choices=research_field_options, widget_classes="form-control", filters=[clean_empty_list], validators=[validators.DataRequired()]) institution_history = fields.DynamicFieldList( fields.FormField(InstitutionInlineForm, widget=ExtendedListWidget( item_widget=ItemWidget(), html_tag='div', ), widget_classes="col-xs-10"), label='Institution History', add_label='Add another institution', min_entries=1, widget=DynamicUnsortedWidget(), widget_classes="ui-disable-sort") advisors = fields.DynamicFieldList(fields.FormField( AdvisorsInlineForm, widget=ExtendedListWidget( item_widget=ItemWidget(), html_tag='div', ), ), label='Advisors', add_label='Add another advisor', min_entries=1, widget=DynamicUnsortedWidget(), widget_classes="ui-disable-sort") experiments = fields.DynamicFieldList(fields.FormField( ExperimentsInlineForm, widget=ExtendedListWidget( item_widget=ItemWidget(), html_tag='div', ), widget_classes="col-xs-10"), label='Experiment History', add_label='Add another experiment', min_entries=1, widget=DynamicUnsortedWidget(), widget_classes="ui-disable-sort") comments = fields.TextAreaField( label=_('Comments'), description= u'Send us any comments you might have. They will not be visible.', widget_classes="form-control") # # Form Configuration # _title = _("Update author details") # Group fields in categories groups = [ ('Personal Information', [ 'given_names', 'family_name', 'display_name', 'native_name', 'email', 'public_email', 'status', 'orcid', 'bai', 'inspireid' ], { "icon": "fa fa-user" }), ('Personal Websites', [ 'websites', 'linkedin_url', 'blog_url', 'twitter_url', "twitter_hidden" ], { "icon": "fa fa-globe" }), ('Career Information', ['research_field', 'institution_history', 'experiments', 'advisors'], { "icon": "fa fa-university" }), ('Comments', ['comments'], { "icon": "fa fa-comments" }) ] def __init__(self, is_review=False, *args, **kwargs): """Constructor.""" super(AuthorUpdateForm, self).__init__(*args, **kwargs) if is_review: self.bai.widget = TextInput() self.bai.widget_classes = "form-control" self.inspireid.widget = TextInput() self.inspireid.widget_classes = "form-control"
class CompleteReleaseForm(Form): name = StringField('Name', validators=[Required()]) product = StringField('Product', validators=[Required()]) blob = JSONStringField('Data', validators=[Required()], widget=FileInput()) data_version = IntegerField('data_version', widget=HiddenInput())
class ShopForm(Form): # 店铺名称 shop_name = StringField( label="店铺名称:", validators=[ validators.DataRequired(message="店铺名称必须填写!"), validators.Length(min=4, max=16, message="店铺名称最短4个字符, 最长16个字符") ], render_kw={"class": "layui-input lens", "placeholder": "请输入店铺名称"} ) # 是否是品牌 brand = BooleanField(label="是否品牌:", default=False) on_time = BooleanField(label="准时送达:", default=False) fengniao = BooleanField(label="蜂鸟速递:", default=False) piao = BooleanField(label="是否发票:", default=False) bao = BooleanField(label="是否保险:", default=False) zhun = BooleanField(label="是否标识:", default=False) # 起送价格 start_send = DecimalField( label="起送价格:", validators=[ validators.DataRequired(message="必须填写起送价格") ], render_kw={"class": "layui-input lens"} ) # 配送费 send_cost = DecimalField( label="配送价格:", validators=[ validators.DataRequired(message="配送费必须填写!") ], render_kw={"class": "layui-input lens"} ) # 店铺公告 notice = StringField( label="店铺公告:", validators=[ validators.Length(min=10, max=128, message="最短10个字符, 最长128个字符") ], render_kw={"class": "layui-input lens"} ) # 优惠信息 discount = StringField( label="优惠信息:", validators=[ validators.Length(min=10, max=128, message="最短10个字符, 最长128个字符") ], render_kw={"class": "layui-input lens"} ) # 店铺图片 shop_img = StringField( label="店铺图片", id='image-input', widget=HiddenInput() ) # 自定义验证器,验证起送价格和运送费 def validate_start_send(self, obj): obj.data = float('{:.2f}'.format(obj.data)) def validate_send_cost(self, obj): obj.data = float("{:.2f}".format(obj.data))
class ReadOnlyForm(Form): name = StringField('Name', validators=[Required()]) product = StringField('Product', validators=[Required()]) read_only = BooleanField('read_only') data_version = IntegerField('data_version', widget=HiddenInput())
class TaskUpload(Form): id = IntegerField(label=None, widget=HiddenInput()) avatar = FileField(lazy_gettext('Avatar'), validators=[FileRequired()])
class AdditionalFactEntryForm(Form): title = StringField('Title', validators=[DataRequired()]) text = TextAreaField('Text', validators=[DataRequired()]) is_long = BooleanField('This should span the entire post') id = IntegerField(widget=HiddenInput())
class HiddenIntegerField(IntegerField): widget = HiddenInput()
class PostChangeForm(PostCreationForm): id = IntegerField(HiddenInput( )) ### THIS ADDS THE ID OF THE REFERENCING POST AS HIDDEN FIELD submit = SubmitField('Save')