Skip to content

Commit

Permalink
Add absolute file paths to map publication info
Browse files Browse the repository at this point in the history
(cherry picked from commit 5e292c5)
  • Loading branch information
index-git authored and jirik committed Nov 9, 2023
1 parent 727349c commit 49747f9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/layman/map/filesystem/input_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,21 @@ def get_map_file(workspace, mapname):


def get_map_info(workspace, mapname, *, x_forwarded_items=None):
map_file_path = get_map_file(workspace, mapname)
map_file_path_absolute = get_map_file(workspace, mapname)
result = {}
if os.path.exists(map_file_path):
with open(map_file_path, 'r', encoding="utf-8") as map_file:
if os.path.exists(map_file_path_absolute):
with open(map_file_path_absolute, 'r', encoding="utf-8") as map_file:
map_json = json.load(map_file)
map_file_path = os.path.relpath(map_file_path, common_util.get_workspace_dir(workspace))
map_file_path = os.path.relpath(map_file_path_absolute, common_util.get_workspace_dir(workspace))
result = {
'file': {
'path': map_file_path,
'url': url_for('rest_workspace_map_file.get', mapname=mapname, workspace=workspace, x_forwarded_items=x_forwarded_items),
},
'_file': {
'paths': {
'absolute': [map_file_path_absolute],
},
'url': url_for('rest_workspace_map_file.get', mapname=mapname, workspace=workspace, internal=True),
},
'title': map_json['title'] or '',
Expand Down
3 changes: 3 additions & 0 deletions tests/asserts/final/publication/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@ def correct_values_in_detail(workspace, publ_type, name, *, exp_publication_deta
{
'_file': {
'url': f'http://{settings.LAYMAN_SERVER_NAME}/rest/workspaces/{workspace}/{publ_type_dir}/{name}/file',
'paths': {
'absolute': [f'/layman_data_test/workspaces/{workspace}/{publ_type_dir}/{name}/input_file/{name}.json']
},
},
'file': {
'path': f'{publ_type_dir}/{name}/input_file/{name}.json',
Expand Down

0 comments on commit 49747f9

Please sign in to comment.