Skip to content

Commit d142adf

Browse files
author
Tome Petrovski
committed
ARTMXCICH-149/Fix ResourceDocsEditView to restrict access to only resources belonging to the dataset
1 parent e5bd1dd commit d142adf

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

ckanext/resource_docs/views.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,19 @@ def get(self, package_id: str, resource_id: str) -> str:
2020
)
2121

2222
pkg_dict = tk.get_action("package_show")({}, {"id": package_id})
23-
resource = tk.get_action("resource_show")({}, {"id": resource_id})
2423

2524
except (tk.ObjectNotFound, tk.NotAuthorized):
2625
return tk.abort(404, tk._("Resource not found"))
2726

27+
resource = None
28+
for res in pkg_dict.get(u'resources', []):
29+
if res["id"] == resource_id:
30+
resource = res
31+
break
32+
33+
if not resource:
34+
return tk.abort(404, tk._("Resource not found"))
35+
2836
try:
2937
docs = tk.get_action("resource_docs_show")({}, {"resource_id": resource_id})
3038
except tk.ObjectNotFound:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "ckanext-resource-docs"
3-
version = "0.3.0"
3+
version = "0.3.1"
44
description = "A CKAN extension that lets you attach a flexible, schema-free data dictionary (“resource documentation”) to any resource, not just Datastore-backed ones."
55
readme = "README.md"
66
authors = [{ name = "Oleksandr Cherniavskiy", email = "[email protected]" }]

0 commit comments

Comments
 (0)