-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d096879
commit 86c92b7
Showing
3 changed files
with
170 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# | ||
# Copyright (C) 2023 CERN. | ||
# | ||
# Invenio-RDM-Records is free software; you can redistribute it and/or modify | ||
# it under the terms of the MIT License; see LICENSE file for more details. | ||
"""Meeting contrib module.""" | ||
from .custom_fields import ( | ||
MEETING_CUSTOM_FIELDS, | ||
MEETING_CUSTOM_FIELDS_UI, | ||
MEETING_NAMESPACE, | ||
) | ||
|
||
__all__ = (MEETING_CUSTOM_FIELDS, MEETING_CUSTOM_FIELDS_UI, MEETING_NAMESPACE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
# | ||
# Copyright (C) 2023 CERN. | ||
# | ||
# Invenio-RDM-Records is free software; you can redistribute it and/or modify | ||
# it under the terms of the MIT License; see LICENSE file for more details. | ||
"""Meeting custom fields. | ||
Implements the following fields: | ||
- meeting.acronym | ||
- meeting.dates | ||
- meeting.place | ||
- meeting.session_part | ||
- meeting.session | ||
- meeting.title | ||
- meeting.url | ||
""" | ||
|
||
from invenio_i18n import lazy_gettext as _ | ||
from invenio_records_resources.services.custom_fields import BaseCF | ||
from marshmallow import fields, validate | ||
from marshmallow_utils.fields import SanitizedUnicode | ||
|
||
from invenio_rdm_records.services.schemas.metadata import _valid_url | ||
|
||
|
||
class MeetingCF(BaseCF): | ||
"""Nested custom field.""" | ||
|
||
@property | ||
def field(self): | ||
"""Meeting fields definitions.""" | ||
return fields.Nested( | ||
{ | ||
"acronym": SanitizedUnicode(), | ||
"dates": SanitizedUnicode(), | ||
"place": SanitizedUnicode(), | ||
"session_part": SanitizedUnicode(), | ||
"session": SanitizedUnicode(), | ||
"title": SanitizedUnicode(), | ||
"url": SanitizedUnicode( | ||
validate=_valid_url(error_msg="You must provide a valid URL."), | ||
), | ||
} | ||
) | ||
|
||
@property | ||
def mapping(self): | ||
"""Meeting search mappings.""" | ||
return { | ||
"type": "object", | ||
"properties": { | ||
"acronym": {"type": "keyword"}, | ||
"dates": {"type": "keyword"}, | ||
"place": {"type": "text"}, | ||
"session_part": {"type": "keyword"}, | ||
"session": {"type": "keyword"}, | ||
"title": {"type": "text"}, | ||
"url": {"type": "keyword"}, | ||
}, | ||
} | ||
|
||
|
||
MEETING_NAMESPACE = { | ||
# Meeting | ||
"meeting": "", | ||
} | ||
|
||
|
||
MEETING_CUSTOM_FIELDS = [ | ||
MeetingCF(name="meeting:meeting"), | ||
] | ||
|
||
MEETING_CUSTOM_FIELDS_UI = { | ||
"section": _("Conference"), | ||
"fields": [ | ||
{ | ||
"field": "meeting:meeting", | ||
"ui_widget": "Meeting", | ||
"template": "meeting.html", | ||
"props": { | ||
"label": _("Conference"), | ||
"title": { | ||
"label": _("Conference title"), | ||
"placeholder": _(""), | ||
"description": _("Conference title"), | ||
}, | ||
"acronym": { | ||
"label": _("Acronym"), | ||
"placeholder": _(""), | ||
"description": _("Acronym that represents the conference"), | ||
}, | ||
"dates": { | ||
"label": _("Dates"), | ||
"placeholder": _("e.g. 21-22 November 2022"), | ||
"description": _("Dates on which the conference took place"), | ||
}, | ||
"place": { | ||
"label": _("Place"), | ||
"placeholder": _(""), | ||
"description": _("Location where the conference took place"), | ||
}, | ||
"url": { | ||
"label": _("Website"), | ||
"placeholder": _(""), | ||
"description": _("e.g. https://zenodo.org"), | ||
}, | ||
"session": { | ||
"label": _("Session"), | ||
"placeholder": _("e.g. VI"), | ||
"description": _("Number of session within the conference."), | ||
}, | ||
"session_part": { | ||
"label": _("Part"), | ||
"placeholder": _("e.g. 1"), | ||
"description": _("Conference session's part number."), | ||
}, | ||
}, | ||
} | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
|
||
{% if field_value.get('title') %} | ||
<dt class="ui tiny header">{{ _("Title")}}</dt> | ||
<dd>{{field_value.get('title')}}</dd> | ||
{% endif %} | ||
|
||
{% if field_value.get('acronym') %} | ||
<dt class="ui tiny header">{{ _("Acronym")}}</dt> | ||
<dd>{{field_value.get('acronym')}}</dd> | ||
{% endif %} | ||
|
||
{% if field_value.get('dates') %} | ||
<dt class="ui tiny header">{{ _("Dates")}}</dt> | ||
<dd>{{field_value.get('dates')}}</dd> | ||
{% endif %} | ||
|
||
{% if field_value.get('place') %} | ||
<dt class="ui tiny header">{{ _("Place")}}</dt> | ||
<dd>{{field_value.get('place')}}</dd> | ||
{% endif %} | ||
|
||
{% if field_value.get('url') %} | ||
<dt class="ui tiny header">{{ _("Website")}}</dt> | ||
<dd>{{field_value.get('url')}}</dd> | ||
{% endif %} | ||
|
||
{% if field_value.get('session') %} | ||
<dt class="ui tiny header">{{ _("Session")}}</dt> | ||
<dd>{{field_value.get('session')}}</dd> | ||
{% endif %} | ||
|
||
{% if field_value.get('session_part') %} | ||
<dt class="ui tiny header">{{ _("Session part")}}</dt> | ||
<dd>{{field_value.get('session_part')}}</dd> | ||
{% endif %} |