Skip to content

Commit

Permalink
Merge branch 'develop' into feature/remove_shell_true
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardKoschicek committed Nov 3, 2023
2 parents a75ebce + 42e08d8 commit e99695f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 30 deletions.
6 changes: 3 additions & 3 deletions openatlas/api/endpoints/display_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ def get() -> tuple[Any, int]:
if license_ := get_license_name(entity):
if path := get_file_path(entity):
iiif_manifest = ''
if check_iiif_activation() \
and check_iiif_file_exist(entity.id):
if (check_iiif_activation() and
check_iiif_file_exist(entity.id)):
iiif_manifest = url_for(
'api.iiif_manifest',
version=g.settings['iiif']['version'],
id_=entity.id,
_external=True)
_external=True) # pragma: no cover
files_dict[path.stem] = {
'extension': path.suffix,
'display': url_for(
Expand Down
34 changes: 9 additions & 25 deletions openatlas/api/formats/loud.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
from openatlas.models.type import Type


def get_loud_entities(
data: dict[str, Any],
loud: dict[str, str]) -> Any:
def get_loud_entities(data: dict[str, Any], loud: dict[str, str]) -> Any:
properties_set = defaultdict(list)

def base_entity_dict() -> dict[str, Any]:
Expand All @@ -25,16 +23,15 @@ def base_entity_dict() -> dict[str, Any]:
'_label': data['entity'].name,
'content': data['entity'].description,
'timespan': get_loud_timespan(data['entity']),
'identified_by': [
{"type": "Name",
"content": data['entity'].name}]}
'identified_by': [{
"type": "Name",
"content": data['entity'].name}]}

def get_range_links() -> dict[str, Any]:
property_ = {
return {
'id': url_for('api.entity', id_=link_.range.id, _external=True),
'type': loud[get_crm_code(link_).replace(' ', '_')],
'_label': link_.range.name}
return property_

def get_domain_links() -> dict[str, Any]:
property_ = {
Expand All @@ -52,7 +49,6 @@ def get_domain_links() -> dict[str, Any]:
property_name = 'broader'
else:
property_name = loud[get_crm_relation(link_).replace(' ', '_')]

if link_.property.code == 'P53':
for geom in Gis.get_wkt_by_id(link_.range.id):
base_property = get_range_links() | geom
Expand Down Expand Up @@ -84,40 +80,28 @@ def get_domain_links() -> dict[str, Any]:

if image_links:
profile_image = Entity.get_profile_image_id(data['entity'])
print(profile_image)
representation = {
"type": "VisualItem",
"digitally_shown_by": []}
representation = {"type": "VisualItem", "digitally_shown_by": []}
for link_ in image_links:
id_ = link_.domain.id
suffix = g.files[id_].suffix.replace('.', '')

if not app.config['IMAGE_FORMATS'].get(suffix):
continue

path = get_file_path(id_)
continue # pragma: no cover
image = {
"id": url_for(
'api.entity',
id_=id_,
_external=True),
"id": url_for('api.entity', id_=id_, _external=True),
"_label": link_.domain.name,
"type": "DigitalObject",
"format": app.config['IMAGE_FORMATS'][suffix],
"access_point": [{
"id": url_for(
'api.display',
filename=path.stem,
filename=get_file_path(id_).stem,
_external=True),
"type": "DigitalObject",
"_label": "ProfileImage" if id_ == profile_image else ''}]}

if type_ := get_standard_type_loud(link_.domain.types):
image['classified_as'] = get_type_property(type_)
representation['digitally_shown_by'].append(image)

properties_set['representation'].append(representation)

return {'@context': app.config['API_CONTEXT']['LOUD']} | \
base_entity_dict() | properties_set

Expand Down
2 changes: 1 addition & 1 deletion openatlas/display/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ def check_iiif_activation() -> bool:
def check_iiif_file_exist(id_: int) -> bool:
if g.settings['iiif_conversion']:
return get_iiif_file_path(id_).is_file()
return bool(get_file_path(id_))
return bool(get_file_path(id_)) # pragma: no cover


def get_iiif_file_path(id_: int) -> Path:
Expand Down
2 changes: 1 addition & 1 deletion tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def setup_database(self) -> None:
Path(app.root_path).parent / 'install' /
f'{file_name}.sql', encoding='utf8') as sql_file:
self.cursor.execute(sql_file.read())
if app.config['LOAD_WINDOWS_TEST_SQL']:
if app.config['LOAD_WINDOWS_TEST_SQL']: # pragma: no cover
with open(
Path(app.root_path).parent / 'install' /
f'data_test_windows.sql', encoding='utf8') as sql_file:
Expand Down

0 comments on commit e99695f

Please sign in to comment.