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 2a4caf6
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
40 changes: 40 additions & 0 deletions site/ic_data_repo/config/custom_fields.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from invenio_records_resources.services.custom_fields import TextCF
from marshmallow_utils.fields import ISOLangString
from marshmallow import validate

RDM_NAMESPACES = {
"imperial": "https://www.imperial.ac.uk",
}

RDM_CUSTOM_FIELDS = [
TextCF(
name="imperial:contact_information",
field_cls=ISOLangString,
field_args={
"validate": validate.Email(), # must be an implementation of Marshmallow.validate.Validator
},
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.",
search=False, # True for autocomplete dropdowns with search functionality
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 @@ -10,6 +10,8 @@
from datetime import datetime

from invenio_oauthclient.views.client import auto_redirect_login
from .custom_fields import *


# Flask
# =====
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 2a4caf6

Please sign in to comment.