Example #1
0
class AuthorInlineForm(WebDepositForm):
    """Author inline form."""

    name = fields.TextField(
        placeholder=_("Family name, First name"),
        widget_classes='form-control',
        # autocomplete=map_result(
        #     dummy_autocomplete,
        #     authorform_mapper
        # ),
        widget=ColumnInput(class_="col-xs-6"),
        validators=[
            required_if(
                'affiliation',
                [
                    lambda x: bool(x.strip()),
                ],  # non-empty
                message=_(
                    "Creator name is required if you specify affiliation.")),
        ],
    )
    affiliation = fields.TextField(
        placeholder=_("Affiliation"),
        widget_classes='form-control',
        widget=ColumnInput(class_="col-xs-4 col-pad-0"),
    )
Example #2
0
class FileInlineForm(WebDepositForm):
    """
    Files inline form
    """
    name = fields.TextField(
        export_key='expansion',
        label=_("Name"),
        placeholder=_("Name this file..."),
        validators=[validators.Required()],
        widget_classes='form-control',
    )
    language = fields.SelectField(
        choices=FILE_LANGUAGES,
        default='Text',
        label=_("Language"),
        export_key='number',
        widget_classes='form-control',
    )
    abstract = fields.TextAreaField(
        default='',
        export_key='summary',
        icon='fa fa-pencil fa-fw',
        label=_("Description"),
        widget_classes='form-control',
    )
Example #3
0
class UrlInlineForm(WebDepositForm):

    """Url inline form."""

    url = fields.TextField(
        widget_classes='form-control',
        widget=ColumnInput(class_="col-xs-10"),
        export_key='full_url',
        placeholder='http://www.example.com',
    )
Example #4
0
class AuthorInlineForm(WebDepositForm):

    """Author inline form."""

    name = fields.TextField(
        widget_classes='form-control',
        widget=ColumnInput(class_="col-xs-6", description="Family name, First name"),
        # validators=[
        #     validators.Required(),
        # ],
        export_key='full_name',
    )
    affiliation = fields.TextField(
        autocomplete=kb_dynamic_autocomplete("InstitutionsCollection",
                                             mapper=institutions_kb_mapper),
        placeholder='Start typing for suggestions',
        autocomplete_limit=5,
        widget_classes='form-control',
        widget=ColumnInput(class_="col-xs-4 col-pad-0", description="Affiliation"),
        export_key='affiliation',
    )
Example #5
0
class GistForm(WebDepositForm):
    #
    # Fields
    #
    title = fields.TextField(
        label='',
        export_key='title.title',
        placeholder=_("Gist description..."),
        widget_classes="form-control",
    )

    gist_files = fields.DynamicFieldList(
        fields.FormField(
            FileInlineForm,
            widget=ExtendedListWidget(
                item_widget=ListItemWidget(html_tag='div', ),
                html_tag='div',
            ),
        ),
        add_label=_('Add another file'),
        export_key='abstract',
        label='',
        min_entries=1,
        validators=[
            validators.Required(),
            list_length(
                min_num=1,
                element_filter=filter_empty_helper(),
            )
        ],
        widget_classes='',
    )

    # Form configuration
    #
    _title = _('New Gist')
    _subtitle = _('Instructions: <br/>'
                  '(i) Press "Save" to save your upload for editing later, '
                  'as many times you like.<br/>'
                  '(ii) When ready, press "Submit" to finalize your upload.')

    groups = [
        (
            'Gist details',
            ['title', 'gist_files'],
        ),
    ]

    field_sizes = {
        'gist_files': 'col-md-10',
        'title': 'col-md-12',
    }
