Skip to content

Commit

Permalink
IIIF adaptions and test SQL
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderWatzinger committed Oct 29, 2023
1 parent 9936957 commit 704fe8f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
7 changes: 7 additions & 0 deletions install/data_test.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@ INSERT INTO web.user_log (user_id, entity_id, action) VALUES (2, 6666, 'insert')
-- Needed to test external reference systems for hierarchies
INSERT INTO web.reference_system_openatlas_class (reference_system_id, openatlas_class_name) VALUES
((SELECT entity_id FROM web.reference_system WHERE name='Wikidata'), 'type');

-- IIIF activation
UPDATE web.settings SET value = 'True' WHERE name = 'iiif';
UPDATE web.settings SET value = '/var/www/iipsrv'WHERE name = 'iiif_path';
UPDATE web.settings SET value = 'http://localhost/iiif/'WHERE name = 'iiif_url';
UPDATE web.settings SET value = '2' WHERE name = 'iiif_version';
UPDATE web.settings SET value = 'deflate' WHERE name = 'iiif_conversion';
6 changes: 3 additions & 3 deletions openatlas/api/endpoints/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ def get() -> Union[tuple[Resource, int], Response]:
app.config['IMAGE_SIZE']
if g.settings['image_processing'] else None},
'IIIF': {
'enabled': app.config['IIIF']['enabled'],
'url': app.config['IIIF']['url'],
'version': app.config['IIIF']['version']}}
'enabled': g.settings['iiif'],
'url': g.settings['iiif_url'],
'version': int(g.settings['iiif_version'])}}
if parser['download']:
download(details, backend_details_template(), 'content')
return marshal(details, backend_details_template()), 200
Expand Down
18 changes: 9 additions & 9 deletions openatlas/api/endpoints/display_image.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
from pathlib import Path as Pathlib_path
from typing import Any

from flask import Response, send_file, url_for
from flask import Response, g, send_file, url_for
from flask_restful import Resource, marshal

from openatlas import app
from openatlas.api.resources.error import DisplayFileNotFoundError, \
NoLicenseError
from openatlas.api.resources.parser import image, files
from openatlas.api.resources.error import (
DisplayFileNotFoundError, NoLicenseError)
from openatlas.api.resources.model_mapper import (
get_entities_by_ids, get_entities_by_system_classes, get_entity_by_id)
from openatlas.api.resources.parser import files, image
from openatlas.api.resources.templates import licensed_file_template
from openatlas.api.resources.util import get_license_name
from openatlas.api.resources.model_mapper import get_entity_by_id, \
get_entities_by_system_classes, get_entities_by_ids
from openatlas.display.util import get_file_path, check_iiif_activation, \
check_iiif_file_exist
from openatlas.display.util import (
check_iiif_activation, check_iiif_file_exist, get_file_path)


class DisplayImage(Resource):
Expand Down Expand Up @@ -49,7 +49,7 @@ def get() -> tuple[Any, int]:
and check_iiif_file_exist(entity.id):
iiif_manifest = url_for(
'api.iiif_manifest',
version=app.config['IIIF']['version'],
version=g.settings['iiif']['version'],
id_=entity.id,
_external=True)
files_dict[path.stem] = {
Expand Down
13 changes: 4 additions & 9 deletions tests/test_file.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pathlib import Path
from typing import Any

from flask import url_for
from flask import g, url_for

from openatlas import app
from openatlas.models.entity import Entity
Expand Down Expand Up @@ -120,16 +120,18 @@ def test_file(self) -> None:
url_for(
'api.iiif_manifest',
id_=file_id,
version=app.config['IIIF']['version']))
version=g.settings['iiif_version']))
rv = rv.get_json()
assert bool(rv['label'] == 'Updated file')

rv = self.app.get(url_for('api.iiif_sequence', id_=file_id))
rv = rv.get_json()
assert bool(str(file_id) in rv['@id'])

rv = self.app.get(url_for('api.iiif_image', id_=file_id))
rv = rv.get_json()
assert bool(str(file_id) in rv['@id'])

rv = self.app.get(url_for('api.iiif_canvas', id_=file_id))
rv = rv.get_json()
assert bool(str(file_id) in rv['@id'])
Expand All @@ -140,16 +142,9 @@ def test_file(self) -> None:
rv = self.app.get(url_for('view', id_=place.id))
assert b'/full/!100,100/0/default.jpg' in rv.data

app.config['IIIF']['conversion'] = False
rv = self.app.get(url_for('view', id_=place.id))
assert b'/full/!100,100/0/default.jpg' in rv.data

app.config['IIIF']['activate'] = False
rv = self.app.get(url_for('view', id_=place.id))
assert b'Logo' in rv.data

app.config['IIIF']['activate'] = True
app.config['IIIF']['conversion'] = True
for file in files:
rv = self.app.get(
url_for('delete', id_=file.id),
Expand Down

0 comments on commit 704fe8f

Please sign in to comment.