From c432c636970be3f43b7ad736d59b9103f5632c53 Mon Sep 17 00:00:00 2001
From: Thorge Petersen <petersen@rz.uni-kiel.de>
Date: Thu, 30 Mar 2023 14:47:28 +0200
Subject: [PATCH] Fixes for url generation

---
 ckanext/odsh/collection/helpers.py                            | 2 +-
 ckanext/odsh/helpers_tpsh.py                                  | 2 +-
 .../templates/organization/snippets/organization_item.html    | 2 +-
 ckanext/odsh/templates/package/search.html                    | 4 ++--
 ckanext/odsh/templates/package/snippets/resource_item.html    | 2 +-
 ckanext/odsh/templates/snippets/package_item.html             | 4 ++--
 ckanext/odsh/templates/snippets/search_form.html              | 2 +-
 ckanext/odsh/templates/user/login.html                        | 2 +-
 8 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/ckanext/odsh/collection/helpers.py b/ckanext/odsh/collection/helpers.py
index f905e15e..cd3f4052 100644
--- a/ckanext/odsh/collection/helpers.py
+++ b/ckanext/odsh/collection/helpers.py
@@ -151,7 +151,7 @@ def gather_collection_info(collection_dict, datasets_in_collection, dataset_dict
     }
 
 def url_from_id(package_id):
-    return helpers.url_for(named_route='dataset.read', id=package_id)
+    return helpers.url_for('dataset.read', id=package_id)
 
 def url_last_member(name_collection):
     return toolkit.url_for('odsh_collection.latest_dataset', id=name_collection)
diff --git a/ckanext/odsh/helpers_tpsh.py b/ckanext/odsh/helpers_tpsh.py
index 38fb986d..e543c5cc 100644
--- a/ckanext/odsh/helpers_tpsh.py
+++ b/ckanext/odsh/helpers_tpsh.py
@@ -185,7 +185,7 @@ def get_address_org(organization):
 
 def get_body_mail(organization, package):
     package_name = package.get('name')
-    url = helpers.url_for(named_route='dataset.read', id=package_name, qualified = True)
+    url = helpers.url_for('dataset.read', id=package_name, qualified = True)
     title = package.get('title')
     anrede = "Sehr geehrte Damen und Herren," + "%0D%0A" +  "%0D%0A" + "zu folgendem Eintrag habe ich eine Anmerkung/Frage:" + "%0D%0A" + "%0D%0A" 
     mail_titel = "Titel: " + title + "%0D%0A"    
diff --git a/ckanext/odsh/templates/organization/snippets/organization_item.html b/ckanext/odsh/templates/organization/snippets/organization_item.html
index 079c8ec8..53ca800e 100644
--- a/ckanext/odsh/templates/organization/snippets/organization_item.html
+++ b/ckanext/odsh/templates/organization/snippets/organization_item.html
@@ -11,7 +11,7 @@ Example:
     {% endfor %}
 </ul>
 #}
-{% set url = h.url_for(named_route='organization.read', id=organization.name) %}
+{% set url = h.url_for('organization.read', id=organization.name) %}
 <a class="organization-item" href="{{ url }}" title="{{ _('View {organization_name}').format(organization_name=organization.display_name) }}">
     <div class="row organization-item">
         <div class="span1 organization-item-text">
diff --git a/ckanext/odsh/templates/package/search.html b/ckanext/odsh/templates/package/search.html
index 5db3c32d..9f3a8919 100644
--- a/ckanext/odsh/templates/package/search.html
+++ b/ckanext/odsh/templates/package/search.html
@@ -12,7 +12,7 @@
 
 {% block toolbar %}
 {{ super() }}
-<form id='dataset-search-box-form' class="section site-search simple-input" action="{% url_for named_route='dataset.search' %}"
+<form id='dataset-search-box-form' class="section site-search simple-input" action="{% url_for 'dataset.search' %}"
 method="get" data-module="select-switch">
     <div class="row filter-search-row">
         <div class='btn show-filters'>{{ _("Filter") }}</div>
@@ -50,7 +50,7 @@ method="get" data-module="select-switch">
     <div class="container-fluid filter-reset">
         <div class="filter-reset-label"><span>{{ _("Filter") }}:</span></div>
         <div class="filter-reset-box">
