Skip to content

Commit

Permalink
Feature/custom fields (#27)
Browse files Browse the repository at this point in the history
This PR adds 115 custom fields using the `mex:` namespace.

These custom fields are derived from the
[3.4.0](https://github.com/robert-koch-institut/mex-model/releases/tag/3.4.0)
version of the MEx metadata model.

There is some validation implemented using little effort but this should
not be required as incoming data will already have been validated using
the model.

The `mex:identifier`  field is the only `required` custom field.

The [resource
types](https://inveniordm.docs.cern.ch/customize/vocabularies/resource_types/)
vocabulary has been replaced with 11 MEx entity types. Please verify
that these are the correct entity types.

The custom nested field class `MultiLanguageTextCF` is modelled on the
MEx
[text](https://github.com/robert-koch-institut/mex-model/blob/main/mex/model/fields/text.json)
field.

### Templates
Three templates has been amended, `records/detail.html` which includes
`records/details/mex_details.html` and `records/macros/mex_detail.html`
only in order to list custom fields the same way Datacite fields are
listed by default on the landing page.

The templates have also been changed to not expect a `props` property
defined in the `RDM_CUSTOM_FIELDS_UI` config variable. In other words,
if these amended templates were not used, Jinja would throw an error
expecting each field in that config variable to have a `props` property
set.

## Unresolved
This PR does not have unit tests. They are coming soon in a PR for
importing data.

There are still decisions to be made on the searchability of these
custom fields, if and then how they are searched on or faceted.
  • Loading branch information
J4bbi authored Jan 22, 2025
1 parent b0eaf3b commit 8eca25b
Show file tree
Hide file tree
Showing 9 changed files with 1,441 additions and 13 deletions.
5 changes: 4 additions & 1 deletion app_data/vocabularies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ subjects:
# TODO: Uncomment this if you want to have all affiliations with ROR identifiers.
# affiliations:
# pid-type: aff
# data-file: vocabularies/affiliations_ror.yaml
# data-file: vocabularies/affiliations_ror.yaml
resourcetypes:
pid-type: rsrct
data-file: vocabularies/resource_types.yaml
116 changes: 116 additions & 0 deletions app_data/vocabularies/resource_types.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# These are 11 MEx entity types
# https://github.com/robert-koch-institut/mex-model/tree/main/mex/model/entities
# they replace the Datacite 4.3 resource types
# https://github.com/inveniosoftware/invenio-rdm-records/blob/master/invenio_rdm_records/fixtures/data/vocabularies/resource_types.yaml
# For more information:
# https://inveniordm.docs.cern.ch/customize/vocabularies/resource_types/
- id: variable
icon: code
title:
en: Variable
props:
type: variable
subtype: ""
tags:
- depositable
- linkable
- id: resource
icon: code
title:
en: Resource
props:
type: resource
subtype: ""
tags:
- depositable
- linkable
- id: activity
icon: code
title:
en: Activity
props:
type: activity
subtype: ""
tags:
- depositable
- linkable
- id: accessplatform
icon: code
title:
en: Access platform
props:
type: accessplatform
subtype: ""
tags:
- depositable
- linkable
- id: distribution
icon: code
title:
en: Distribution
props:
type: distribution
subtype: ""
tags:
- depositable
- linkable
- id: organizationalunit
icon: code
title:
en: Organizational unit
props:
type: organizationalunit
subtype: ""
tags:
- depositable
- linkable
- id: contactpoint
icon: code
title:
en: Contact point
props:
type: contactpoint
subtype: ""
tags:
- depositable
- linkable
- id: person
icon: code
title:
en: Person
props:
type: person
subtype: ""
tags:
- depositable
- linkable
- id: variablegroup
icon: code
title:
en: Variable group
props:
type: variablegroup
subtype: ""
tags:
- depositable
- linkable
- id: bibliographicresource
icon: code
title:
en: Bibliographic resource
props:
type: bibliographicresource
subtype: ""
tags:
- depositable
- linkable
- id: organization
icon: code
title:
en: Organization
props:
type: organization
subtype: ""
tags:
- depositable
- linkable
23 changes: 11 additions & 12 deletions site/mex_invenio/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
from datetime import datetime
from invenio_i18n import lazy_gettext as _

from mex_invenio.custom_fields.custom_fields import RDM_NAMESPACES, RDM_CUSTOM_FIELDS, RDM_CUSTOM_FIELDS_UI


def _(x): # needed to avoid start time failure with lazy strings
return x


# Flask
# =====
# See https://flask.palletsprojects.com/en/1.1.x/config/
Expand All @@ -26,22 +30,20 @@ def _(x): # needed to avoid start time failure with lazy strings
# SECURITY WARNING: keep the secret key used in production secret!
# Do not commit it to a source code repository.
# TODO: Set
SECRET_KEY="CHANGE_ME"
SECRET_KEY = "CHANGE_ME"

# Since HAProxy and Nginx route all requests no matter the host header
# provided, the allowed hosts variable is set to localhost. In production it
# should be set to the correct host and it is strongly recommended to only
# route correct hosts to the application.
APP_ALLOWED_HOSTS = ['0.0.0.0', 'localhost', '127.0.0.1']


# Flask-SQLAlchemy
# ================
# See https://flask-sqlalchemy.palletsprojects.com/en/2.x/config/

# TODO: Set
SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://mex-invenio:mex-invenio@localhost/mex-invenio"

SQLALCHEMY_DATABASE_URI = "postgresql+psycopg2://mex-invenio:mex-invenio@localhost/mex-invenio"

# Invenio-App
# ===========
Expand All @@ -51,9 +53,9 @@ def _(x): # needed to avoid start time failure with lazy strings
'content_security_policy': {
'default-src': [
"'self'",
'data:', # for fonts
'data:', # for fonts
"'unsafe-inline'", # for inline scripts and styles
"blob:", # for pdf preview
"blob:", # for pdf preview
# Add your own policies here (e.g. analytics)
],
},
Expand All @@ -72,7 +74,6 @@ def _(x): # needed to avoid start time failure with lazy strings
'strict_transport_security_preload': False,
}


# Flask-Babel
# ===========
# See https://python-babel.github.io/flask-babel/#configuration
Expand All @@ -82,7 +83,6 @@ def _(x): # needed to avoid start time failure with lazy strings
# Default time zone
BABEL_DEFAULT_TIMEZONE = 'Europe/Zurich'


# Invenio-I18N
# ============
# See https://invenio-i18n.readthedocs.io/en/latest/configuration.html
Expand All @@ -93,7 +93,6 @@ def _(x): # needed to avoid start time failure with lazy strings
# ('tr', _('Turkish')),
]


# Invenio-Theme
# =============
# See https://invenio-theme.readthedocs.io/en/latest/configuration.html
Expand All @@ -105,7 +104,6 @@ def _(x): # needed to avoid start time failure with lazy strings
# Header logo
THEME_LOGO = 'images/invenio-rdm.svg'


# Invenio-App-RDM
# ===============
# See https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/config.py
Expand Down Expand Up @@ -133,7 +131,7 @@ def _(x): # needed to avoid start time failure with lazy strings
"publisher": "mex-invenio",
}

APP_RDM_DEPOSIT_FORM_AUTOCOMPLETE_NAMES = 'search' # "search_only" or "off"
APP_RDM_DEPOSIT_FORM_AUTOCOMPLETE_NAMES = 'search' # "search_only" or "off"

# Invenio-Records-Resources
# =========================
Expand Down Expand Up @@ -166,7 +164,7 @@ def _(x): # needed to avoid start time failure with lazy strings
SECURITY_RECOVERABLE = True # local login: allow users to reset the password
SECURITY_CHANGEABLE = True # local login: allow users to change psw
SECURITY_CONFIRMABLE = True # local login: users can confirm e-mail address
SECURITY_LOGIN_WITHOUT_CONFIRMATION = False # require users to confirm email before being able to login
SECURITY_LOGIN_WITHOUT_CONFIRMATION = False # require users to confirm email before being able to login

# Invenio-OAuthclient
# -------------------
Expand All @@ -175,6 +173,7 @@ def _(x): # needed to avoid start time failure with lazy strings
OAUTHCLIENT_REMOTE_APPS = {} # configure external login providers

from invenio_oauthclient.views.client import auto_redirect_login

ACCOUNTS_LOGIN_VIEW_FUNCTION = auto_redirect_login # autoredirect to external login if enabled
OAUTHCLIENT_AUTO_REDIRECT_TO_EXTERNAL_LOGIN = False # autoredirect to external login

Expand Down
Empty file.
Loading

0 comments on commit 8eca25b

Please sign in to comment.