class NotesField(WebDepositField(), TextAreaField): def __init__(self, **kwargs): super(NotesField, self).__init__(**kwargs) self._icon_html = '<i class="icon-list"></i>' def pre_validate(self, form=None): return dict(error=0, error_message='')
class LanguageField(WebDepositField(key='language'), SelectField): def __init__(self, **kwargs): super(LanguageField, self).__init__(**kwargs) self._icon_html = '<i class="icon-flag"></i>' def pre_validate(self, form=None): return dict(error=0, error_message='')
class IntegerTextField(WebDepositField(), IntegerField): def __init__(self, **kwargs): super(IntegerTextField, self).__init__(**kwargs) def pre_validate(self, form=None): return dict(error=0, error_message='')
class AbstractField(WebDepositField(key='abstract.summary'), TextAreaField): def __init__(self, **kwargs): super(AbstractField, self).__init__(**kwargs) self._icon_html = '<i class="icon-pencil"></i>' def pre_validate(self, form=None): return dict(error=0, error_message='')
class TitleField(WebDepositField(key='title.title'), TextField): def __init__(self, **kwargs): super(TitleField, self).__init__(**kwargs) self._icon_html = '<i class="icon-book"></i>' def pre_validate(self, form=None): # Load custom validation validators = self.config.get_validators() if validators is not [] and validators is not None: validation_json = {} for validator in validators: json = validator(self) validation_json = self.merge_validation_json( validation_json, json) return validation_json value = self.data if value == "" or value.isspace(): return dict(error=0, error_message='') error_message = 'Document Title must have at least 4 characters' if len(str(value)) < 4: try: self.errors.append(error_message) except AttributeError: self.errors = list(self.process_errors) self.errors.append(error_message) return dict(error=1, error_message=error_message) return dict(error=0, error_message='')
class Date(WebDepositField(), DateField): def __init__(self, **kwargs): super(Date, self).__init__(**kwargs) self._icon_html = '<i class="icon-calendar"></i>' def pre_validate(self, form=None): return dict(error=0, error_message='')
class FileUploadField(WebDepositField(), FileField): def __init__(self, **kwargs): super(FileUploadField, self).__init__(**kwargs) self._icon_html = '<i class="icon-file"></i>' def pre_validate(self, form=None): return dict(error=0, error_message='')
class RecordIDField(WebDepositField(key='recid'), TextField): """ Used to update existing records """ def __init__(self, **kwargs): super(RecordIDField, self).__init__(**kwargs) self._icon_html = '<i class="icon-barcode"></i>' def pre_validate(self, form=None): return record_id_validate(self, form)
class AuthorField(WebDepositField(key='authors[0].full_name'), TextField): def __init__(self, **kwargs): super(AuthorField, self).__init__(**kwargs) self._icon_html = '<i class="icon-user"></i>' def pre_validate(self, form=None): return dict(error=0, error_message='') def autocomplete(self): # Load custom autocompletion function autocomplete = self.config.get_autocomplete_function() if autocomplete is not None: return autocomplete(self.data) return orcid_authors(self.data)
class ISSNField(WebDepositField(key='issn'), TextField): def __init__(self, **kwargs): super(ISSNField, self).__init__(**kwargs) self._icon_html = '<i class="icon-barcode"></i>' def pre_validate(self, form=None): # Load custom validation validators = self.config.get_validators() if validators is not [] and validators is not None: validation_json = {} for validator in validators: json = validator(self) validation_json = self.merge_validation_json( validation_json, json) return validation_json return sherpa_romeo_issn_validate(self)
class DOIField(WebDepositField(key='publication_info.DOI'), TextField): def __init__(self, **kwargs): super(DOIField, self).__init__(**kwargs) self._icon_html = '<i class="icon-barcode"></i>' def pre_validate(self, form=None): # Load custom validation validators = self.config.get_validators() if validators is not [] and validators is not None: validation_json = {} for validator in validators: json = validator(self) validation_json = self.merge_validation_json( validation_json, json) return validation_json return datacite_doi_validate(self)
class PagesNumberField(WebDepositField(), TextField): def __init__(self, **kwargs): super(PagesNumberField, self).__init__(**kwargs) self._icon_html = '<i class="icon-th"></i>' def pre_validate(self, form=None): # Load custom validation validators = self.config.get_validators() if validators is not [] and validators is not None: validation_json = {} for validator in validators: json = validator(self) validation_json = self.merge_validation_json( validation_json, json) return validation_json # Default validation return number_validate(self, error_message='Pages must be a number!')
class PublisherField(WebDepositField(), TextField): def __init__(self, **kwargs): super(PublisherField, self).__init__(**kwargs) self._icon_html = '<i class="icon-certificate"></i>' def pre_validate(self, form=None): # Load custom validation validators = self.config.get_validators() if validators is not [] and validators is not None: validation_json = {} for validator in validators: json = validator(self) validation_json = self.merge_validation_json( validation_json, json) return validation_json return sherpa_romeo_publisher_validate(self) def autocomplete(self): # Load custom autocompletion function autocomplete = self.config.get_autocomplete_function() if autocomplete is not None: return autocomplete(self.data) return sherpa_romeo_publishers(self.data)