Skip to content

Commit

Permalink
Merge branch 'develop' into fix/file_reference_links
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderWatzinger committed Oct 14, 2024
2 parents 836e458 + 6a8d6c5 commit 40c11a8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
6 changes: 6 additions & 0 deletions openatlas/api/endpoints/iiif.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@

from openatlas.api.endpoints.parser import Parser
from openatlas.api.resources.api_entity import ApiEntity
from openatlas.api.resources.error import DisplayFileNotFoundError
from openatlas.api.resources.parser import iiif
from openatlas.api.resources.util import get_license_url, get_license_name
from openatlas.display.util import check_iiif_file_exist
from openatlas.models.annotation import Annotation
from openatlas.models.entity import Entity

Expand Down Expand Up @@ -236,6 +238,8 @@ def get(version: int, id_: int) -> Response:
@staticmethod
def get_manifest_version_2(id_: int, parser: Parser) -> dict[str, Any]:
entity = ApiEntity.get_by_id(id_, types=True)
if entity.class_.view != 'file' and not check_iiif_file_exist(id_):
raise DisplayFileNotFoundError
license_ = get_license_name(entity)
if entity.license_holder:
license_ = f'{license_}, {entity.license_holder}'
Expand Down Expand Up @@ -264,6 +268,8 @@ def get_manifest_version_2(id_: int, parser: Parser) -> dict[str, Any]:


def get_metadata(entity: Entity) -> dict[str, Any]:
if entity.class_.view != 'file' and not check_iiif_file_exist(entity.id):
raise DisplayFileNotFoundError
ext = '.tiff' if g.settings['iiif_conversion'] else entity.get_file_ext()
image_url = f"{g.settings['iiif_url']}{entity.id}{ext}"
req = requests.get(f"{image_url}/info.json", timeout=30)
Expand Down
20 changes: 15 additions & 5 deletions openatlas/api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"info": {
"title": "OpenAtlas API",
"description": "An API that allows user to access data from an OpenAtlas instance.",
"version": "0.4.5a",
"version": "0.4.5b",
"contact": {
"name": "OpenAtlas",
"url": "https://openatlas.eu",
Expand Down Expand Up @@ -1210,7 +1210,7 @@
}
}
},
"/display/{entityId}": {
"/display/{fileId}": {
"get": {
"tags": [
"Image Endpoints"
Expand All @@ -1219,7 +1219,7 @@
"operationId": "DisplayImage",
"parameters": [
{
"$ref": "#/components/parameters/entityId"
"$ref": "#/components/parameters/fileId"
},
{
"in": "query",
Expand Down Expand Up @@ -1258,7 +1258,7 @@
}
}
},
"/iiif_manifest/{version}/{entityId}": {
"/iiif_manifest/{version}/{fileId}": {
"get": {
"tags": [
"Image Endpoints"
Expand All @@ -1277,7 +1277,7 @@
}
},
{
"$ref": "#/components/parameters/entityId"
"$ref": "#/components/parameters/fileId"
},
{
"$ref": "#/components/parameters/url"
Expand Down Expand Up @@ -1354,6 +1354,16 @@
},
"example": 40
},
"fileId": {
"name": "fileId",
"in": "path",
"description": "Specific ID of a file entity.",
"required": true,
"schema": {
"type": "integer"
},
"example": 40
},
"cidoc_class": {
"name": "cidoc_class",
"description": "CIDOC class to be requested",
Expand Down
9 changes: 9 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,15 @@ def test_api(self) -> None:
url_for('api_04.display', filename=f'{file_without_file.id}'))
assert 'File not found' in rv.get_json()['title']

rv = self.app.get(
url_for('api_04.iiif_manifest', version= 2, id_=place.id))
assert 'File not found' in rv.get_json()['title']

rv = self.app.get(
url_for('api_04.iiif_sequence', version= 2, id_=place.id))
assert 'File not found' in rv.get_json()['title']


rv = self.app.get(url_for(
'api_04.display',
filename=f'{file_not_public.id}'))
Expand Down

0 comments on commit 40c11a8

Please sign in to comment.