Example #6
0
class LiteratureForm(WebDepositForm):

    """Literature form fields."""

    # captcha = RecaptchaField()

    doi = fields.DOIField(
        label=_('DOI'),
        processors=[],
        export_key='doi',
        description='e.g. 10.1234/foo.bar or doi:10.1234/foo.bar',
        placeholder=''
    )

    arxiv_id = ArXivField(
        label=_('arXiv ID'),
    )

    # 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.Required()],
    )

    title = fields.TitleField(
        label=_('Title'),
        widget_classes="form-control",
        validators=[validators.Required()],
        export_key='title',
    )

    title_arXiv = fields.TitleField(
        export_key='title_arXiv',
        widget_classes="hidden",
        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'),
        widget_classes="form-control"
    )

    experiment = fields.TextField(
        placeholder=_("Start typing for suggestions"),
        label=_('Experiment'),
        widget_classes="form-control",
        autocomplete=kb_dynamic_autocomplete("dynamic_experiments",
                                             mapper=experiment_kb_mapper)
    )

    # this should be a prefilled dropdown
    subject = fields.SelectMultipleField(
        label=_('Subject'),
        widget_classes="form-control",
        export_key='subject_term',
        filters=[clean_empty_list]
    )

    abstract = fields.TextAreaField(
        label=_('Abstract'),
        default='',
        widget_classes="form-control",
        export_key='abstract',
    )

    page_nr = fields.TextField(
        label=_('Number of Pages'),
        widget_classes="form-control",
        export_key='page_nr'
    )

    languages = [("en", _("English")),
                 ("fre", _("French")),
                 ("ger", _("German")),
                 ("dut", _("Dutch")),
                 ("ita", _("Italian")),
                 ("spa", _("Spanish")),
                 ("por", _("Portuguese")),
                 ("gre", _("Greek")),
                 ("slo", _("Slovak")),
                 ("cze", _("Czech")),
                 ("hun", _("Hungarian")),
                 ("pol", _("Polish")),
                 ("nor", _("Norwegian")),
                 ("swe", _("Swedish")),
                 ("fin", _("Finnish")),
                 ("rus", _("Russian")),
                 ("oth", _("Other"))]

    language = fields.LanguageField(
        label=_("Language"),
        choices=languages
    )

    conf_name = fields.TextField(
        placeholder=_("Start typing for suggestions"),
        label=_('Conference Information'),
        description=_('Conference name, acronym, place, date'),
        widget_classes="form-control"
    )

    conference_id = fields.TextField(
        export_key='conference_id',
        widget_classes="hidden",
        widget=HiddenInput(),
    )

    license_url = fields.TextField(
        label=_('License URL'),
        export_key='license_url',
        widget_classes="hidden",
        widget=HiddenInput(),
    )

    # ==============
    # 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,
        export_key='supervisors',
        widget_classes=THESIS_CLASS,
    )

    defense_date = fields.Date(
        label=_('Date of Defense'),
        description='Format: YYYY-MM-DD.',
        widget=defensedate_widget,
    )

    degree_type = fields.TextField(
        label=_('Degree type'),
        widget_classes="form-control" + THESIS_CLASS,
    )

    university = fields.TextField(
        label=_('University'),
        widget_classes="form-control" + THESIS_CLASS,
    )

    # ============
    # Journal Info
    # ============
    journal_title = fields.TextField(
        placeholder=_("Start typing for suggestions"),
        label=_('Journal Title'),
        widget_classes="form-control",
        autocomplete=kb_dynamic_autocomplete("dynamic_journal_titles",
                                             mapper=journal_title_kb_mapper)
    )

    page_range = fields.TextField(
        label=_('Page Range'),
        description=_('e.g. 1-100'),
        widget_classes="form-control"
    )

    article_id = fields.TextField(
        label=_('Article ID'),
        widget_classes="form-control"
    )

    volume = fields.TextField(
        label=_('Volume'),
        widget_classes="form-control"
    )

    year = fields.TextField(
        label=_('Year'),
        widget_classes="form-control"
    )

    issue = fields.TextField(
        label=_('Issue'),
        widget_classes="form-control"
    )

    nonpublic_note = fields.TextAreaField(
        label=_('Proceedings'),
        description='Editors, title of proceedings, publisher, year of publication, page range',
        widget=wrap_nonpublic_note
    )

    note = fields.TextAreaField(
        export_key='note',
        widget_classes="hidden",
        widget=HiddenInput(),
    )

    # ====================
    # Fulltext Information
    # ====================
    file_field = fields.FileUploadField(
        label="",
        widget=plupload_widget,
        export_key=False
    )

    url = fields.DynamicFieldList(
        fields.FormField(
            UrlInlineForm,
            widget=ExtendedListWidget(
                item_widget=ItemWidget(),
                html_tag='div',
            ),
        ),
        #validators=[validators.URL(), validators.Optional, ],
        label=_('External URL'),
        add_label=_('Add another url'),
        min_entries=1,
        export_key='url',
        widget_classes='',
    )

    # ok_to_upload = fields.BooleanField(
    #     label=_('I ensure the file is free to be uploaded.'),
    #     default=False,
    #     validators=[required_if('file_field',
    #                             [lambda x: bool(x.strip()), ],  # non-empty
    #                             message="It's required to check this box."
    #                             ),
    #                 required_if('url',
    #                             [lambda x: bool(x.strip()), ],  # non-empty
    #                             message="It's required to check this box."
    #                             ),
    #                 ]
    #     )

    #
    # Form Configuration
    #
    _title = _("Literature submission")

    # Group fields in categories

    groups = [
        ('Import from existing source',
            ['arxiv_id', 'doi', 'import_buttons']),
        ('Document Type',
            ['captcha', 'type_of_doc', ]),
        ('Basic Information',
            ['title', 'title_arXiv', 'language', 'title_translation', 'authors',
             'collaboration', 'experiment', 'abstract', 'page_nr', 'subject',
             'supervisors', 'defense_date', 'degree_type', 'university',
             'license_url']),
        ('Conference Information',
            ['conf_name', 'conference_id']),
        ('Journal Information',
            ['journal_title', 'volume', 'issue', 'page_range', 'article_id',
             'year']),
        ('Proceedings Information (not published in journal)',
            ['nonpublic_note', 'note']),
        ('Upload/link files',
            ['file_field', 'url']),
    ]

    field_sizes = {
        'file_field': 'col-md-12',
        'type_of_doc': 'col-xs-4',
        'wrap_nonpublic_note': 'col-md-9',
    }

    def __init__(self, *args, **kwargs):
        """Constructor."""
        super(LiteratureForm, self).__init__(*args, **kwargs)
        from invenio.modules.knowledge.api import get_kb_mappings
        self.subject.choices = [(x['value'], x['value'])
            for x in get_kb_mappings(cfg["DEPOSIT_INSPIRE_SUBJECTS_KB"])]
