Skip to content

Commit

Permalink
updated DataCiteMetadata.build_codebase_metadata(): added description…
Browse files Browse the repository at this point in the history
…, default publication year to this year if none, updated identifier and creators fields (comses/comses.net/comses#699)
  • Loading branch information
monaw committed May 25, 2024
1 parent ef94073 commit f0d0bea
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions django/library/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
}
]
Expand All @@ -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"
Expand Down

0 comments on commit f0d0bea

Please sign in to comment.