Skip to content

Commit

Permalink
Merge d149892 into 8501f84
Browse files Browse the repository at this point in the history
  • Loading branch information
kimakan committed Apr 27, 2023
2 parents 8501f84 + d149892 commit a2293d2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
2 changes: 1 addition & 1 deletion daiquiri/datalink/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def get_context_data(self, request, **kwargs):
context = {}

if 'ID' in kwargs:
context['datalinks'] = Datalink.objects.filter(ID=kwargs['ID'])
context['datalinks'] = Datalink.objects.filter(ID=kwargs['ID']).order_by('semantics')
context['ID'] = kwargs['ID']

return context
Expand Down
38 changes: 34 additions & 4 deletions daiquiri/oai/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,12 @@ def get_datalink(self, pk):

datalink = {
'formats': [],
'alternate_identifiers': [],
'alternate_identifiers': [
{
'alternate_identifier': pk,
'alternate_identifier_type': 'datalink'
}
],
'related_identifiers': []
}
for access_url, description, semantics, content_type, content_length in rows:
Expand All @@ -246,20 +251,45 @@ def get_datalink(self, pk):
datalink['title'] = description

elif semantics == '#this':
datalink['formats'].append(content_type)
if content_type not in datalink['formats']:
datalink['formats'].append(content_type)
datalink['related_identifiers'].append({
'related_identifier': access_url,
'related_identifier_type': 'URL',
'relation_type': 'IsDescribedBy'
})

elif semantics == '#detached-header':
if content_type not in datalink['formats']:
datalink['formats'].append(content_type)
datalink['related_identifiers'].append({
'related_identifier': access_url,
'related_identifier_type': 'URL',
'relation_type': 'IsSupplementedBy'
})

elif semantics == '#documentation':
datalink['alternate_identifiers'].append({
'alternate_identifier': access_url,
'alternate_identifier_type': 'URL'
'related_identifier': access_url,
'related_identifier_type': 'URL',
'relation_type': 'IsDocumentedBy'
})

elif semantics == '#progenitor':
datalink['related_identifiers'].append({
'related_identifier': access_url,
'related_identifier_type': 'URL',
'relation_type': 'IsDerivedFrom'
})

elif semantics == '#preview':
datalink['related_identifiers'].append({
'related_identifier': access_url,
'related_identifier_type': 'URL',
'relation_type': 'IsDescribedBy'
})

elif semantics == '#preview-image':
datalink['related_identifiers'].append({
'related_identifier': access_url,
'related_identifier_type': 'URL',
Expand Down

0 comments on commit a2293d2

Please sign in to comment.