Example #7
0
class ArticleForm(WebDepositForm):
    """Article form."""

    #
    # Fields
    #
    doi = fields.TextField(
        label=_("Digital Object Identifier"),
        placeholder=_("e.g. 10.1234/foo.bar..."),
        widget_classes="form-control",
        icon='fa fa-barcode fa-fw',
        validators=[
            doi_syntax_validator,
        ],
        filters=[
            strip_string,
            strip_prefixes("doi:", "http://dx.doi.org/"),
        ],
        processors=[
            missing_doi_warning,
        ],
    )

    publication_date = fields.Date(
        label=_('Publication date'),
        icon='fa fa-calendar fa-fw',
        description=_('Required. Format: YYYY-MM-DD.'),
        default=date.today(),
        validators=[validators.DataRequired()],
        widget=date_widget,
        widget_classes='input-sm',
        export_key='imprint.date',
    )

    title = fields.TextField(
        label=_('Title'),
        export_key='title.title',
        icon='fa fa-book fa-fw',
        widget_classes="form-control",
        validators=[validators.DataRequired()],
    )

    authors = fields.DynamicFieldList(
        fields.FormField(
            AuthorInlineForm,
            widget=ExtendedListWidget(
                item_widget=ItemWidget(),
                html_tag='div',
            ),
        ),
        label=_('Authors'),
        add_label=_('Add another author'),
        icon='fa fa-user fa-fw',
        min_entries=1,
        widget_classes='',
        export_key='authors',
        validators=[
            validators.DataRequired(),
            list_length(
                min_num=1,
                element_filter=filter_empty_helper(),
            )
        ],
    )

    abstract = fields.TextAreaField(
        label=_("Description"),
        description=_('Required.'),
        default='',
        icon='fa fa-pencil fa-fw',
        validators=[
            validators.DataRequired(),
        ],
        widget=CKEditorWidget(
            toolbar=[
                ['PasteText', 'PasteFromWord'],
                [
                    'Bold',
                    'Italic',
                    'Strike',
                    '-',
                    'Subscript',
                    'Superscript',
                ],
                ['NumberedList', 'BulletedList'],
                ['Undo', 'Redo', '-', 'Find', 'Replace', '-', 'RemoveFormat'],
                ['SpecialChar', 'ScientificChar'],
                ['Source'],
                ['Maximize'],
            ],
            disableNativeSpellChecker=False,
            extraPlugins='scientificchar',
            removePlugins='elementspath',
        ),
        filters=[
            sanitize_html(),
            strip_string,
        ],
        export_key='abstract.summary',
    )

    journal_title = fields.TextField(
        label=_("Journal title"),
        description=_("Optional."),
        validators=[
            required_if(
                'journal_volume',
                [
                    lambda x: bool(x.strip()),
                ],  # non-empty
                message=_("Journal title is required if you specify either "
                          "volume, issue or pages.")),
            required_if(
                'journal_issue',
                [
                    lambda x: bool(x.strip()),
                ],  # non-empty
                message=_("Journal title is required if you specify either "
                          "volume, issue or pages.")),
            required_if(
                'journal_pages',
                [
                    lambda x: bool(x.strip()),
                ],  # non-empty
                message=_("Journal title is required if you specify either "
                          "volume, issue or pages.")),
        ],
        export_key='journal_info.title',
        widget_classes='form-control',
    )

    journal_volume = fields.TextField(
        label=_("Volume"),
        description=_("Optional."),
        export_key='journal_info.volume',
        widget_classes='form-control',
    )

    journal_issue = fields.TextField(
        label=_("Issue"),
        description=_("Optional."),
        export_key='journal_info.issue',
        widget_classes='form-control',
    )

    journal_pages = fields.TextField(
        label=_("Pages"),
        description=_("Optional."),
        export_key='journal_info.pagination',
        widget_classes='form-control',
    )

    language = fields.SelectField(
        choices=LocalProxy(
            lambda: language_list_long(enabled_langs_only=False)),
        default='english',
        icon='fa fa-globe fa-fw',
        widget_classes='form-control',
    )

    keywords = fields.DynamicFieldList(
        fields.TextField(
            widget_classes='form-control',
            autocomplete=keywords_autocomplete,
            widget=ColumnInput(class_="col-xs-10"),
        ),
        label=_('Keywords'),
        add_label=_('Add another keyword'),
        icon='fa fa-tags fa-fw',
        widget_classes='',
        min_entries=1,
    )

    notes = fields.TextAreaField(
        label=_("Notes"),
        description=_('Optional.'),
        default='',
        validators=[validators.optional()],
        filters=[
            strip_string,
        ],
        widget_classes='form-control',
        icon='fa fa-pencil fa-fw',
        export_key='comment',
    )

    plupload_file = fields.FileUploadField(label="",
                                           widget=plupload_widget,
                                           export_key=False)

    #
    # Form configuration
    #
    _title = _('New article')
    _subtitle = _('Instructions: (i) Press "Save" to save your upload for '
                  'editing later, as many times you like. (ii) Upload or '
                  'remove  extra files in the bottom of the form. (iii) When '
                  'ready, press "Submit" to finalize your upload.')

    groups = [
        ('Basic Information', [
            'doi',
            'publication_date',
            'title',
            'authors',
            'abstract',
        ], {
            'indication': 'required',
        }),
        ('Journal',
         ['journal_title', 'journal_volume', 'journal_issue',
          'journal_pages'], {
              'indication': 'required'
          }),
        ('Additional information', ['language', 'keywords', 'notes'], {
            'indication': 'optional',
        })
    ]

    field_sizes = {
        'plupload_file': 'col-md-12',
    }