Skip to content

Commit

Permalink
Merge pull request #8 from datopian/ckan-2.10.1-support
Browse files Browse the repository at this point in the history
Upgrade change for CKAN 2.10.x
  • Loading branch information
Mikanebu authored Oct 31, 2023
2 parents aab6e0f + fe9ac36 commit a78d5ce
Show file tree
Hide file tree
Showing 15 changed files with 283 additions and 162 deletions.
6 changes: 3 additions & 3 deletions ckanext/rvr/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def package_search(context, data_dict):

# check if some extension needs to modify the search params
for item in plugins.PluginImplementations(plugins.IPackageController):
data_dict = item.before_search(data_dict)
data_dict = item.before_dataset_search(data_dict)

# the extension may have decided that it is not necessary to perform
# the query
Expand Down Expand Up @@ -389,7 +389,7 @@ def get_filtered_packages(
if context.get('for_view'):
for item in plugins.PluginImplementations(
plugins.IPackageController):
package_dict = item.before_view(package_dict)
package_dict = item.before_dataset_view(package_dict)
# Check daterange
is_in_range = True
for k in dateranges:
Expand Down Expand Up @@ -477,7 +477,7 @@ def get_filtered_packages(

# check if some extension needs to modify the search results
for item in plugins.PluginImplementations(plugins.IPackageController):
search_results = item.after_search(search_results, data_dict)
search_results = item.after_dataset_search(search_results, data_dict)

# After extensions have had a chance to modify the facets, sort them by
# display name.
Expand Down
2 changes: 1 addition & 1 deletion ckanext/rvr/assets/css/rvr.css
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ html.js body div.hero div.container.content div.row.row1 div.searchbox-mobile{
}


.module-heading[data-toggle="collapse"] {
.module-heading[data-bs-toggle="collapse"] {
cursor: pointer;
}

Expand Down
15 changes: 8 additions & 7 deletions ckanext/rvr/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def get_specific_page(name=""):
None, {
'page_type': 'page'}
)

new_list = []
for page in page_list:
if page['name'] == name:
Expand Down Expand Up @@ -86,7 +87,7 @@ def build_pages_nav_main(*args):
# Different CKAN versions use different route names - gotta catch em all!
about_menu_routes = ['about', 'home.about']
group_menu_routes = ['group_index', 'home.group_index']
org_menu_routes = ['organizations_index', 'home.organizations_index']
org_menu_routes = ['organizations.index', 'home.organizations.index']

new_args = []
for arg in args:
Expand All @@ -103,11 +104,9 @@ def build_pages_nav_main(*args):
pages_list = tk.get_action('ckanext_pages_list')(None, {'order': True, 'private': False})

page_name = ''

if (tk.c.action in ('pages_show', 'blog_show')
and tk.c.controller == 'ckanext.pages.controller:PagesController'):
page_name = tk.c.environ['routes.url'].current().split('/')[-1]
output = output + get_nav_transport()
if tk.get_endpoint() in (('pages', 'pages_show'), ('pages', 'blog_show')):
page_name = tk.request.path.split('/')[-1]
#output = output + get_nav_transport()
for page in pages_list:
type_ = 'blog' if page['page_type'] == 'blog' else 'pages'
name = urllib.parse.quote(page['name'].encode('utf-8')) #.decode('utf-8')
Expand All @@ -131,7 +130,9 @@ def get_facet_description(facet_name):
'tags': tk._('Selbstgewählte Schlagworte'),
'res_format': tk._('Zur Auswahl stehende Dateiformate'),
'license_id': tk._('Rechtliche Vorgaben zur Nutzung der Daten'),
'date_filters': tk._('Filter nach Erstellungsdatum der Daten')
'date_filters': tk._('Filter nach Erstellungsdatum der Daten'),
'frequency': tk._('Frequenz'),
'source_type': tk._('Quelle Typ')
}
return facet_description[facet_name]

Expand Down
1 change: 0 additions & 1 deletion ckanext/rvr/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class RvrPlugin(p.SingletonPlugin, tk.DefaultDatasetForm, DefaultTranslation):
p.implements(p.IFacets, inherit=True)
p.implements(p.IBlueprint)
p.implements(p.IActions)
p.implements(p.IRoutes, inherit=True)

# IConfigurer
def update_config(self, config_):
Expand Down
9 changes: 4 additions & 5 deletions ckanext/rvr/templates/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,10 @@ <h4 class="">
</div>

<div class="social-media">
<a href="https://www.facebook.com/RVR.Ruhr" target="_blank"><i class="fa fa-facebook-f"></i></a>
<a href="https://twitter.com/rvr_ruhr" target="_blank"><i class="fa fa-twitter"></i></a>
<a href="https://www.instagram.com/rvr.ruhr/" target="_blank"><i class="fa fa-instagram"></i></a>
<a href="https://www.youtube.com/channel/UCCJDPVQdYd_TRVqT_sutt7g" target="_blank"><i
class="fa fa-youtube-play"></i></a>
<a href="https://www.facebook.com/RVR.Ruhr" target="_blank"><i class="fa-brands fa-facebook"></i></a>
<a href="https://twitter.com/rvr_ruhr" target="_blank"><i class="fa-brands fa-twitter"></i></a>
<a href="https://www.instagram.com/rvr.ruhr/" target="_blank"><i class="fa-brands fa-instagram"></i></a>
<a href="https://www.youtube.com/channel/UCCJDPVQdYd_TRVqT_sutt7g" target="_blank"><i class="fa-brands fa-youtube"></i></a>
</div>
</div>
</div>
Expand Down
161 changes: 121 additions & 40 deletions ckanext/rvr/templates/header.html
Original file line number Diff line number Diff line change
@@ -1,52 +1,133 @@
{% ckan_extends %}
{% set dataset_type = h.default_package_type() %}

{% block header_site_navigation %}
<nav class="section navigation">
<ul class="nav nav-pills">
{% block header_site_navigation_tabs %}
{{ h.build_nav_main(
('dataset.search', _('Datasets')),
('organization.index', _('Organizations')),
('group.index', _('Groups')),
('page.faq', _('FAQ')),
('home.about', _('About')) ) }}
{% endblock %}
</ul>
</nav>
{% endblock %}

{% block header_site_search %}
<div class="menu-right container-fluid">
<form class="section site-search simple-input" action="{% url_for 'dataset.search' %}" method="get">
<div class="field">
<label for="field-sitewide-search">{% block header_site_search_label %}{{ _('Search Datasets') }}{% endblock %}</label>
<input id="field-sitewide-search" type="text" class="form-control" name="q" placeholder="{{ _('Search') }}" />
<button class="btn-search" type="submit"><i class="fa fa-search"></i></button>
{% block header_wrapper %} {% block header_account %}
<div class="account-masthead">
<div class="container">
{% block header_account_container_content %} {% if c.userobj %}
<div class="account avatar authed" data-module="me" data-me="{{ c.userobj.id }}">
<ul class="list-unstyled">
{% block header_account_logged %} {% if c.userobj.sysadmin %}
<li>
<a href="{{ h.url_for('admin.index') }}" title="{{ _('Sysadmin settings') }}">
<i class="fa fa-gavel" aria-hidden="true"></i>
<span class="text">{{ _('Admin') }}</span>
</a>
</li>
{% endif %}
{% block header_account_profile %}
<li>
<a href="{{ h.url_for('user.read', id=c.userobj.name) }}" class="image" title="{{ _('View profile') }}">
{{ h.user_image((c.user if c and c.user else ''), size=22) }}
<span class="username">{{ c.userobj.display_name }}</span>
</a>
</li>
{% endblock %}
{% block header_dashboard %}
<li>
<a href="{{ h.url_for('dashboard.datasets') }}" title="{{ _("View dashboard") }}">
<i class="fa fa-tachometer" aria-hidden="true"></i>
<span class="text">{{ _('Dashboard') }}</span>
</a>
</li>
{% endblock %}
{% block header_account_settings_link %}
<li>
<a href="{{ h.url_for('user.edit', id=c.userobj.name) }}" title="{{ _('Profile settings') }}">
<i class="fa fa-cog" aria-hidden="true"></i>
<span class="text">{{ _('Profile settings') }}</span>
</a>
</li>
{% endblock %} {% block header_account_log_out_link %}
<li>
<a href="{{ h.url_for('user.logout') }}" title="{{ _('Log out') }}">
<i class="fa fa-sign-out" aria-hidden="true"></i>
<span class="text">{{ _('Log out') }}</span>
</a>
</li>
{% endblock %} {% endblock %}
</ul>
</div>
</form>

<div class="social-media navbar-left">
<div class="social-icons">
<a href="https://www.facebook.com/RVR.Ruhr" target="blank"><i class="fa fa-facebook"></i></a>
<a href="https://twitter.com/metropole_ruhr" target="blank"><i class="fa fa-twitter"></i></a>
<a href="https://www.instagram.com/rvr.ruhr/"target="blank"><i class="fa fa-instagram"></i></a>
<a href="https://www.youtube.com/channel/UCCJDPVQdYd_TRVqT_sutt7g" target="blank"><i class="fa fa-youtube-play"></i></a>
{% else %}
<nav class="account not-authed" aria-label="{{ _('Account') }}">
<ul class="list-unstyled">
{% block header_account_notlogged %}
<li>{% link_for _('Log in'), named_route='user.login' %}</li>
{% if h.check_access('user_create') %}
<li>{% link_for _('Register'), named_route='user.register', class_='sub' %}</li>
{% endif %} {% endblock %}
</ul>
</nav>
{% endif %} {% endblock %}
</div>
</div>

</div>
{% endblock %}
<header class="navbar navbar-static-top masthead">
<div class="container">
{% block header_debug %} {% if g.debug and not g.debug_supress_header %}
<div class="debug">Blueprint : {{ g.blueprint }}<br />View : {{ g.view }}</div>
{% endif %} {% endblock %}
<nav class="navbar navbar-expand-lg navbar-light">
<hgroup class="{{ g.header_class }} navbar-left">

{% block header_logo %}
{% if g.site_logo %}
<a class="logo" href="{{ h.url_for('home.index') }}">
<img src="{{ h.url_for_static_or_external(g.site_logo) }}" alt="{{ g.site_title }}"
title="{{ g.site_title }}" />
</a>
{% else %}
<h1>
<a href="{{ h.url_for('home.index') }}">{{ g.site_title }}</a>
</h1>
{% if g.site_description %}
<h2>{{ g.site_description }}</h2>
{% endif %}
{% endif %}
{% endblock %}

{% endblock%}
</hgroup>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#main-navigation-toggle"
aria-controls="main-navigation-toggle" aria-expanded="false" aria-label="Toggle navigation">
<span class="fa fa-bars text-white"></span>
</button>

<div class="main-navbar collapse navbar-collapse" id="main-navigation-toggle">
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
{% block header_site_navigation %}
{% block header_site_navigation_tabs %}
{% set org_type = h.default_group_type('organization') %}
{% set group_type = h.default_group_type('group') %}

{% block header_wrapper %}
{{ h.build_nav_main(
(dataset_type ~ '.search', h.humanize_entity_type('package', dataset_type, 'main nav') or _('Datasets'), ["dataset", "resource"]),
(org_type ~ '.index',
h.humanize_entity_type('organization', org_type, 'main nav') or _('Organizations'), ['organization']),
(group_type ~ '.index',
h.humanize_entity_type('group', group_type, 'main nav') or _('Groups'), ['group']),
('page.faq', _('FAQ')),
('home.about', _('About')) ) }}
{% endblock %}
</ul>

{{ super() }}
{% endblock %}
{% block header_site_search %}
<form class="d-flex site-search" action="{% url_for dataset_type ~ '.search' %}" method="get">
<label class="d-none" for="field-sitewide-search">{% block header_site_search_label %}{{ h.humanize_entity_type('package', dataset_type, 'search_placeholder') or _('Search Datasets...') }}{% endblock %}</label>
<input id="field-sitewide-search" class="form-control me-2" type="text" name="q" placeholder="{{ _('Search') }}" aria-label="{{ h.humanize_entity_type('package', dataset_type, 'search_placeholder') or _('Search datasets...') }}"/>
<button class="btn" type="submit" aria-label="{{ _('Submit') }}"><i class="fa fa-search"></i></button>
</form>
<div class="social-icons">
<a href="https://www.facebook.com/RVR.Ruhr" target="blank"><i class="fa-brands fa-facebook"></i></a>
<a href="https://twitter.com/metropole_ruhr" target="blank"><i class="fa-brands fa-twitter"></i></a>
<a href="https://www.instagram.com/rvr.ruhr/" target="blank"><i class="fa-brands fa-instagram"></i></a>
<a href="https://www.youtube.com/channel/UCCJDPVQdYd_TRVqT_sutt7g" target="blank"><i class="fa-brands fa-youtube"></i></a>
</div>
{% endblock %}
</div>
</nav>
</div>
</header>
<div class="jumbotron">
<header>
<h1> Open Data Portal Metropole Ruhr</h1>
</header>
</div>


{% endblock %}
13 changes: 6 additions & 7 deletions ckanext/rvr/templates/package/read_base.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{% extends "package/base.html" %}

{% set default_group_type = h.default_group_type('group') %}

{% block subtitle %}{{ h.dataset_display_name(pkg) }} {{ g.template_title_delimiter }} {{ super() }}{% endblock %}

{% block head_extras -%}
Expand All @@ -10,17 +12,14 @@
{% endblock -%}

{% block content_action %}
{% if not is_activity_archive %}
{% if h.check_access('package_update', {'id':pkg.id }) %}
{% link_for _('Manage'), named_route=pkg.type ~ '.edit', id=pkg.name, class_='btn btn-default', icon='wrench' %}
{% endif %}
{% if h.check_access('package_update', {'id':pkg.id }) %}
{% link_for _('Manage'), named_route=pkg.type ~ '.edit', id=pkg.name, class_='btn btn-light', icon='wrench' %}
{% endif %}
{% endblock %}

{% block content_primary_nav %}
{{ h.build_nav_icon(dataset_type ~ '.read', _('Dataset'), id=pkg.id if is_activity_archive else pkg.name, icon='sitemap') }}
{{ h.build_nav_icon(dataset_type ~ '.groups', _('Groups'), id=pkg.id if is_activity_archive else pkg.name, icon='users') }}
{{ h.build_nav_icon(dataset_type ~ '.activity', _('Activity Stream'), id=pkg.id if is_activity_archive else pkg.name, icon='clock-o') }}
{{ h.build_nav_icon(dataset_type ~ '.read', _('Dataset'), id=pkg.name, icon='sitemap') }}
{{ h.build_nav_icon(dataset_type ~ '.groups', h.humanize_entity_type('group', default_group_type, 'content tab') or _('Groups'), id=pkg.name, icon='users') }}
{% endblock %}

{% block secondary_content %}
Expand Down
2 changes: 1 addition & 1 deletion ckanext/rvr/templates/package/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h3>{{ _('Filterbereich') }}</h3>
{{ h.snippet('snippets/facet_list.html', title=facet_titles[facet], name=facet, search_facets=search_facets, dateranges=dateranges, active_range=active_range, daterange_options=daterange_options ) }}
{% endfor %}
</div>
<a class="close no-text hide-filters"><i class="fa fa-times-circle"></i><span class="text">close</span></a>
<a class="close no-text hide-filters"><i class="fas fa-times-circle"></i><span class="text">close</span></a>
</div>
{% endblock %}

Expand Down
1 change: 1 addition & 0 deletions ckanext/rvr/templates/package/snippets/package_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{# This provides a full page that renders a form for adding a dataset. It can
then itself be extended to add/remove blocks of functionality. #}
<form id="dataset-edit" class="dataset-form" method="post" action="{{ action }}" data-module="basic-form" novalidate>
{{ h.csrf_input() }}
{% block stages %}
{{ h.snippet('package/snippets/stages.html', stages=stage) }}
{% endblock %}
Expand Down
20 changes: 10 additions & 10 deletions ckanext/rvr/templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
{%- block content %}
{% block maintag %}<div class="main">{% endblock %}
<div id="content" class="container">
{% block main_content %}
{% block main_content %}
{% block flash %}
<div class="flash-messages">
{% block flash_inner %}
{% for message in h.flash.pop_messages() | list %}
<div class="alert fade in {{ message.category }}">
{{ h.literal(message) }}
</div>
{% endfor %}
{% endblock %}
</div>
<div class="flash-messages">
{% block flash_inner %}
{% for category, message in h.get_flashed_messages(with_categories=true) %}
<div class="alert alert-dismissible fade show {{ category }}">
{{ h.literal(message) }}
</div>
{% endfor %}
{% endblock %}
</div>
{% endblock %}

{% block toolbar %}
Expand Down
Loading

0 comments on commit a78d5ce

Please sign in to comment.