diff --git a/CHANGELOG.md b/CHANGELOG.md index e4878c259514aaa5a486639fcfcea1116ae59c3b..6f9558a2654f14a261ec3b2dc5e3538e443a9a99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added + +- Added a "Dashboard" link to the account navigation for quick access to the user dashboard. + +### Removed + +- Removed custom dashboard blueprint and associated view as these functionalities are covered by the default CKAN implementation. + ### Fixed - Added a check to ensure `data.id` is present before rendering the delete button in the dataset edit form. This prevents server errors when `data.id` is not available, e.g., for new datasets. diff --git a/ckanext/odsh/plugin.py b/ckanext/odsh/plugin.py index 2078ae169b16e1f94f871656b518cfc91eb775eb..9ca9f663eb19823be1e89bd5a9df04ad2fed40c2 100644 --- a/ckanext/odsh/plugin.py +++ b/ckanext/odsh/plugin.py @@ -21,7 +21,6 @@ import ckanext.odsh.tools as tools from ckanext.odsh.views import default # from ckanext.odsh.views import package from ckanext.odsh.views import user -from ckanext.odsh.views import dashboard from ckanext.odsh.views import harvest from ckanext.odsh.views import feed # from ckanext.dcat import blueprints as dcat_view @@ -75,15 +74,6 @@ class OdshPlugin(p.SingletonPlugin, DefaultTranslation, tk.DefaultDatasetForm): view_func=user.index, strict_slashes=False) # bp_user.add_url_rule(u'/user/register', view_func=user.register) - # Dashboard - bp_dashboard = dashboard.blueprint - bp_dashboard.add_url_rule( - u'/dashboard/datasets', view_func=dashboard.datasets) - bp_dashboard.add_url_rule( - u'/dashboard/organizations', view_func=dashboard.organizations) - bp_dashboard.add_url_rule( - u'/dashboard/groups', view_func=dashboard.groups) - # Harvest bp_harvest = harvest.blueprint bp_harvest.add_url_rule(u'/harvest', view_func=harvest.search, strict_slashes=False) @@ -95,7 +85,7 @@ class OdshPlugin(p.SingletonPlugin, DefaultTranslation, tk.DefaultDatasetForm): bp_feed = feed.blueprint bp_feed.add_url_rule(u'/feeds/custom.atom', methods=[u'GET'], view_func=feed.custom) - return [bp_default, bp_user, bp_dashboard, bp_harvest, bp_feed] #bp_package + return [bp_default, bp_user, bp_harvest, bp_feed] # bp_package # IActions diff --git a/ckanext/odsh/templates/header.html b/ckanext/odsh/templates/header.html index 429f730b883cf976bc2b3ba1e3617dc23e400021..0a957ee0ea197ecc8a89507913afde4498880513 100644 --- a/ckanext/odsh/templates/header.html +++ b/ckanext/odsh/templates/header.html @@ -18,15 +18,15 @@ </a> {% endblock %} </hgroup> - <h1 class='site-title'> {{ g.site_title }} </h1> + <h1 class="site-title"> {{ g.site_title }} </h1> <div id="menu-button-and-title" aria-label="{{ _('Toggle menu') }}" data-module="odsh_toggle_menu"> <span class="fa fa-bars"></span> - <h1 class='site-title-mobile'> {{ g.site_title }} </h1> + <h1 class="site-title-mobile"> {{ g.site_title }} </h1> </div> </div> <div class="container navigation-container"> - <div class='row navigation-row'> + <div class="row navigation-row"> <nav class="navigation"> <ul class="nav nav-pills"> <li class="header-menu-mobile" data-module="odsh_toggle_menu"> @@ -44,10 +44,10 @@ <li><a href="/infos">{{ _('Infos') }}</a></li> {% set clazz='active' if c.action=='login' else ''%} {% if h.check_access('package_create') %} - <li class='{{clazz}}'> + <li class="{{clazz}}"> <a href="/harvest">{{ _('Harvester') }}</a> </li> - <li class='{{clazz}}'> + <li class="{{clazz}}"> {% link_for _('Upload'), named_route='dataset.new', class_='text' %} </li> {% endif %} @@ -56,9 +56,9 @@ <li class="dropdown navbar-right {{clazz}}"> {% set name = c.userobj.fullname if c.userobj.fullname else c.userobj.email%} <a href="#" class="dropdown-toggle" data-bs-toggle="dropdown" id="accountMenuButton" aria-expanded="false"> - <svg class='user-icon' viewBox="0 0 54 54"> - <circle class='user-icon' cx="27" cy="17" r="7.5" /> - <path class='user-icon' + <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> @@ -73,7 +73,7 @@ {% endif %} {% block header_account_profile %} <li> - <svg class='user-icon-small' viewBox="0 0 54 54"> + <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> @@ -84,10 +84,18 @@ </a> </li> {% endblock %} + {% block header_dashboard %} + <li> + <a href="{{ h.url_for('dashboard.datasets') }}" aria-label="{{ _('View dashboard') }}" title="{{ _('View dashboard') }}" role="menuitem"> + <i class="fa fa-tachometer"></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) }}" aria-label="{{ _('Edit profile') }}" title="{{ _('Edit profile') }}" role="menuitem"> - <i class='fa fa-edit'></i> + <i class="fa fa-edit"></i> <span class="text"> {{ _('Edit profile') }} </span> @@ -97,7 +105,7 @@ {% block header_account_log_out_link %} <li> <a href="{{ h.url_for('user.logout') }}" aria-label="{{ _('Logout') }}" title="{{ _('Logout') }}" role="menuitem"> - <i class='fa fa-sign-out'></i> + <i class="fa fa-sign-out"></i> <span class="text">{{ _('Logout') }}</span> </a> </li> diff --git a/ckanext/odsh/views/dashboard.py b/ckanext/odsh/views/dashboard.py deleted file mode 100644 index 463487c4517f694e73e07f39c1373849f5706cfa..0000000000000000000000000000000000000000 --- a/ckanext/odsh/views/dashboard.py +++ /dev/null @@ -1,27 +0,0 @@ -import ckan.authz as authz -import ckan.lib.helpers as h -from ckan.common import g, _ -from flask import Blueprint -import ckan.views.dashboard as dashboard -import logging - -log = logging.getLogger(__name__) - -blueprint = Blueprint(u'odsh_dashboard', __name__) - -@blueprint.before_request -def before_request() -> None: - is_sysadmin = authz.is_sysadmin(g.user) - if not is_sysadmin: - h.flash_error(_(u'Not authorized to see this page')) - return h.redirect_to(u'user.login') - return None - -def datasets(): - return dashboard.datasets() - -def organizations(): - return dashboard.organizations() - -def groups(): - return dashboard.groups()