Skip to content

Commit a2f0416

Browse files
authored
Merge pull request #292 from dpc-sdp/SXDEDPCXZIC-453
SXDEDPCXZIC-453 / update DTV settings
2 parents a3e40a3 + 7e45f8c commit a2f0416

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

ckanext/datavic_odp_theme/helpers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import json
55
import base64
66
from typing import Any, Optional
7+
from urllib.parse import quote
78

89
from sqlalchemy import func
910

@@ -152,7 +153,7 @@ def get_digital_twin_resources(pkg: dict[str, Any]) -> list[dict[str, Any]]:
152153
return []
153154

154155
acceptable_resources = {}
155-
for res in pkg["resources"]:
156+
for res in pkg.get("resources", []):
156157
if not res["format"]:
157158
continue
158159

@@ -187,8 +188,9 @@ def url_for_dtv_config(ids: list[str], embedded: bool = True) -> str:
187188
"""Build URL where DigitalTwin can get map configuration for the preview."""
188189

189190
encoded = base64.urlsafe_b64encode(bytes(json.dumps(ids), "utf8"))
191+
encoded_string = quote(encoded, safe='')
190192
return toolkit.url_for(
191-
"vic_odp.dtv_config", encoded=encoded, embedded=embedded, _external=True
193+
"vic_odp.dtv_config", encoded=encoded_string, embedded=embedded, _external=True
192194
)
193195

194196

ckanext/datavic_odp_theme/views.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
import base64
55
from typing import Any
6+
from urllib.parse import unquote_to_bytes
67

78
from flask import Blueprint, jsonify
89

@@ -36,6 +37,7 @@ def vic_organization_activity(id: str, offset: int = 0):
3637

3738

3839
def dtv_config(encoded: str, embedded: bool):
40+
encoded = unquote_to_bytes(encoded)
3941
try:
4042
ids: list[str] = json.loads(base64.urlsafe_b64decode(encoded))
4143
except ValueError:

0 commit comments

Comments
 (0)