diff --git a/ckanext/check_link/views.py b/ckanext/check_link/views.py index 5190cf7..e58dee0 100644 --- a/ckanext/check_link/views.py +++ b/ckanext/check_link/views.py @@ -6,12 +6,11 @@ from flask import Blueprint import ckan.plugins.toolkit as tk -from ckan import authz, model +from ckan import model from ckan.logic import parse_params from ckanext.collection import shared -from ckanext.check_link.model import Report if TYPE_CHECKING: from ckan.types import Context @@ -34,11 +33,13 @@ @bp.route("/organization//check-link/report") def organization_report(organization_id: str): - if not authz.is_authorized_boolean( - "check_link_view_report_page", - {"user": tk.g.user}, - {"organization_id": organization_id}, - ): + try: + tk.check_access( + "check_link_view_report_page", + {"user": tk.g.user}, + {"organization_id": organization_id}, + ) + except tk.NotAuthorized: return tk.abort(403) try: @@ -68,9 +69,13 @@ def organization_report(organization_id: str): @bp.route("/dataset//check-link/report") def package_report(package_id: str): - if not authz.is_authorized_boolean( - "check_link_view_report_page", {"user": tk.g.user}, {"package_id": package_id} - ): + try: + tk.check_access( + "check_link_view_report_page", + {"user": tk.g.user}, + {"package_id": package_id}, + ) + except tk.NotAuthorized: return tk.abort(403) try: @@ -99,9 +104,13 @@ def report( organization_id: str | None = None, package_id: str | None = None, ): - if not authz.is_authorized_boolean( - "check_link_view_report_page", {"user": tk.g.user}, {} - ): + try: + tk.check_access( + "check_link_view_report_page", + {"user": tk.g.user}, + {}, + ) + except tk.NotAuthorized: return tk.abort(403) col_name = "check-link-report" diff --git a/pyproject.toml b/pyproject.toml index 08a8dce..6dcdb52 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "ckanext-check-link" -version = "0.2.2.a0" +version = "0.2.2" description = "Resource URL checker" classifiers = [ "Development Status :: 4 - Beta", "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11",] keywords = [ "CKAN",]