Skip to content

Commit

Permalink
Merge branch 'hotfix/0.7.2' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
rlskoeser committed Feb 16, 2022
2 parents 1c388b5 + dd8db40 commit 2752ea5
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
=========

0.7.2
-----

* Include manifest attribution information in `extra_data` on import


0.7.1
-----

Expand Down
2 changes: 1 addition & 1 deletion djiffy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
default_app_config = 'djiffy.apps.DjiffyConfig'

__version_info__ = (0, 7, 1, None)
__version_info__ = (0, 7, 2, None)


# Dot-connect all but the last. Last is dash-connected if not None.
Expand Down
3 changes: 2 additions & 1 deletion djiffy/fixtures/chto-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -895,5 +895,6 @@
"format": "application/ld+json"
},
"license": "http://rightsstatements.org/vocab/NKC/1.0/",
"logo": "https://example.com/logo.png"
"logo": "https://example.com/logo.png",
"attribution": "Created by a person"
}
4 changes: 2 additions & 2 deletions djiffy/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ def import_manifest(self, manifest, path):
response = get_iiif_url(url)
db_manifest.extra_data[url] = response.json()

# also check for logo and license and add to extra data
for field in ['logo', 'license']:
# also check for logo, license, and attribution and add to extra data
for field in ['logo', 'license', 'attribution']:
if hasattr(manifest, field):
db_manifest.extra_data[field] = getattr(manifest, field)

Expand Down
5 changes: 5 additions & 0 deletions djiffy/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ def logo(self):
'''manifest logo, if there is one'''
return self.extra_data.get('logo', None)

@property
def attribution(self):
'''manifest attribution, if there is one'''
return self.extra_data.get('attribution', None)

@property
def license(self):
'''manifest license, if there is one'''
Expand Down
12 changes: 10 additions & 2 deletions djiffy/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ def test_license(self):
book.extra_data['license'] = 'http://rightsstatements.org/vocab/InC/1.0/'
assert book.license == book.extra_data['license']

def test_attribution(self):
book = Manifest(short_id='bk123')
assert book.attribution is None

book.extra_data['attribution'] = 'Created by a person'
assert book.attribution == book.extra_data['attribution']

def test_rights_statement_id(self):
book = Manifest(short_id='bk123')
assert book.rights_statement_id is None
Expand Down Expand Up @@ -481,9 +488,10 @@ def test_import_manifest(self, mock_getiiifurl):
assert manif.extra_data[pres.seeAlso.id] == mock_extra_data
assert mock_getiiifurl.called_with(pres.seeAlso.id)
assert mock_getiiifurl.return_value.json.called_with()
# license & logo available
# license, logo, & attribution available
assert manif.license == "http://rightsstatements.org/vocab/NKC/1.0/"
assert manif.logo == "https://example.com/logo.png"
assert manif.attribution == "Created by a person"

assert len(manif.canvases.all()) == len(pres.sequences[0].canvases)
assert manif.thumbnail.iiif_image_id == \
Expand Down Expand Up @@ -539,7 +547,7 @@ def test_import_manifest(self, mock_getiiifurl):
manif.delete()
del pres.seeAlso
manif = self.importer.import_manifest(pres, self.test_manifest)
assert set(manif.extra_data.keys()) == set(['logo', 'license'])
assert set(manif.extra_data.keys()) == set(['logo', 'license', 'attribution'])

# unsupported type won't import
pres.id = 'http://some.other/uri'
Expand Down

0 comments on commit 2752ea5

Please sign in to comment.