From 52c3975bfc0f07df1df87bf4032b8171e697342e Mon Sep 17 00:00:00 2001
From: Thorge Petersen <petersen@rz.uni-kiel.de>
Date: Mon, 10 Jul 2023 12:11:34 +0200
Subject: [PATCH] Fixes in templates and dashboard view for ckan 2.10 upgrade

---
 ckanext/odsh/templates/header.html                     |  7 +++++--
 ckanext/odsh/templates/snippets/dataset_map.html       |  2 +-
 .../odsh/templates/snippets/home_breadcrumb_item.html  |  2 +-
 ckanext/odsh/templates/snippets/package_item.html      |  4 +++-
 ckanext/odsh/views/dashboard.py                        | 10 +++++-----
 5 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/ckanext/odsh/templates/header.html b/ckanext/odsh/templates/header.html
index 85f97274..c921aed0 100644
--- a/ckanext/odsh/templates/header.html
+++ b/ckanext/odsh/templates/header.html
@@ -2,6 +2,9 @@
 {% asset 'ckanext-odsh/odsh_toggle_menu' %}
 {% endblock scripts %}
 
+{% set dataset_type = h.default_package_type() %}
+{% set org_type = h.default_group_type('organization') %}
+
 {% block header_wrapper %}
 {% block header_account %}
 <header class="navbar navbar-static-top masthead">
@@ -41,8 +44,8 @@
           {% block header_site_navigation_tabs %}
           {{
             h.build_nav_main(
-              ('search', _('Datasets')),
-              ('organizations_index', _('Organizations'))
+              (dataset_type ~ '.search', _('Datasets'), ["dataset", "resource"]),
+              (org_type ~ '.index', _('Organizations'), ['organization'])
             )
           }}
           {% endblock %}
diff --git a/ckanext/odsh/templates/snippets/dataset_map.html b/ckanext/odsh/templates/snippets/dataset_map.html
index 1e4ad4fb..3d99f307 100644
--- a/ckanext/odsh/templates/snippets/dataset_map.html
+++ b/ckanext/odsh/templates/snippets/dataset_map.html
@@ -4,7 +4,7 @@
 
 {% set map_config = h.get_common_map_config() %}
 {% set x=map_config.__setitem__("height", "10px") %}
-<div class="dataset-map" data-module="dataset-map" data-extent="{{ extent }}" data-module-site_url="{{ h.dump_json(h.url('/', locale='default', qualified=true)) }}" data-module-map_config="{{ h.dump_json(map_config) }}">
+<div class="dataset-map" data-module="dataset-map" data-extent="{{ extent }}" data-module-site_url="{{ h.dump_json(h.url_for('home.index', locale='default', qualified=true)) }}" data-module-map_config="{{ h.dump_json(map_config) }}">
   <div id="dataset-map-container"></div>
   <div id="dataset-map-attribution">
     {% snippet "spatial/snippets/map_attribution.html", map_config=map_config %}
diff --git a/ckanext/odsh/templates/snippets/home_breadcrumb_item.html b/ckanext/odsh/templates/snippets/home_breadcrumb_item.html
index 7631991a..866c9007 100644
--- a/ckanext/odsh/templates/snippets/home_breadcrumb_item.html
+++ b/ckanext/odsh/templates/snippets/home_breadcrumb_item.html
@@ -1,6 +1,6 @@
 {# Used to insert the home icon into a breadcrumb #}
 <li class="home">
-    <a href="{{ h.url_for('home') }}">
+    <a href="{{ h.url_for('home.index') }}">
         <img class='icon-home' src='/base/images/Icon-Home.png' alt='home icon' />
         <span> {{_('Home') }}</span>
     </a>
diff --git a/ckanext/odsh/templates/snippets/package_item.html b/ckanext/odsh/templates/snippets/package_item.html
index 2711197d..b00af1d5 100644
--- a/ckanext/odsh/templates/snippets/package_item.html
+++ b/ckanext/odsh/templates/snippets/package_item.html
@@ -72,7 +72,9 @@ Example:
             {% endif %}
             {% endblock heading_private %}
             {% block heading_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))}}
+            <a href="{{ h.url_for('%s.read' % package.type, id=package.name) }}">
+              {{ _('View {organization_name}').format(organization_name=title)|truncate(80) }}
+            </a>
             {% endblock heading_title %}
             {% block heading_meta %}
             {% if package.get('state', '').startswith('draft') %}
diff --git a/ckanext/odsh/views/dashboard.py b/ckanext/odsh/views/dashboard.py
index dceebe44..463487c4 100644
--- a/ckanext/odsh/views/dashboard.py
+++ b/ckanext/odsh/views/dashboard.py
@@ -1,8 +1,8 @@
 import ckan.authz as authz
 import ckan.lib.helpers as h
-from ckan.common import g
+from ckan.common import g, _
 from flask import Blueprint
-from ckan.views.dashboard import datasets, organizations, groups
+import ckan.views.dashboard as dashboard
 import logging
 
 log = logging.getLogger(__name__)
@@ -18,10 +18,10 @@ def before_request() -> None:
     return None
 
 def datasets():
-    return datasets()
+    return dashboard.datasets()
 
 def organizations():
-    return organizations()
+    return dashboard.organizations()
 
 def groups():
-    return groups()
+    return dashboard.groups()
-- 
GitLab