diff --git a/django/library/models.py b/django/library/models.py index 6be5e42a5..ec0e01408 100644 --- a/django/library/models.py +++ b/django/library/models.py @@ -7,7 +7,7 @@ from typing import List import uuid from collections import OrderedDict -from datetime import timedelta +from datetime import datetime, timedelta import semver from django.conf import settings @@ -2633,10 +2633,11 @@ def build_codebase_metadata(cls, codebase: Codebase): metadata = {} # FIXME: set more codebase attributes??? # https://support.datacite.org/docs/what-is-the-identifiers-attribute-in-the-rest-api + # future consideration: adding references_text and associated_publication_text fields when more info for those fiels are added metadata["identifiers"] = [ { - "identifierType": "URL", + "identifierType": "DOI", # only "DOI" allowed according to DataCite schema "identifier": codebase.permanent_url, } ] @@ -2650,21 +2651,34 @@ def build_codebase_metadata(cls, codebase: Codebase): ) # FIXME: creators should never be empty! + # FIXME: when additional info is available for codebase creator, update this metadata["creators"] = [ - {"name": author_string_name} for author_string_name in codebase.author_list + {"name": author_string_name, "creatorType": "Personal"} + for author_string_name in codebase.author_list ] metadata["titles"] = [{"title": codebase.title}] + metadata["descriptions"] = [ + { + "description": codebase.summarized_description, + "descriptionType": "Abstract", + } + ] # or codebase.description.raw? # FIXME: include more info! metadata["publisher"] = str( f'{CommonMetadata.COMSES_ORGANIZATION["name"]} {CommonMetadata.COMSES_ORGANIZATION["url"]}' ) + + # Use this year if no publication year found + currentDateTime = datetime.now() + date = currentDateTime.date() + year = date.strftime("%Y") metadata["publicationYear"] = str( codebase.first_published_at.year if codebase is not None and codebase.first_published_at is not None and codebase.first_published_at.year is not None - else None + else year ) metadata["types"] = {"resourceType": "Model", "resourceTypeGeneral": "Software"} metadata["schemaVersion"] = "http://datacite.org/schema/kernel-4"