diff --git a/site/ic_data_repo/config/custom_fields.py b/site/ic_data_repo/config/custom_fields.py new file mode 100644 index 0000000..ac792d8 --- /dev/null +++ b/site/ic_data_repo/config/custom_fields.py @@ -0,0 +1,42 @@ +from invenio_records_resources.services.custom_fields import TextCF +from marshmallow import validate +from marshmallow_utils.fields import ISOLangString + +RDM_NAMESPACES = { + "imperial": "https://www.imperial.ac.uk", +} + +RDM_CUSTOM_FIELDS = [ + TextCF( + name="imperial:contact_information", + field_cls=ISOLangString, + field_args={ + # must be an implementation of Marshmallow.validate.Validator + "validate": validate.Email(), + }, + multiple=False, + ), +] + +RDM_CUSTOM_FIELDS_UI = [ + { + "section": "Contact information", + "fields": [ + dict( + field="imperial:contact_information", + ui_widget="Input", + template="contact_information.html", + props=dict( + label="Contact information", + placeholder="name@imperial.ic.uk", + icon="address card outline", + description="Please provide an email for contact information.", + # True for autocomplete dropdowns with search functionality + search=False, + multiple=False, # True for selecting multiple values + clearable=True, + ), + ) + ], + } +] diff --git a/site/ic_data_repo/config/settings.py b/site/ic_data_repo/config/settings.py index addff47..d274a8f 100644 --- a/site/ic_data_repo/config/settings.py +++ b/site/ic_data_repo/config/settings.py @@ -11,6 +11,8 @@ from invenio_oauthclient.views.client import auto_redirect_login +from .custom_fields import * # noqa + # Flask # ===== # See https://flask.palletsprojects.com/en/1.1.x/config/ diff --git a/site/ic_data_repo/templates/contact_information.html b/site/ic_data_repo/templates/contact_information.html new file mode 100644 index 0000000..085ec26 --- /dev/null +++ b/site/ic_data_repo/templates/contact_information.html @@ -0,0 +1 @@ +{{field_value}}