-            <a href="{{h.url_for(named_route='dataset.search')}}">{{ _('Reset') }}</a>
+            <a href="{{h.url_for('dataset.search')}}">{{ _('Reset') }}</a>
         </div>
     </div>
 </div>
diff --git a/ckanext/odsh/templates/package/snippets/resource_item.html b/ckanext/odsh/templates/package/snippets/resource_item.html
index 9b65a49d..3f981fd6 100644
--- a/ckanext/odsh/templates/package/snippets/resource_item.html
+++ b/ckanext/odsh/templates/package/snippets/resource_item.html
@@ -1,5 +1,5 @@
 {% set url_action = 'edit' if url_is_edit and can_edit else 'read' %}
-{% set url = h.url_for(named_route='resource.'+url_action, id=pkg.name, resource_id=res.id) %}
+{% set url = h.url_for('resource.'+url_action, id=pkg.name, resource_id=res.id) %}
 
 {# hack for correcting slave url if resource was uploaded #}
 {% set download = h.odsh_public_resource_url(res) or url %}
diff --git a/ckanext/odsh/templates/snippets/package_item.html b/ckanext/odsh/templates/snippets/package_item.html
index 52293978..7130ddce 100644
--- a/ckanext/odsh/templates/snippets/package_item.html
+++ b/ckanext/odsh/templates/snippets/package_item.html
@@ -67,7 +67,7 @@ Example:
             {% endif %}
             {% endblock heading_private %}
             {% block heading_title %}
-            {{ h.link_to(h.truncate(title, truncate_title), h.url_for(named_route='dataset.read', id=package.name),title=_('View {organization_name}').format(organization_name=title))}}
+            {{ h.link_to(h.truncate(title, truncate_title), h.url_for('%s.read' % package.type, id=package.name),title=_('View {organization_name}').format(organization_name=title))}}
             {% endblock heading_title %}
             {% block heading_meta %}
             {% if package.get('state', '').startswith('draft') %}
@@ -120,7 +120,7 @@ Example:
       {% block resources_inner %}
       {% for resource in h.dict_list_reduce(package.resources, 'format') %}
       <li>
-        <a href="{{ h.url_for(named_route='dataset.read', id=package.name) }}" class="label dataformat-label"
+        <a href="{{ h.url_for(package.type ~ '.read', id=package.name) }}" class="label dataformat-label"
           data-format="{{ resource.lower().replace('_srvc','') }}">{{
           resource.replace('_SRVC','') }}</a>
       </li>
diff --git a/ckanext/odsh/templates/snippets/search_form.html b/ckanext/odsh/templates/snippets/search_form.html
index ffd38b09..09b45a23 100644
--- a/ckanext/odsh/templates/snippets/search_form.html
+++ b/ckanext/odsh/templates/snippets/search_form.html
@@ -42,7 +42,7 @@
     {% else %}
     <h2>{% snippet 'snippets/search_result_text.html', query=query, count=count, type=type %}</h2>
     {% if type == 'dataset' %}
-    <a aria-label="{{ _('rss feeds') }}" href={{h.remove_url_param([''], named_route='feeds.custom') }}> 
+    <a aria-label="{{ _('rss feeds') }}" href={{h.remove_url_param([''], controller='feeds', action='custom') }}> 
         <i aria-hidden="true" class="fa fa-solid fa-rss"></i>
     </a>
     {%- endif -%}
diff --git a/ckanext/odsh/templates/user/login.html b/ckanext/odsh/templates/user/login.html
index 3167301e..af9f18ad 100644
--- a/ckanext/odsh/templates/user/login.html
+++ b/ckanext/odsh/templates/user/login.html
@@ -28,7 +28,7 @@
       {% block help_forgotten_inner %}
         <span>{{ _('Forgotten your password?') }}:</span>
         {% block help_forgotten_button %}
-          <a class="btn-forget-password" href="{{ h.url_for(user.request_reset) }}">
+          <a class="btn-forget-password" href="{{ h.url_for('user.request_reset') }}">
             {{ _('Change password') }}</a>
         {% endblock %}
       {% endblock %}
-- 
GitLab