Skip to content

Commit

Permalink
Merge dff3433 into 372253d
Browse files Browse the repository at this point in the history
  • Loading branch information
slint committed Oct 8, 2020
2 parents 372253d + dff3433 commit 9486f28
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
4 changes: 3 additions & 1 deletion tests/unit/records/test_schemas_csl.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ def test_full(db, full_record, recid_pid):
"page": "20",
"container_title": "Bam",
"id": "123",
"ISSN": "0317-8471"
"ISSN": "0317-8471",
"event": "The 13th Biennial HITRAN Conference (HITRAN13)",
"event-place": "Harvard-Smithsonian Center for Astrophysics",
}


Expand Down
9 changes: 8 additions & 1 deletion tests/unit/records/test_schemas_schemaorg_jsonld.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,14 @@ def test_full_record(record_with_files_creation):
u'name': u'my place'
}, {
'@type': 'Place', 'name': 'New York'
}]
}],
u'workFeatured': {
u'@type': u'Event',
u'name': u'The 13th Biennial HITRAN Conference',
u'alternateName': u'HITRAN13',
u'location': u'Harvard-Smithsonian Center for Astrophysics',
u'url': u'http://hitran.org/conferences/hitran-13-2014/',
},
}
assert data == expected

Expand Down
20 changes: 20 additions & 0 deletions zenodo/modules/records/serializers/schemas/csl.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,26 @@ class RecordSchemaCSLJSON(Schema):
publisher = fields.Method('get_publisher')
publisher_place = fields.Str(attribute='metadata.imprint.place')

event = fields.Method('get_event')
event_place = fields.Str(
attribute='metadata.meeting.place', dump_to='event-place')
# TODO: check if possible to dump in EDTF format
# event_date = fields.Str(
# attribute='metadata.meeting.dates', dump_to='event-date')

def get_event(self, obj):
"""Get event/meeting title and acronym."""
m = obj['metadata']
meeting = m.get('meeting', {})
if meeting:
title = meeting.get('title')
acronym = meeting.get('acronym')
if title and acronym:
return u'{} ({})'.format(title, acronym)
elif title or acronym:
return title or acronym
return missing

def get_journal_or_part_of(self, obj, key):
"""Get journal or part of."""
m = obj['metadata']
Expand Down
14 changes: 13 additions & 1 deletion zenodo/modules/records/serializers/schemas/schemaorg.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ def get_geo(self, obj):
return missing


class MeetingEvent(Schema):
"""Schema for Meeting event."""

type_ = fields.Constant('Event', dump_to='@type')
name = fields.Str(attribute='title')
alternateName = fields.Str(attribute='acronym')
location = fields.Str(attribute='place')
url = fields.Str()


class CreativeWork(Schema):
"""Schema for schema.org/CreativeWork type."""

Expand All @@ -145,7 +155,7 @@ class CreativeWork(Schema):

temporal = fields.Method('get_dates')

# NOTE: could also be "author"
# NOTE: could also be "author"
creator = fields.Nested(Person, many=True, attribute='metadata.creators')

version = SanitizedUnicode(attribute='metadata.version')
Expand All @@ -165,6 +175,8 @@ class CreativeWork(Schema):
contributor = fields.Nested(
Person, many=True, attribute='metadata.contributors')

workFeatured = fields.Nested(MeetingEvent, attribute='metadata.meeting')

# NOTE: editor from "contributors"?
# editor

Expand Down

0 comments on commit 9486f28

Please sign in to comment.