Skip to content

Commit e5bacad

Browse files
authored
Merge pull request #295 from dpc-sdp/release-2.10.1
Release 2.10.1
2 parents c1086ae + a2f0416 commit e5bacad

15 files changed

Lines changed: 104 additions & 35 deletions

File tree

ckanext/datavic_odp_theme/grunt/sass/_form.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ $rpl-form-textarea-height-m: rem(75px) !default;
117117

118118
.form-actions {
119119
overflow: hidden;
120+
align-items: center;
121+
flex-wrap: nowrap;
122+
gap: 10px;
120123
}
121124

122125
select.form-control {

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/plugin.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -73,27 +73,28 @@ def before_dataset_index(self, pkg_dict: dict[str, Any]) -> dict[str, Any]:
7373

7474
def _is_all_api_format(self, pkg_dict: dict[str, Any]) -> bool:
7575
"""Check if the dataset contains a resource in a format recognized as an API.
76-
This involves determining if the format of the resource is CSV and if this resource exists in the datastore
77-
or matches a format inside a predefined list.
76+
This involves determining if the format of the resource is CSV and if this
77+
resource exists in the datastore or matches a format inside a predefined list.
7878
"""
79-
for resource in tk.get_action("package_show")({"ignore_auth": True},
80-
{"id": pkg_dict["id"]}).get(
81-
"resources", []):
79+
for resource in tk.get_action("package_show")(
80+
{"ignore_auth": True},
81+
{"id": pkg_dict["id"]}
82+
).get("resources", []):
8283
if resource["format"].upper() == "CSV" and resource["datastore_active"]:
8384
return True
8485

8586
if [
8687
res_format
8788
for res_format in pkg_dict["res_format"]
8889
if res_format
89-
in [
90-
"WMS",
91-
"WFS",
92-
"API",
93-
"ARCGIS GEOSERVICES REST API",
94-
"ESRI REST",
95-
"GEOJSON",
96-
]
90+
in [
91+
"WMS",
92+
"WFS",
93+
"API",
94+
"ARCGIS GEOSERVICES REST API",
95+
"ESRI REST",
96+
"GEOJSON",
97+
]
9798
]:
9899
return True
99100
return False
@@ -110,10 +111,11 @@ def get_categories(self):
110111
# IAuthenticator
111112

112113
def login(self) -> Optional[Response]:
113-
session.regenerate_id() # type: ignore
114+
session.modified = True
114115

115116
def logout(self) -> Optional[Response]:
116-
session.regenerate_id() # type: ignore
117+
session.modified = True
118+
117119

118120
# ISignal
119121

@@ -170,15 +172,15 @@ class DatavicODPThemeAuth(p.SingletonPlugin):
170172
171173
We are chaining auth functions from activity and overriding its templates
172174
at the same time. The former requires us to put our plugin after the
173-
activty, while the latter will work only if we put our plugin before the
175+
activity, while the latter will work only if we put our plugin before the
174176
activity. The only way to solve this puzzle is to split the logic between
175177
two sub-plugins.
176178
177179
"""
178180
pass
179181

180182

181-
class DatavicXLoaderPlugin(xloaderPlugin):
183+
class DatavicXLoaderPlugin(xloaderPlugin, p.SingletonPlugin):
182184
p.implements(p.IPackageController, inherit=True)
183185

184186
# IPackageController

ckanext/datavic_odp_theme/templates/datatables/datatables_view.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
{% ckan_extends %}
22

33

4-
{% block bodytag %} data-site-root="{{ h.url_for('home.index', locale='default', qualified=true) }}" data-locale-root="{{ h.url_for('home.index', qualified=true) }}" {% endblock %}
4+
{% block bodytag %}
5+
{{ super() }}
6+
data-site-root="{{ h.url_for('home.index', locale='default', qualified=true) }}"
7+
data-locale-root="{{ h.url_for('home.index', qualified=true) }}"
8+
{% endblock %}
59

610
{% block page %}
711
{% set datadictionary = h.datavic_datastore_dictionary(resource.id, resource_view.id) %}
812
{% set nbspval = " "|safe %}
9-
{% set languagefile = "/vendor/DataTables/i18n/en.json" if h.lang() in ["en", "en_AU"] else h.url_for_static('vendor/DataTables/i18n/' + h.lang() + '.json') %}
13+
{% set languagefile = "/datatablesview/i18n/en_GB.json" if h.lang() in ["en", "en_AU"] else h.url_for_static('/datatablesview/i18n/' + h.lang() + '.json') %}
1014

1115
<script type=text/javascript>
1216
const gdataDict = {{ datadictionary|tojson }}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<tr>
2+
<td>{{ field.id }}</td>
3+
<td>{{ field.type }}</td>
4+
<td>{{ h.get_translated(field.get('info', {}), 'label') }}</td>
5+
<td>{{ h.render_markdown(h.get_translated(field.get('info', {}), 'notes')) }}</td>
6+
</tr>

ckanext/datavic_odp_theme/templates/package/snippets/resource_item.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<li>
4949
<a class="btn btn-primary btn-outline"
5050
href="{{ h.url_for('dataset_resource.edit', id=pkg.name, resource_id=res.id) }}">
51-
<i class="fa fa-pencil-square-o"></i>
51+
<i class="fa fa-pencil-square"></i>
5252
{{ _('Edit') }}
5353
</a>
5454
</li>
@@ -63,7 +63,7 @@
6363
<li>
6464
<a href="{{ res.url }}" class="btn btn-primary" target="_blank">
6565
{% if res.has_views or res.url_type == 'upload' %}
66-
<i class="fa fa-arrow-circle-o-down"></i>
66+
<i class="fa fa-download"></i>
6767
{{ _('Download data') }}
6868
{% else %}
6969
<i class="fa fa-external-link"></i>

ckanext/datavic_odp_theme/tests/e2e/__init__.py

Whitespace-only changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from __future__ import annotations
2+
3+
from typing import Any
4+
5+
import pytest
6+
7+
8+
@pytest.fixture()
9+
def browser_context_args(
10+
browser_context_args: dict[str, Any], ckan_config: dict[str, Any]
11+
):
12+
"""Modify playwright's standard configuration of browser's context."""
13+
browser_context_args["base_url"] = ckan_config["ckan.site_url"]
14+
return browser_context_args
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from __future__ import annotations
2+
3+
from typing import Any, Callable
4+
5+
import pytest
6+
from playwright.sync_api import Page, expect
7+
8+
import ckan.plugins.toolkit as tk
9+
10+
11+
@pytest.mark.playwright
12+
@pytest.mark.usefixtures("with_plugins", "clean_db", "clean_index")
13+
class TestDatasetSearch:
14+
def test_public_dataset(
15+
self, page: Page, package_factory: Callable[..., dict[str, Any]]
16+
):
17+
dataset = package_factory(private=False)
18+
19+
page.goto(tk.h.url_for("dataset.search"))
20+
expect(page.locator(".privacy-label ")).to_have_text(
21+
"Open to the public"
22+
)
23+
24+
page.get_by_role("link", name=dataset["title"]).click()
25+
26+
expect(page).to_have_url(
27+
tk.h.url_for("dataset.read", id=dataset["name"])
28+
)

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)