Skip to content

Commit af28216

Browse files
[ENG-7799] Update authors' names format in metadata (#11091)
## Purpose In metadata we return authors' names as full names. We should use this format instead: "{family name}, {given name}" Also added givenName and familyName in JSON-LD schema ## Changes Updated function that generates names, added `given_name` attribute when serialize contributors in mako templates ## Ticket https://openscience.atlassian.net/browse/ENG-7799
1 parent 9fb209e commit af28216

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

osf/metadata/serializers/google_dataset_json_ld.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,12 @@ def metadata_as_dict(self) -> dict:
7676

7777
def format_creators(basket):
7878
creator_data = []
79-
for creator_iri in basket[DCTERMS.creator]:
79+
for creator in basket.focus.dbmodel.contributors.all():
8080
creator_data.append({
8181
'@type': 'Person',
82-
'name': next(basket[creator_iri:FOAF.name]),
82+
'name': creator.fullname,
83+
'givenName': creator.given_name,
84+
'familyName': creator.family_name
8385
})
8486
return creator_data
8587

website/profile/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def serialize_user(user, node=None, admin=False, full=False, is_profile=False, i
3131
'id': str(user._id),
3232
'registered': user.is_registered,
3333
'surname': user.family_name,
34+
'given_name': user.given_name,
3435
'fullname': fullname,
3536
'shortname': fullname if len(fullname) < 50 else fullname[:23] + '...' + fullname[-23:],
3637
'profile_image_url': user.profile_image_url(size=settings.PROFILE_IMAGE_MEDIUM),

website/templates/base.mako

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@
7575
<meta property="og:image:height" content="630" />
7676
<meta property="og:image:alt" content="OSF" />
7777
78-
%for author in self.authors_meta()[:10]:
79-
<meta name="dc.creator" content="${author}" />
78+
%for author, creator in list(zip(self.authors_meta()[:10], self.creator_meta()[:10])):
79+
<meta name="dc.creator" content="${creator}" />
8080
<meta name="citation_author" content="${author}" />
8181
%endfor
8282
%for tag in self.keywords_meta()[:10]:
@@ -329,6 +329,10 @@
329329
### The list of project contributors ###
330330
</%def>
331331

332+
<%def name="creator_meta()">
333+
### The list of project creators ###
334+
</%def>
335+
332336
<%def name="datemodified_meta()">
333337
### The project last modified date.
334338
</%def>

website/templates/project/project_base.mako

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@
6969
</%def>
7070

7171
<%def name="authors_meta()">
72+
%if node['contributors'] and not node['anonymous']:
73+
<%
74+
return [f'{contrib['surname']}, {contrib['given_name']}'for contrib in node['contributors'] if isinstance(contrib, dict)]
75+
%>
76+
%endif
77+
</%def>
78+
79+
<%def name="creator_meta()">
7280
%if node['contributors'] and not node['anonymous']:
7381
<%
7482
return [contrib['fullname'] for contrib in node['contributors'] if isinstance(contrib, dict)]

0 commit comments

Comments
 (0)