Skip to content

Commit

Permalink
Fix EUDAT extended updated field
Browse files Browse the repository at this point in the history
  • Loading branch information
Janne Karjalainen committed Oct 6, 2021
1 parent f8bd865 commit c90c360
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions b2share/modules/records/serializers/schemas/eudatextended.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .eudatcore import EudatCoreSchema
from lxml import etree
from .dc import record_url

from datetime import datetime

def add_affiliations(source, target):
if source.get('affiliations', []):
Expand Down Expand Up @@ -116,6 +116,7 @@ def contributors(self, metadata, root):
root.append(contributors)

def dates(self, obj, root):
from dateutil import parser
metadata = obj['metadata']
dates = E.dates()
if 'dates' in metadata:
Expand All @@ -125,8 +126,9 @@ def dates(self, obj, root):
date.set('dateInformation', d['date_information'])
dates.append(date)
dates.append(E.date(obj['created'],dateType='Created', dateInformation='Creation'))
if obj['updated'] > obj['created']:
dates.append(E.date(obj['updated'],dateType='Updated', dateInformation='Updated with latest properties'))
d = parser.parse(obj['updated']) - parser.parse(obj['created'])
if d.days > 0:
dates.append(E.date(obj['updated'], dateType='Updated', dateInformation='Updated with latest properties'))
root.append(dates)

def resource_types(self, metadata, root):
Expand Down

0 comments on commit c90c360

Please sign in to comment.