From 35c0a04cbb7aeff7d97b40d8f07d095c8acf7be4 Mon Sep 17 00:00:00 2001 From: Thorge Petersen <petersen@rz.uni-kiel.de> Date: Thu, 30 Mar 2023 14:18:57 +0200 Subject: [PATCH] Removed controllers from url generation --- ckanext/odsh/collection/helpers.py | 2 +- ckanext/odsh/collection/plugin.py | 3 +- ckanext/odsh/helpers.py | 2 +- ckanext/odsh/helpers_tpsh.py | 2 +- ckanext/odsh/pdf_to_thumbnail/helpers.py | 3 +- ckanext/odsh/profiles/odsh_dcat_de_profile.py | 2 +- ckanext/odsh/templates/datarequests/base.html | 2 +- .../odsh/templates/datarequests/close.html | 4 +- .../odsh/templates/datarequests/comment.html | 6 +- ckanext/odsh/templates/datarequests/edit.html | 4 +- .../odsh/templates/datarequests/index.html | 2 +- ckanext/odsh/templates/datarequests/new.html | 2 +- ckanext/odsh/templates/datarequests/show.html | 8 +- .../datarequests/snippets/comment_item.html | 6 +- .../snippets/datarequest_form.html | 2 +- .../snippets/datarequest_list.html | 2 +- ckanext/odsh/templates/header.html | 225 +++++++++--------- ckanext/odsh/templates/home/index.html | 4 +- .../odsh/templates/organization/index.html | 6 +- ckanext/odsh/templates/organization/read.html | 2 +- .../snippets/organization_form.html | 4 +- .../snippets/organization_item.html | 2 +- ckanext/odsh/templates/package/base.html | 10 +- ckanext/odsh/templates/package/edit_base.html | 4 +- ckanext/odsh/templates/package/read.html | 12 +- .../templates/package/resource_edit_base.html | 4 +- .../odsh/templates/package/resource_read.html | 4 +- ckanext/odsh/templates/package/search.html | 6 +- .../package/snippets/package_form.html | 2 +- .../package/snippets/resource_form.html | 2 +- .../package/snippets/resource_item.html | 6 +- .../templates/package/snippets/stages.html | 2 +- .../templates/package/view_edit_base.html | 4 +- .../templates/snippets/follow_button.html | 4 +- .../odsh/templates/snippets/organization.html | 2 +- .../odsh/templates/snippets/package_item.html | 4 +- .../odsh/templates/snippets/search_form.html | 2 +- ckanext/odsh/templates/user/login.html | 42 ++-- ckanext/odsh/templates/user/logout.html | 2 +- ckanext/odsh/tests/test_routes.py | 2 +- ckanext/odsh/tests/test_search.py | 2 +- ckanext/odsh/tests/test_upload.py | 6 +- ckanext/odsh/tests/test_user.py | 2 +- ckanext/odsh/views/feed.py | 6 +- 44 files changed, 207 insertions(+), 218 deletions(-) diff --git a/ckanext/odsh/collection/helpers.py b/ckanext/odsh/collection/helpers.py index ce519e68..f905e15e 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(controller='dataset', action='read', id=package_id) + return helpers.url_for(named_route='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/collection/plugin.py b/ckanext/odsh/collection/plugin.py index 0c8ccf0a..6b196f12 100644 --- a/ckanext/odsh/collection/plugin.py +++ b/ckanext/odsh/collection/plugin.py @@ -64,8 +64,7 @@ class CollectionsPlugin(plugins.SingletonPlugin, DefaultDatasetForm): if toolkit.is_url(pre_resource_url): url_resource = pre_resource_url else: - url_resource = toolkit.url_for(controller='dataset', - action='resource_download', + url_resource = toolkit.url_for(named_route='dataset.resource_download', id=download_package_id, resource_id=download_resource_id, filename=pre_resource_url) diff --git a/ckanext/odsh/helpers.py b/ckanext/odsh/helpers.py index 044e879f..79cd564a 100644 --- a/ckanext/odsh/helpers.py +++ b/ckanext/odsh/helpers.py @@ -428,7 +428,7 @@ def get_package_dict(name): def tpsh_get_successor_and_predecessor_urls(context, pkg_dict): successor_name, predecessor_name = tpsh_get_successor_and_predecessor_dataset(context, pkg_dict) successor_url, predecessor_url = ( - helpers.url_for(controller='dataset', action='read', id=name) + helpers.url_for(named_route='dataset.read', id=name) if name is not None else None for name in (successor_name, predecessor_name) diff --git a/ckanext/odsh/helpers_tpsh.py b/ckanext/odsh/helpers_tpsh.py index c70ce0f3..38fb986d 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(controller='dataset', action='read', id=package_name, qualified = True) + url = helpers.url_for(named_route='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/pdf_to_thumbnail/helpers.py b/ckanext/odsh/pdf_to_thumbnail/helpers.py index 33409443..82a5d15c 100644 --- a/ckanext/odsh/pdf_to_thumbnail/helpers.py +++ b/ckanext/odsh/pdf_to_thumbnail/helpers.py @@ -16,8 +16,7 @@ def get_download_link_for_thumbnail(package): if is_url(pre_resource_url): url_resource = pre_resource_url else: - url_resource = url_for(controller='dataset', - action='resource_download', + url_resource = url_for(named_route='dataset.resource_download', id=package_id, resource_id=resource_id, filename=pre_resource_url, diff --git a/ckanext/odsh/profiles/odsh_dcat_de_profile.py b/ckanext/odsh/profiles/odsh_dcat_de_profile.py index e890e763..98e8380e 100644 --- a/ckanext/odsh/profiles/odsh_dcat_de_profile.py +++ b/ckanext/odsh/profiles/odsh_dcat_de_profile.py @@ -192,7 +192,7 @@ class ODSHDCATdeProfile(DCATdeProfile): @staticmethod def _construct_refs(id): public_url = config.get('ckan.site_url') - url_to_id = helpers.url_for(controller='dataset', action='read', id=id) + url_to_id = helpers.url_for(named_route='dataset.read', id=id) ref = public_url + url_to_id return ref diff --git a/ckanext/odsh/templates/datarequests/base.html b/ckanext/odsh/templates/datarequests/base.html index 933720ee..5722356e 100644 --- a/ckanext/odsh/templates/datarequests/base.html +++ b/ckanext/odsh/templates/datarequests/base.html @@ -9,7 +9,7 @@ {% endblock %} {% block breadcrumb_content %} - <li class="active">{% link_for _('Data Proposal'), controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='index' %}</li> + <li class="active">{% link_for _('Data Proposal'), named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.index' %}</li> {% endblock %} {% block main_content %} diff --git a/ckanext/odsh/templates/datarequests/close.html b/ckanext/odsh/templates/datarequests/close.html index 65d168a6..0b3e115c 100644 --- a/ckanext/odsh/templates/datarequests/close.html +++ b/ckanext/odsh/templates/datarequests/close.html @@ -3,8 +3,8 @@ {% block subtitle %}{{ _('Close Data Proposal') }}{% endblock %} {% block breadcrumb_content %} - <li>{% link_for _('Data Proposal'), controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='index' %}</li> - <li>{% link_for c.datarequest.get('title')|truncate(30), controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='show', id=c.datarequest.get('id') %}</li> + <li>{% link_for _('Data Proposal'), named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.index' %}</li> + <li>{% link_for c.datarequest.get('title')|truncate(30), named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.show', id=c.datarequest.get('id') %}</li> <li class="active"><a href="">{{ _('Close Data Proposal') }}</a></li> {% endblock %} diff --git a/ckanext/odsh/templates/datarequests/comment.html b/ckanext/odsh/templates/datarequests/comment.html index d64bfa83..01d29f12 100644 --- a/ckanext/odsh/templates/datarequests/comment.html +++ b/ckanext/odsh/templates/datarequests/comment.html @@ -15,11 +15,11 @@ {% block primary_content_inner %} {% if h.check_access('update_datarequest', {'id':datarequest_id }) %} - {% link_for _('Manage'), controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='update', id=datarequest_id, class_='btn btn-default', icon='wrench' %} + {% link_for _('Manage'), named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.update', id=datarequest_id, class_='btn btn-default', icon='wrench' %} {% endif %} {% if h.check_access('close_datarequest', {'id':datarequest_id }) and not c.datarequest.closed %} - {% link_for _('Close'), controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='close', id=datarequest_id, class_='btn btn-danger', icon='lock' %} + {% link_for _('Close'), named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.close', id=datarequest_id, class_='btn btn-danger', icon='lock' %} {% endif %} <h2 class="page-heading"> @@ -70,7 +70,7 @@ <th scope="row" class="dataset-label">{{ _('Accepted Dataset') }}</th> <td class="dataset-details"> {% if c.datarequest.accepted_dataset %} - {% link_for c.datarequest.accepted_dataset['title'], controller='dataset', action='read', id=c.datarequest.accepted_dataset.get('id') %} + {% link_for c.datarequest.accepted_dataset['title'], named_route='dataset.read', id=c.datarequest.accepted_dataset.get('id') %} {% else %} {{ _('None') }} {% endif %} diff --git a/ckanext/odsh/templates/datarequests/edit.html b/ckanext/odsh/templates/datarequests/edit.html index 6ca7fb66..ae301370 100644 --- a/ckanext/odsh/templates/datarequests/edit.html +++ b/ckanext/odsh/templates/datarequests/edit.html @@ -3,8 +3,8 @@ {% block subtitle %}{{ _('Edit Data Proposal') }}{% endblock %} {% block breadcrumb_content %} - <li>{% link_for _('Data Proposal'), controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='index' %}</li> - <li>{% link_for c.original_title|truncate(30), controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='show', id=c.datarequest.get('id') %}</li> + <li>{% link_for _('Data Proposal'), named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.index' %}</li> + <li>{% link_for c.original_title|truncate(30), named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.show', id=c.datarequest.get('id') %}</li> <li class="active"><a href="">{{ _('Edit Data Proposal') }}</a></li> {% endblock %} diff --git a/ckanext/odsh/templates/datarequests/index.html b/ckanext/odsh/templates/datarequests/index.html index 947e326e..d44ea218 100644 --- a/ckanext/odsh/templates/datarequests/index.html +++ b/ckanext/odsh/templates/datarequests/index.html @@ -9,7 +9,7 @@ {{ h.snippet('datarequests/snippets/datarequest_list.html', datarequest_count=c.datarequest_count, datarequests=c.datarequests, page=c.page, q=c.q)}} {% if h.check_access('create_datarequest') %} <div class="add_request_container"> - {% link_for _('Add Request'), controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='new', class_='btn btn-primary', icon=h.get_plus_icon() %} + {% link_for _('Add Request'), named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.new', class_='btn btn-primary', icon=h.get_plus_icon() %} </div> {% endif %} {% endblock %} diff --git a/ckanext/odsh/templates/datarequests/new.html b/ckanext/odsh/templates/datarequests/new.html index e8f5807d..1cf63c2e 100644 --- a/ckanext/odsh/templates/datarequests/new.html +++ b/ckanext/odsh/templates/datarequests/new.html @@ -3,7 +3,7 @@ {% block subtitle %}{{ _('Create Data Request') }}{% endblock %} {% block breadcrumb_content %} - <li>{% link_for _('Data Proposal'), controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='index' %}</li> + <li>{% link_for _('Data Proposal'), named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.index' %}</li> <li class="active"><a href="">{{ _('Create Data Proposal') }}</a></li> {% endblock %} diff --git a/ckanext/odsh/templates/datarequests/show.html b/ckanext/odsh/templates/datarequests/show.html index 72eba0b5..9ac6e9bf 100644 --- a/ckanext/odsh/templates/datarequests/show.html +++ b/ckanext/odsh/templates/datarequests/show.html @@ -5,18 +5,18 @@ {% set datarequest_id = c.datarequest.get('id') %} {% block breadcrumb_content %} - <li>{% link_for _('Data Requests'), controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='index' %}</li> - <li>{% link_for c.datarequest.get('title'), controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='show', id=datarequest_id %}</li> + <li>{% link_for _('Data Requests'), named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI'.index' %}</li> + <li>{% link_for c.datarequest.get('title'), named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.show', id=datarequest_id %}</li> {% endblock %} {% block content_action %} {% if h.check_access('update_datarequest', {'id':datarequest_id }) %} - {% link_for _('Manage'), controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='update', id=datarequest_id, class_='btn btn-default', icon='wrench' %} + {% link_for _('Manage'), named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.update', id=datarequest_id, class_='btn btn-default', icon='wrench' %} {% endif %} {% if h.check_access('close_datarequest', {'id':datarequest_id }) and not c.datarequest.closed %} - {% link_for _('Close'), controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='close', id=datarequest_id, class_='btn btn-danger', icon='lock' %} + {% link_for _('Close'), named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.close', id=datarequest_id, class_='btn btn-danger', icon='lock' %} {% endif %} {% endblock %} diff --git a/ckanext/odsh/templates/datarequests/snippets/comment_item.html b/ckanext/odsh/templates/datarequests/snippets/comment_item.html index 155e6d1d..678afe85 100644 --- a/ckanext/odsh/templates/datarequests/snippets/comment_item.html +++ b/ckanext/odsh/templates/datarequests/snippets/comment_item.html @@ -6,7 +6,7 @@ {% endif %} <div class="odsh-comment-wrapper"> - {# <a href="{{ h.url_for(controller='user', action='read', id=comment.user.get('name')) }}" + {# <a href="{{ h.url_for(named_route='user.read', id=comment.user.get('name')) }}" class="comment-avatar"> {{ h.gravatar(comment.user.get('email_hash'), 48) }} </a> @@ -18,7 +18,7 @@ {% if h.check_access('delete_datarequest_comment', {'id':comment.id }) %} <div class="comment-action"> {% set locale = h.dump_json({'content': _('Are you sure you want to delete this comment?')}) %} - <a class="subtle-btn" id="delete-comment-{{ comment.id }}" href="{% url_for controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='delete_comment', datarequest_id=datarequest.id, comment_id=comment.id %}" data-module="confirm-action" data-module-i18n="{{ locale }}"><i class="icon-remove fa fa-times"></i></a> + <a class="subtle-btn" id="delete-comment-{{ comment.id }}" href="{% url_for named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.delete_comment', datarequest_id=datarequest.id, comment_id=comment.id %}" data-module="confirm-action" data-module-i18n="{{ locale }}"><i class="icon-remove fa fa-times"></i></a> </div> {% endif %} {% if can_update %} @@ -29,7 +29,7 @@ #} <div class="comment-header-text"> <i class="icon-comment fa fa-comment"></i> - <a href="{{ h.url_for(controller='user', action='read', id=comment.user.get('name')) }}" class="comment-author">{{ comment.user.get('display_name') }}</a> + <a href="{{ h.url_for(named_route='user.read', id=comment.user.get('name')) }}" class="comment-author">{{ comment.user.get('display_name') }}</a> <span class='comment-date' title="{{comment.time}}">{{ h.odsh_render_datetime(comment.time).lower() }}</span> </div> </div> diff --git a/ckanext/odsh/templates/datarequests/snippets/datarequest_form.html b/ckanext/odsh/templates/datarequests/snippets/datarequest_form.html index 9bebd010..df695074 100644 --- a/ckanext/odsh/templates/datarequests/snippets/datarequest_form.html +++ b/ckanext/odsh/templates/datarequests/snippets/datarequest_form.html @@ -27,7 +27,7 @@ then itself be extended to add/remove blocks of functionality. #} {% block delete_button %} {% if h.check_access('delete_datarequest', {'id': data.get('id', '')}) and not data.state == 'deleted' %} {% set locale = h.dump_json({'content': _('Are you sure you want to delete this data request?')}) %} - <a class="btn btn-danger pull-left" href="{% url_for controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='delete', id=data.get('id') %}" data-module="confirm-action" data-module-i18n="{{ locale }}">{% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a> + <a class="btn btn-danger pull-left" href="{% url_for named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.delete', id=data.get('id') %}" data-module="confirm-action" data-module-i18n="{{ locale }}">{% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a> {% endif %} {% endblock %} <button class="btn btn-primary btn-arrow-right" type="submit" name="save">{% block save_button_text %}{{ _('Create Data Request') }}{% endblock %}</button> diff --git a/ckanext/odsh/templates/datarequests/snippets/datarequest_list.html b/ckanext/odsh/templates/datarequests/snippets/datarequest_list.html index 90c75c19..c2ef8dac 100644 --- a/ckanext/odsh/templates/datarequests/snippets/datarequest_list.html +++ b/ckanext/odsh/templates/datarequests/snippets/datarequest_list.html @@ -10,7 +10,7 @@ <p class="empty"> {{ _('No Data Requests found with the given criteria') }}. {% if h.check_access('create_datarequest') %} - {% link_for _('How about creating one?'), controller='ckanext.datarequests.controllers.ui_controller:DataRequestsUI', action='new' %}</a> + {% link_for _('How about creating one?'), named_route='ckanext.datarequests.controllers.ui_controller:DataRequestsUI.new' %}</a> {% endif %} </p> {% endif %} diff --git a/ckanext/odsh/templates/header.html b/ckanext/odsh/templates/header.html index 123cdcb8..708d0a57 100644 --- a/ckanext/odsh/templates/header.html +++ b/ckanext/odsh/templates/header.html @@ -1,128 +1,121 @@ - {% block scripts %} - {% asset 'ckanext-odsh/tpsh_toggle_menu' %} +{% asset 'ckanext-odsh/tpsh_toggle_menu' %} {% endblock scripts %} {% block header_wrapper %} {% block header_account %} <header class="navbar navbar-static-top masthead"> - {% block header_debug %} - {% if g.debug and not g.debug_supress_header %} - <div class="debug">Controller : {{ c.controller }}<br />Action : {{ c.action }}</div> - {% endif %} - {% endblock %} - <div class="container"> - {# The .header-image class hides the main text and uses image replacement for the title #} - <div class='row topline'> + <div class="container"> + {# The .header-image class hides the main text and uses image replacement for the title #} + <div class='row topline'> - <div class='span3 span-navigation'> - <hgroup class="{{ g.header_class }} pull-left"> + <div class='span3 span-navigation'> + <hgroup class="{{ g.header_class }} pull-left"> - {% block header_logo %} - <a class="logo" href="{{ h.url_for('home') }}"> - <img class="img-logo-large" src="{{ h.url_for_static_or_external(g.site_logo) }}" alt="Logo Schleswig Holstein" - title="{{ g.site_title }}" /> - <img class="img-logo-small" src="/base/images/logo-quer.png" alt="Logo Schleswig Holstein" - title="{{ g.site_title }}" /> - </a> - {% endblock %} - </hgroup> - </div> - <h1 class='site-title'> {{ g.site_title }} </h1> - </div> - <div id="menu-button-and-title" data-module="tpsh_toggle_menu"> - <span class="fa fa-bars"></span> - <h1 class='site-title-mobile'> {{ g.site_title }} </h1> - </div> + {% block header_logo %} + <a class="logo" href="{{ h.url_for('home.index') }}"> + <img class="img-logo-large" src="{{ h.url_for_static_or_external(g.site_logo) }}" + alt="Logo Schleswig Holstein" title="{{ g.site_title }}" /> + <img class="img-logo-small" src="/base/images/logo-quer.png" alt="Logo Schleswig Holstein" + title="{{ g.site_title }}" /> + </a> + {% endblock %} + </hgroup> + </div> + <h1 class='site-title'> {{ g.site_title }} </h1> + </div> + <div id="menu-button-and-title" data-module="tpsh_toggle_menu"> + <span class="fa fa-bars"></span> + <h1 class='site-title-mobile'> {{ g.site_title }} </h1> </div> + </div> - <div class="container navigation-container"> - <div class='row navigation-row'> - <nav class="section navigation"> - <ul class="nav nav-pills"> - <li class="header-menu-mobile" data-module="tpsh_toggle_menu"> - <a>{{ _('Menu') }}</a> - <img src="/base/images/icon_close_white.svg" alt="Menü schließen" aria-label="Menü schließen"/> - </li> - {% block header_site_navigation_tabs %} - {{ - h.build_nav_main( - ('search', _('Datasets')), - ('organizations_index', _('Organizations')) - ) - }} - {% endblock %} - <li><a href="/infos">{{ _('Infos') }}</a></li> - {% set clazz='active' if c.action=='login' else ''%} - {% if h.check_access('package_create') %} - <li class='{{clazz}}'> - <a href="/harvest">{{ _('Harvester') }}</a> - </li> - <li class='{{clazz}}'> - {% link_for _('Upload'), controller='dataset', action='new', class_='text' %} - </li> - {% endif %} - {% if c.userobj %} - <li class="dropdown navbar-right {{clazz}}"> - {% set name = c.userobj.fullname if c.userobj.fullname else c.userobj.email%} - <a class="dropdown-toggle" data-toggle="dropdown" href="#"> - <svg class='user-icon' viewBox="0 0 54 54"> - <circle class='user-icon' cx="27" cy="17" r="7.5" /> - <path class='user-icon' - d="M42.5,44.5h-31v-6.4c0-4.7,3.9-8.6,8.6-8.6h13.9c4.7,0,8.6,3.9,8.6,8.6V44.5z" /> - </svg> - {{name}}</a> - <ul class="dropdown-menu" role="menu"> - <li> - <svg class='user-icon-small' viewBox="0 0 54 54"> - <circle cx="27" cy="17" r="7.5" /> - <path - d="M42.5,44.5h-31v-6.4c0-4.7,3.9-8.6,8.6-8.6h13.9c4.7,0,8.6,3.9,8.6,8.6V44.5z" /> - </svg> - <a href="{{ h.url_for('/user/') }}" title="logout" role="menuitem"> - <span class="text"> - {{ _('View profile') }} - </span> - </a> - </li> - <li> - <a href="{{ h.url_for('/user/edit') }}" title="logout" role="menuitem"> - <i class='fa fa-edit'></i> - <span class="text"> - {{ _('Edit profile') }} - </span> - </a> - </li> - <li> - <a href="{{ h.url_for('/user/_logout') }}" title="logout" role="menuitem"> - <i class='fa fa-sign-out'></i> - <span class="text">{{ _('Logout') }}</span> - </a> - </li> - </ul> - </a> - </li> - {% else %} - <li class='{{clazz}}'> - <a href="{{ h.url_for('/user/login') }}" title="login"> - <span class="text">{{ _('Login') }}</span> - </a> - </li> - {% endif %} - <li class="language-switch"> - <a href="/gebaerdensprache" title="{{ _('Sign language') }}" class="navGebaerdensprache"></a> - </li> - <li class="language-switch"> - <a href="/leichtesprache" title="{{ _('Simple language') }}" class="navLeichteSprache"></a> - </li> - </ul> - </nav> - <nav class="section navigation"> - <ul class="nav nav-pills"> - </ul> - </nav> - {% endblock %} - </div> + <div class="container navigation-container"> + <div class='row navigation-row'> + <nav class="section navigation"> + <ul class="nav nav-pills"> + <li class="header-menu-mobile" data-module="tpsh_toggle_menu"> + <a>{{ _('Menu') }}</a> + <img src="/base/images/icon_close_white.svg" alt="Menü schließen" aria-label="Menü schließen" /> + </li> + {% block header_site_navigation_tabs %} + {{ + h.build_nav_main( + ('search', _('Datasets')), + ('organizations_index', _('Organizations')) + ) + }} + {% endblock %} + <li><a href="/infos">{{ _('Infos') }}</a></li> + {% set clazz='active' if c.action=='login' else ''%} + {% if h.check_access('package_create') %} + <li class='{{clazz}}'> + <a href="/harvest">{{ _('Harvester') }}</a> + </li> + <li class='{{clazz}}'> + {% link_for _('Upload'), named_route='dataset.new', class_='text' %} + </li> + {% endif %} + {% if c.userobj %} + <li class="dropdown navbar-right {{clazz}}"> + {% set name = c.userobj.fullname if c.userobj.fullname else c.userobj.email%} + <a class="dropdown-toggle" data-toggle="dropdown" href="#"> + <svg class='user-icon' viewBox="0 0 54 54"> + <circle class='user-icon' cx="27" cy="17" r="7.5" /> + <path class='user-icon' + d="M42.5,44.5h-31v-6.4c0-4.7,3.9-8.6,8.6-8.6h13.9c4.7,0,8.6,3.9,8.6,8.6V44.5z" /> + </svg> + {{name}}</a> + <ul class="dropdown-menu" role="menu"> + <li> + <svg class='user-icon-small' viewBox="0 0 54 54"> + <circle cx="27" cy="17" r="7.5" /> + <path d="M42.5,44.5h-31v-6.4c0-4.7,3.9-8.6,8.6-8.6h13.9c4.7,0,8.6,3.9,8.6,8.6V44.5z" /> + </svg> + <a href="{{ h.url_for('user.read', id=c.userobj.name) }}" title="logout" role="menuitem"> + <span class="text"> + {{ _('View profile') }} + </span> + </a> + </li> + <li> + <a href="{{ h.url_for('user.edit', id=c.userobj.name) }}" title="logout" role="menuitem"> + <i class='fa fa-edit'></i> + <span class="text"> + {{ _('Edit profile') }} + </span> + </a> + </li> + <li> + <a href="{{ h.url_for('user.logout') }}" title="logout" role="menuitem"> + <i class='fa fa-sign-out'></i> + <span class="text">{{ _('Logout') }}</span> + </a> + </li> + </ul> + </a> + </li> + {% else %} + <li class='{{clazz}}'> + <a href="{{ h.url_for('user.login') }}" title="login"> + <span class="text">{{ _('Login') }}</span> + </a> + </li> + {% endif %} + <li class="language-switch"> + <a href="/gebaerdensprache" title="{{ _('Sign language') }}" class="navGebaerdensprache"></a> + </li> + <li class="language-switch"> + <a href="/leichtesprache" title="{{ _('Simple language') }}" class="navLeichteSprache"></a> + </li> + </ul> + </nav> + <nav class="section navigation"> + <ul class="nav nav-pills"> + </ul> + </nav> + {% endblock %} </div> + </div> </header> -{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/ckanext/odsh/templates/home/index.html b/ckanext/odsh/templates/home/index.html index bd567402..ff5122b7 100644 --- a/ckanext/odsh/templates/home/index.html +++ b/ckanext/odsh/templates/home/index.html @@ -4,7 +4,7 @@ {% block subtitle %}{{ _("Welcome") }}{% endblock %} {% block breadcrumb_content %} - <li class="active">{{ h.nav_link(_('Start'), controller='home', action='index') }}</li> + <li class="active">{{ h.nav_link(_('Start'), named_route='home.index') }}</li> {% endblock %} @@ -26,7 +26,7 @@ Datensätze entdecken <div class='home-groups-rows'> {% for group in group_row %} {% if group != '' %} - {% set href = h.add_url_param(controller='dataset', action='search',extras={'groups':group.id} ) %} + {% set href = h.add_url_param(named_route='dataset.search',extras={'groups':group.id} ) %} <div class='home_group_item'> <div class='home-groups-img'> <img src="/base/images/icon_kat_{{group.id}}.svg"/> diff --git a/ckanext/odsh/templates/organization/index.html b/ckanext/odsh/templates/organization/index.html index 45009cd2..58de4af2 100644 --- a/ckanext/odsh/templates/organization/index.html +++ b/ckanext/odsh/templates/organization/index.html @@ -3,7 +3,7 @@ {% block subtitle %}{{ _('Organizations') }}{% endblock %} {% block breadcrumb_content %} -<li class="active">{% link_for _('Organizations'), controller='organization', action='index' %}</li> +<li class="active">{% link_for _('Organizations'), named_route='organization.index' %}</li> {% endblock %} {% block page_header %}{% endblock %} @@ -27,7 +27,7 @@ {% block primary %} <div class="primary organization"> {% if h.check_access('organization_create') %} - {% link_for _('Add Organization'), controller='organization', action='new', class_='btn btn-primary', + {% link_for _('Add Organization'), named_route='organization.new', class_='btn btn-primary', icon='plus-square' %} {% endif %} <h1 class="hide-heading">{% block page_heading %}{{ _('Organizations') }}{% endblock %}</h1> @@ -45,7 +45,7 @@ <p class="empty"> {{ _('There are currently no organizations for this site') }}. {% if h.check_access('organization_create') %} - {% link_for _('How about creating one?'), controller='organization', action='new' %}</a>. + {% link_for _('How about creating one?'), named_route='organization.new' %}</a>. {% endif %} </p> {% endif %} diff --git a/ckanext/odsh/templates/organization/read.html b/ckanext/odsh/templates/organization/read.html index 60d9e9c7..7c842dee 100644 --- a/ckanext/odsh/templates/organization/read.html +++ b/ckanext/odsh/templates/organization/read.html @@ -2,7 +2,7 @@ {% block page_primary_action %} {% if h.check_access('package_create', {'owner_org': c.group_dict.id}) %} -{% link_for _('Add dataset'), controller='dataset', action='new', group=c.group_dict.id, class_='btn btn-primary', +{% link_for _('Add dataset'), named_route='dataset.new', group=c.group_dict.id, class_='btn btn-primary', icon='plus-square' %} {% endif %} {% endblock %} diff --git a/ckanext/odsh/templates/organization/snippets/organization_form.html b/ckanext/odsh/templates/organization/snippets/organization_form.html index e074b30e..1c4e8b1e 100644 --- a/ckanext/odsh/templates/organization/snippets/organization_form.html +++ b/ckanext/odsh/templates/organization/snippets/organization_form.html @@ -10,8 +10,8 @@ {{ form.input('title', label=_('Name'), id='field-name', placeholder=_('My Organization'), value=data.title, error=errors.title, classes=['control-full'], attrs=attrs) }} {# Perhaps these should be moved into the controller? #} - {% set prefix = h.url_for(controller='organization', action='read', id='') %} - {% set domain = h.url_for(controller='organization', action='read', id='', qualified=true) %} + {% set prefix = h.url_for(named_route='organization.read', id='') %} + {% set domain = h.url_for(named_route='organization.read', id='', qualified=true) %} {% set domain = domain|replace("http://", "")|replace("https://", "") %} {% set attrs = {'data-module': 'slug-preview-slug', 'data-module-prefix': domain, 'data-module-placeholder': '<organization>'} %} diff --git a/ckanext/odsh/templates/organization/snippets/organization_item.html b/ckanext/odsh/templates/organization/snippets/organization_item.html index 8bb15bc6..079c8ec8 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(controller='organization', action='read', id=organization.name) %} +{% set url = h.url_for(named_route='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/base.html b/ckanext/odsh/templates/package/base.html index 63718cd3..4cf8978b 100644 --- a/ckanext/odsh/templates/package/base.html +++ b/ckanext/odsh/templates/package/base.html @@ -11,15 +11,15 @@ {% set dataset = h.dataset_display_name(pkg) %} {% if pkg.organization %} {% set organization = h.get_translated(pkg.organization, 'title') or pkg.organization.name %} -<li>{% link_for _('Organizations'), controller='organization', action='index' %}</li> -<li>{% link_for organization|truncate(30), controller='organization', action='read', id=pkg.organization.name %}</li> +<li>{% link_for _('Organizations'), named_route='organization.index' %}</li> +<li>{% link_for organization|truncate(30), named_route='organization.read', id=pkg.organization.name %}</li> {% else %} -<li>{% link_for _('Datasets'), controller='dataset', action='search' %}</li> +<li>{% link_for _('Datasets'), named_route='dataset.search' %}</li> {% endif %} -<li {{ self.breadcrumb_content_selected() }}>{% link_for dataset|truncate(30), controller='dataset', action='read', +<li {{ self.breadcrumb_content_selected() }}>{% link_for dataset|truncate(30), named_route='dataset.read', id=pkg.name %}</li> {% else %} -<li>{% link_for _('Datasets'), controller='dataset', action='search' %}</li> +<li>{% link_for _('Datasets'), named_route='dataset.search' %}</li> <li class="active"><a href="">{{ _('Create Dataset') }}</a></li> {% endif %} {% endblock %} \ No newline at end of file diff --git a/ckanext/odsh/templates/package/edit_base.html b/ckanext/odsh/templates/package/edit_base.html index f383e668..6b2b285b 100644 --- a/ckanext/odsh/templates/package/edit_base.html +++ b/ckanext/odsh/templates/package/edit_base.html @@ -4,7 +4,7 @@ {% block breadcrumb_content %} {% if pkg %} -<li class="active">{% link_for _('Edit'), controller='dataset', action='edit', id=pkg.name %}</li> +<li class="active">{% link_for _('Edit'), named_route='dataset.edit', id=pkg.name %}</li> {% else %} <li class="active"><a href="">{{ _('Create Dataset') }}</a></li> {% endif %} @@ -20,7 +20,7 @@ {% block primary_content %} <div class="odsh-dataset-heading"> <div class='title'>Datensatz "{{h.dataset_display_name(pkg)}}" bearbeiten</div> - {% link_for _('Back'), controller='dataset', action='read', id=pkg.name, class_='btn btn-heading', icon='arrow-left' %} + {% link_for _('Back'), named_route='dataset.read', id=pkg.name, class_='btn btn-heading', icon='arrow-left' %} <span class="clear"></span> </div> {{ super() }} diff --git a/ckanext/odsh/templates/package/read.html b/ckanext/odsh/templates/package/read.html index e62a2fab..fd2de74b 100644 --- a/ckanext/odsh/templates/package/read.html +++ b/ckanext/odsh/templates/package/read.html @@ -14,14 +14,14 @@ {% set dataset = h.dataset_display_name(pkg) %} {% if pkg.organization %} {% set organization = h.get_translated(pkg.organization, 'title') or pkg.organization.name %} -<li>{% link_for organization|truncate(30), controller='organization', action='read', id=pkg.organization.name %}</li> +<li>{% link_for organization|truncate(30), named_route='organization.read', id=pkg.organization.name %}</li> {% else %} -<li>{% link_for _('Datasets'), controller='dataset', action='search' %}</li> +<li>{% link_for _('Datasets'), named_route='dataset.search' %}</li> {% endif %} -<li {{ self.breadcrumb_content_selected() }}>{% link_for dataset|truncate(30), controller='dataset', action='read', +<li {{ self.breadcrumb_content_selected() }}>{% link_for dataset|truncate(30), named_route='dataset.read', id=pkg.name %}</li> {% else %} -<li>{% link_for _('Datasets'), controller='dataset', action='search' %}</li> +<li>{% link_for _('Datasets'), named_route='dataset.search' %}</li> <li class="active"><a href="">{{ _('Create Dataset') }}</a></li> {% endif %} {% endblock breadcrumb_content %} @@ -43,7 +43,7 @@ <div class="odsh-dataset-edit-button"> {% if h.check_access('package_update', {'id':pkg.id }) %} <div> - {% link_for _('Manage Dataset'), controller='dataset', action='edit', id=pkg.name, class_='btn btn-primary btn-add-dataset', + {% link_for _('Manage Dataset'), named_route='dataset.edit', id=pkg.name, class_='btn btn-primary btn-add-dataset', icon='wrench' %} </div> {% endif %} @@ -88,7 +88,7 @@ {% snippet "package/snippets/resources_list.html", pkg=pkg, resources=pkg.resources %} {% if h.check_access('package_update', {'id':pkg.id }) %} <div class='add-resource-container'> - {% link_for _('Add new resource'), controller='resource', action='new', id=c.pkg_dict.name, class_='btn btn-primary', icon='plus' %} + {% link_for _('Add new resource'), named_route='resource.new', id=c.pkg_dict.name, class_='btn btn-primary', icon='plus' %} </div> {% endif %} {% endblock package_resources %} diff --git a/ckanext/odsh/templates/package/resource_edit_base.html b/ckanext/odsh/templates/package/resource_edit_base.html index f2c33fe4..4ada9a1e 100644 --- a/ckanext/odsh/templates/package/resource_edit_base.html +++ b/ckanext/odsh/templates/package/resource_edit_base.html @@ -8,7 +8,7 @@ {% block breadcrumb_content %} {{ super() }} {% if res %} - <li>{% link_for h.resource_display_name(res)|truncate(30), controller='resource', action='read', id=pkg.name, resource_id=res.id %}</li> + <li>{% link_for h.resource_display_name(res)|truncate(30), named_route='resource.read', id=pkg.name, resource_id=res.id %}</li> <li{% block breadcrumb_edit_selected %} class="active"{% endblock %}><a href="">{{ _('Edit') }}</a></li> {% endif %} {% endblock %} @@ -25,7 +25,7 @@ {% if res %} <div class="odsh-dataset-heading"> <span class='title'>Ressource {%if(res.name)%}"{{res.name}}"{%endif%} bearbeiten</span> - {% link_for _('Back'), controller='resource', action='read', id=pkg.name, resource_id=res.id, class_='btn btn-heading', icon='arrow-left' %} + {% link_for _('Back'), named_route='resource.read', id=pkg.name, resource_id=res.id, class_='btn btn-heading', icon='arrow-left' %} <span class="clear"></span> </div> {% endif %} diff --git a/ckanext/odsh/templates/package/resource_read.html b/ckanext/odsh/templates/package/resource_read.html index 3c11d74d..758b2e15 100644 --- a/ckanext/odsh/templates/package/resource_read.html +++ b/ckanext/odsh/templates/package/resource_read.html @@ -28,7 +28,7 @@ <ul> {% block resource_actions_inner %} {% if h.check_access('package_update', {'id':pkg.id }) %} - <li>{% link_for _('Manage'), controller='dataset', action='edit', id=pkg.name, resource_id=res.id, class_='btn', icon='wrench' %}</li> + <li>{% link_for _('Manage'), named_route='dataset.edit', id=pkg.name, resource_id=res.id, class_='btn', icon='wrench' %}</li> {% endif %} {% if res.url and h.is_url(res.url) %} <li> @@ -65,7 +65,7 @@ {% if not res.description and package.notes %} <h3>{{ _('From the dataset abstract') }}</h3> <blockquote>{{ h.markdown_extract(h.get_translated(package, 'notes')) }}</blockquote> - <p>{% trans dataset=package.title, url=h.url_for(controller='dataset', action='read', id=package['name']) %}Source: <a href="{{ url }}">{{ dataset }}</a>{% endtrans %} + <p>{% trans dataset=package.title, url=h.url_for(named_route='dataset.read', id=package['name']) %}Source: <a href="{{ url }}">{{ dataset }}</a>{% endtrans %} {% endif %} </div> {% endblock %} diff --git a/ckanext/odsh/templates/package/search.html b/ckanext/odsh/templates/package/search.html index 61e64b65..5db3c32d 100644 --- a/ckanext/odsh/templates/package/search.html +++ b/ckanext/odsh/templates/package/search.html @@ -7,12 +7,12 @@ {% endblock styles %} {% block breadcrumb_content %} - <li class="active">{{ h.nav_link(_('Datasets'), controller='dataset', action='search', highlight_actions = 'new index') }}</li> + <li class="active">{{ h.nav_link(_('Datasets'), named_route='dataset.search', highlight_actions = 'new index') }}</li> {% endblock %} {% block toolbar %} {{ super() }} -<form id='dataset-search-box-form' class="section site-search simple-input" action="{% url_for controller='dataset', action='search' %}" +<form id='dataset-search-box-form' class="section site-search simple-input" action="{% url_for named_route='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(controller='dataset', action='search')}}">{{ _('Reset') }}</a> + <a href="{{h.url_for(named_route='dataset.search')}}">{{ _('Reset') }}</a> </div> </div> </div> diff --git a/ckanext/odsh/templates/package/snippets/package_form.html b/ckanext/odsh/templates/package/snippets/package_form.html index ee6c6436..1b0c9226 100644 --- a/ckanext/odsh/templates/package/snippets/package_form.html +++ b/ckanext/odsh/templates/package/snippets/package_form.html @@ -28,7 +28,7 @@ <div class="span6"> {% block delete_button %} {% if h.check_access('package_delete', {'id': data.id}) and not data.state == 'deleted' %} - <a class="btn btn-danger pull-left" href="{% url_for controller='dataset', action='delete', id=data.id %}" + <a class="btn btn-danger pull-left" href="{% url_for named_route='dataset.delete', id=data.id %}" data-module="confirm-action" data-module-content="{{ _('Are you sure you want to delete this dataset?') }}"> {% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a> {% endif %} diff --git a/ckanext/odsh/templates/package/snippets/resource_form.html b/ckanext/odsh/templates/package/snippets/resource_form.html index 0c196b9e..ce277790 100644 --- a/ckanext/odsh/templates/package/snippets/resource_form.html +++ b/ckanext/odsh/templates/package/snippets/resource_form.html @@ -3,7 +3,7 @@ {% set data = data or {} %} {% set errors = errors or {} %} {% set active = data and data.state=='active' %} -{% set action = form_action or h.url_for(controller='resource', action='new', id=pkg_name) %} +{% set action = form_action or h.url_for(named_route='resource.new', id=pkg_name) %} <form id="resource-edit" class="dataset-form dataset-resource-form {%if(data)%}resource-edit-form{%endif%}" method="post" action="{{ action }}" data-module="basic-form resource-form" enctype="multipart/form-data" novalidate> {% block stages %} diff --git a/ckanext/odsh/templates/package/snippets/resource_item.html b/ckanext/odsh/templates/package/snippets/resource_item.html index 33c97155..9b65a49d 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(controller='resource', action=url_action, id=pkg.name, resource_id=res.id) %} +{% set url = h.url_for(named_route='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 %} @@ -30,7 +30,7 @@ <div aria-hidden="true" class="icon icon-download"></div> </a> {% if can_edit %} - <a href="{{ h.url_for(controller='resource', action='edit', id=pkg.name, resource_id=res.id) }}"> + <a href="{{ h.url_for(named_route='resource.edit', id=pkg.name, resource_id=res.id) }}"> <div class="icon icon-edit"></div> </a> {% endif %} @@ -52,7 +52,7 @@ <div aria-hidden="true" class="icon icon-download"></div> </a> {% if can_edit %} - <a href="{{ h.url_for(controller='resource', action='edit', id=pkg.name, resource_id=res.id) }}"> + <a href="{{ h.url_for(named_route='resource.edit', id=pkg.name, resource_id=res.id) }}"> <div class="icon icon-edit"></div> </a> {% endif %} diff --git a/ckanext/odsh/templates/package/snippets/stages.html b/ckanext/odsh/templates/package/snippets/stages.html index c498d12d..0a7378a5 100644 --- a/ckanext/odsh/templates/package/snippets/stages.html +++ b/ckanext/odsh/templates/package/snippets/stages.html @@ -33,7 +33,7 @@ Example: {# stage 1 #} <button class="highlight" name="save" value="go-resources" type="submit">{{ _('Add dataset') }}</button> {% else %} - {% link_for _('Add dataset'), controller='dataset', action='new', class_="highlight" %} + {% link_for _('Add dataset'), named_route='dataset.new', class_="highlight" %} {% endif %} {% endif %} </li> diff --git a/ckanext/odsh/templates/package/view_edit_base.html b/ckanext/odsh/templates/package/view_edit_base.html index ed445941..822af310 100644 --- a/ckanext/odsh/templates/package/view_edit_base.html +++ b/ckanext/odsh/templates/package/view_edit_base.html @@ -6,9 +6,9 @@ {% block breadcrumb_edit_selected %}{% endblock %} {% block content_action %} - {% link_for _('All views'), controller='resource', action='views', id=pkg.name, resource_id=res.id, class_='btn', icon='arrow-left' %} + {% link_for _('All views'), named_route='resource.views', id=pkg.name, resource_id=res.id, class_='btn', icon='arrow-left' %} {% if res %} - {% set url = h.url_for(controller='resource', action='read', id=pkg.name, resource_id=res.id) ~ '?view_id=' ~ resource_view.id %} + {% set url = h.url_for(named_route='resource.read', id=pkg.name, resource_id=res.id) ~ '?view_id=' ~ resource_view.id %} <a href="{{ url }}" class="btn"><i class="fa fa-eye"></i> {{ _('View view') }}</a> {% endif %} {% endblock %} diff --git a/ckanext/odsh/templates/snippets/follow_button.html b/ckanext/odsh/templates/snippets/follow_button.html index 4085eff5..918b23c7 100644 --- a/ckanext/odsh/templates/snippets/follow_button.html +++ b/ckanext/odsh/templates/snippets/follow_button.html @@ -4,12 +4,12 @@ {% endif %} {% if following %} -<a href="{{ h.url_for(controller=controller, action='unfollow', id=obj_id) }}" class="{% block following_class %}btn btn-primary{% endblock %}" +<a href="{{ h.url_for(obj_type + '.unfollow', id=obj_id) }}" class="{% block following_class %}btn btn-primary{% endblock %}" data-module="follow" data-module-type="{{ obj_type }}" data-module-id="{{ obj_id }}" data-module-action="unfollow"> {{ _('Unfollow') }} </a> {% else %} -<a href="{{ h.url_for(controller=controller, action='follow', id=obj_id) }}" class="{% block unfollowing_class %}btn btn-primary {% endblock %}" +<a href="{{ h.url_for(obj_type + '.follow', id=obj_id) }}" class="{% block unfollowing_class %}btn btn-primary {% endblock %}" data-module="follow" data-module-type="{{ obj_type }}" data-module-id="{{ obj_id }}" data-module-action="follow"> {{ _('Follow') }} </a> diff --git a/ckanext/odsh/templates/snippets/organization.html b/ckanext/odsh/templates/snippets/organization.html index d24457c0..3465d5cd 100644 --- a/ckanext/odsh/templates/snippets/organization.html +++ b/ckanext/odsh/templates/snippets/organization.html @@ -84,7 +84,7 @@ Example: {% if organization.description %} <p> {{ h.markdown_extract(organization.description, 180) }} - {% link_for _('read more'), controller='organization', action='about', id=organization.name %} + {% link_for _('read more'), named_route='organization.about', id=organization.name %} </p> {% else %} <p class="empty">{{ _('There is no description for this organization') }}</p> diff --git a/ckanext/odsh/templates/snippets/package_item.html b/ckanext/odsh/templates/snippets/package_item.html index 5c85b2aa..52293978 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(controller='dataset', action='read', id=package.name),title=_('View {organization_name}').format(organization_name=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))}} {% 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(controller='dataset', action='read', id=package.name) }}" class="label dataformat-label" + <a href="{{ h.url_for(named_route='dataset.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 09b45a23..ffd38b09 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([''], controller='feeds', action='custom') }}> + <a aria-label="{{ _('rss feeds') }}" href={{h.remove_url_param([''], named_route='feeds.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 e1c84988..3167301e 100644 --- a/ckanext/odsh/templates/user/login.html +++ b/ckanext/odsh/templates/user/login.html @@ -7,31 +7,31 @@ {% endblock skip %} {% block breadcrumb_content %} -<li class="active">{{ h.nav_link(_('Login'), controller='user', action='login') }}</li> + <li class="active">{{ h.nav_link(_('Login'), named_route='user.login') }}</li> {% endblock %} {% block primary_content %} -<section class="module"> + <section class="module"> <div class="module-content"> - <h2 class="page-heading">{% block page_heading %}{{ _('Login') }}{% endblock %}</h2> - {% block form %} - {% snippet "user/snippets/login_form.html", action=c.login_handler, error_summary=error_summary %} - {% endblock %} + <h2 class="page-heading">{% block page_heading %}{{ _('Login') }}{% endblock %}</h2> + {% block form %} + {% snippet "user/snippets/login_form.html", error_summary=error_summary %} + {% endblock %} </div> -</section> -{% endblock %} + </section> + {% endblock %} -{% block secondary_content %} + {% block secondary_content %} -{% block help_forgotten %} -<section class="module module-narrow module-shallow"> - {% block help_forgotten_inner %} - <span>{{ _('Forgotten your password?') }}:</span> - {% block help_forgotten_button %} - <a class="btn-forget-password" href="{{ h.url_for(controller='user', action='request_reset') }}"> - {{ _('Change password') }}</a> - {% endblock %} - {% endblock %} -</section> -{% endblock %} -{% endblock %} + {% block help_forgotten %} + <section class="module module-narrow module-shallow"> + {% 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) }}"> + {{ _('Change password') }}</a> + {% endblock %} + {% endblock %} + </section> + {% endblock %} +{% endblock %} \ No newline at end of file diff --git a/ckanext/odsh/templates/user/logout.html b/ckanext/odsh/templates/user/logout.html index 50d38b06..3328f459 100644 --- a/ckanext/odsh/templates/user/logout.html +++ b/ckanext/odsh/templates/user/logout.html @@ -1,7 +1,7 @@ {% extends "page.html" %} {% block breadcrumb_content %} - <li class="active">{{ h.nav_link(_('Logout'), controller='user', action='logout') }}</li> + <li class="active">{{ h.nav_link(_('Logout'), named_route='user.logout') }}</li> {% endblock %} {% block subtitle %}{{ _('Logged Out') }}{% endblock %} diff --git a/ckanext/odsh/tests/test_routes.py b/ckanext/odsh/tests/test_routes.py index 3ea06196..59ddeffc 100644 --- a/ckanext/odsh/tests/test_routes.py +++ b/ckanext/odsh/tests/test_routes.py @@ -36,7 +36,7 @@ class TestRoutes: def _get_package_new_form(self): # self.env = {'REMOTE_USER': 'ckanuser'} response = self.app.get( - url=url_for(controller='dataset', action='new') + url=url_for(named_route='dataset.new') # extra_environ=self.env, ) return response.forms['dataset-edit'] diff --git a/ckanext/odsh/tests/test_search.py b/ckanext/odsh/tests/test_search.py index 5989e591..854a7917 100644 --- a/ckanext/odsh/tests/test_search.py +++ b/ckanext/odsh/tests/test_search.py @@ -246,7 +246,7 @@ class TestSearch(helpers.FunctionalTestBase): return helpers.webtest_submit(search_form) def _perform_search_for_form(self, form): - search_url = url_for(controller='dataset', action='search') + search_url = url_for(named_route='dataset.search') search_response = self._get_test_app().get(search_url) search_form = search_response.forms[form] diff --git a/ckanext/odsh/tests/test_upload.py b/ckanext/odsh/tests/test_upload.py index 206cb18d..50f54422 100644 --- a/ckanext/odsh/tests/test_upload.py +++ b/ckanext/odsh/tests/test_upload.py @@ -237,7 +237,7 @@ class TestUpload(helpers.FunctionalTestBase): ) self.env = {'REMOTE_USER': user['name'].encode('ascii')} response = app.get( - url=url_for(controller='dataset', action='new'), + url=url_for(named_route='dataset.new'), extra_environ=self.env, ) return response.forms['dataset-edit'] @@ -246,7 +246,7 @@ class TestUpload(helpers.FunctionalTestBase): app = self._get_test_app() # user = factories.User() response = app.get( - url=url_for(controller='dataset', action='edit', id=id), + url=url_for(named_route='dataset.edit', id=id), extra_environ=self.env, ) return response.forms['dataset-edit'] @@ -255,7 +255,7 @@ class TestUpload(helpers.FunctionalTestBase): app = self._get_test_app() # user = factories.User() response = app.get( - url=url_for(controller='dataset', action='read', id=id), + url=url_for(named_route='dataset.read', id=id), extra_environ=self.env, ) return response diff --git a/ckanext/odsh/tests/test_user.py b/ckanext/odsh/tests/test_user.py index 18d14ac6..5dede8b1 100644 --- a/ckanext/odsh/tests/test_user.py +++ b/ckanext/odsh/tests/test_user.py @@ -83,7 +83,7 @@ class TestUser(helpers.FunctionalTestBase): def _logout(self): app = self._get_test_app() - logout_url = url_for(controller='user', action='logout') + logout_url = url_for(named_route='user.logout') logout_response = app.get(logout_url, status=302) final_response = helpers.webtest_maybe_follow(logout_response) return final_response diff --git a/ckanext/odsh/views/feed.py b/ckanext/odsh/views/feed.py index 793c50eb..16e6947e 100644 --- a/ckanext/odsh/views/feed.py +++ b/ckanext/odsh/views/feed.py @@ -44,12 +44,10 @@ def custom(): request.args, item_count=item_count, limit=data_dict['rows'], - controller=u'feeds', - action=u'custom') + named_route='feeds.custom') feed_url = ckan_feed._feed_url(request.args, - controller='feeds', - action='custom') + named_route='feeds.custom') atom_url = h._url_with_params('/feeds/custom.atom', list(search_params.items())) -- GitLab