55
66"""UI community schema."""
77
8- from functools import partial
9-
108from flask import g
119from flask_resources import BaseObjectSchema
1210from idutils import detect_identifier_schemes , to_url
1311from invenio_i18n import get_locale
1412from invenio_i18n import lazy_gettext as _
13+ from invenio_records_resources .proxies import current_custom_fields_schema_registry
1514from invenio_records_resources .services .custom_fields import CustomFieldsSchemaUI
1615from invenio_vocabularies .contrib .awards .serializer import AwardL10NItemSchema
1716from invenio_vocabularies .contrib .funders .serializer import FunderL10NItemSchema
1817from invenio_vocabularies .resources import VocabularyL10Schema
1918from marshmallow import Schema , fields , post_dump
20- from marshmallow_utils .fields import FormatEDTF as FormatEDTF_
19+ from marshmallow_utils .fields import FormatEDTF
2120
2221from invenio_communities .communities .schema import CommunityThemeSchema
2322from invenio_communities .proxies import current_communities
@@ -57,10 +56,6 @@ def mask_removed_by(obj):
5756 return return_value
5857
5958
60- # Partial to make short definitions in below schema.
61- FormatEDTF = partial (FormatEDTF_ , locale = get_locale )
62-
63-
6459class TombstoneSchema (Schema ):
6560 """Schema for a record tombstone."""
6661
@@ -70,9 +65,13 @@ class TombstoneSchema(Schema):
7065
7166 removed_by = fields .Function (mask_removed_by )
7267
73- removal_date_l10n_medium = FormatEDTF (attribute = "removal_date" , format = "medium" )
68+ removal_date_l10n_medium = FormatEDTF (
69+ attribute = "removal_date" , format = "medium" , locale = get_locale
70+ )
7471
75- removal_date_l10n_long = FormatEDTF (attribute = "removal_date" , format = "long" )
72+ removal_date_l10n_long = FormatEDTF (
73+ attribute = "removal_date" , format = "long" , locale = get_locale
74+ )
7675
7776 citation_text = fields .String (attribute = "citation_text" )
7877
@@ -106,7 +105,9 @@ class UICommunitySchema(BaseObjectSchema):
106105
107106 # Custom fields
108107 custom_fields = fields .Nested (
109- partial (CustomFieldsSchemaUI , fields_var = "COMMUNITIES_CUSTOM_FIELDS" )
108+ lambda : current_custom_fields_schema_registry .get (
109+ "COMMUNITIES_CUSTOM_FIELDS" , CustomFieldsSchemaUI .field_property_name
110+ )
110111 )
111112
112113 permissions = fields .Method ("get_permissions" , dump_only = True )
0 commit comments