Skip to content

Commit

Permalink
modification: resource type translate
Browse files Browse the repository at this point in the history
  • Loading branch information
philippgualdi committed Sep 27, 2023
1 parent 33b71ae commit eb0a81c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
9 changes: 9 additions & 0 deletions invenio_records_marc21/records/fields/resourcetype.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from enum import Enum


class ResourceTypeEnum(Enum):
"""Enum defining resource type."""

HSMASTER = "HS-MASTER"

HSDISS = "HS-DISS"
16 changes: 13 additions & 3 deletions invenio_records_marc21/resources/serializers/ui/fields/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
# details.

"""Metadata field for marc21 records."""

import re
from contextlib import suppress
from dataclasses import dataclass
from typing import Dict, List

from flask_babelex import gettext as _
from marshmallow.fields import Field

from .....records.fields.resourcetype import ResourceTypeEnum


class Marc21Controlfield:
"""Marc21Controlfield."""
Expand Down Expand Up @@ -215,8 +219,14 @@ def get_description(self, fields):
def get_resource_type(self, fields):
"""Get resource type."""
resource_type = fields.get_values("970", "2", "_", subfield_notation="d")
resource_types = {
ResourceTypeEnum.HSMASTER.value: _("Masterthesis"),
ResourceTypeEnum.HSDISS.value: _("Dissertation"),
}

if resource_type:
return resource_type[0]
if not resource_type:
return ""
if resource_type[0] in resource_types.keys():
return resource_types.get(resource_type[0])

return ""
return resource_type[0]

0 comments on commit eb0a81c

Please sign in to comment.