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( export_key='categories', widget=HiddenInput(), ) # 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', 'page_nr', '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) # from invenio_knowledge.api import get_kb_mappings self.subject.choices = [('dummy', 'dummy')] self.degree_type.choices = [('dummy', 'dummy')]
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