Skip to content

Commit

Permalink
Basic custom contact information
Browse files Browse the repository at this point in the history
  • Loading branch information
J4bbi committed Oct 29, 2024
1 parent 3e54d82 commit a56694a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
42 changes: 42 additions & 0 deletions site/ic_data_repo/config/custom_fields.py
Original file line number Diff line number Diff line change
@@ -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="[email protected]",
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,
),
)
],
}
]
2 changes: 2 additions & 0 deletions site/ic_data_repo/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
1 change: 1 addition & 0 deletions site/ic_data_repo/templates/contact_information.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{field_value}}

0 comments on commit a56694a

Please sign in to comment.