From 14a3808c013c8654b96a7ee33e4b6c7f5f5a034e Mon Sep 17 00:00:00 2001 From: John Martin Date: Wed, 9 Oct 2013 16:04:13 +0100 Subject: [PATCH] [#1200] Quick tidy up of the resource_edit based templates --- ckan/config/routing.py | 7 ++- ckan/templates/package/base_form_page.html | 5 +- ckan/templates/package/edit.html | 26 ++++---- ckan/templates/package/edit_base.html | 15 +++++ ckan/templates/package/new_resource.html | 15 ----- ckan/templates/package/read_base.html | 15 +---- ckan/templates/package/resource_data.html | 60 +++++++++---------- ckan/templates/package/resource_edit.html | 16 +---- .../templates/package/resource_edit_base.html | 24 ++++++++ ckan/templates/package/snippets/info.html | 38 ++++++------ ckanext/datapusher/plugin.py | 2 +- 11 files changed, 110 insertions(+), 113 deletions(-) create mode 100644 ckan/templates/package/edit_base.html create mode 100644 ckan/templates/package/resource_edit_base.html diff --git a/ckan/config/routing.py b/ckan/config/routing.py index 6b41d8a66f2..6366b9ea01c 100644 --- a/ckan/config/routing.py +++ b/ckan/config/routing.py @@ -222,7 +222,6 @@ def make_map(): ]))) m.connect('/dataset/{action}/{id}', requirements=dict(action='|'.join([ - 'edit', 'new_metadata', 'new_resource', 'history', @@ -234,6 +233,10 @@ def make_map(): 'delete', 'api_data', ]))) + m.connect('dataset_edit', '/dataset/edit/{id}', action='edit', + ckan_icon='edit') + m.connect('dataset_resources', '/dataset/resources/{id}', + action='resources', ckan_icon='time') m.connect('dataset_followers', '/dataset/followers/{id}', action='followers', ckan_icon='group') m.connect('dataset_activity', '/dataset/activity/{id}', @@ -247,7 +250,7 @@ def make_map(): m.connect('/dataset/{id}/resource_delete/{resource_id}', action='resource_delete') m.connect('resource_edit', '/dataset/{id}/resource_edit/{resource_id}', - action='resource_edit') + action='resource_edit', ckan_icon='edit') m.connect('/dataset/{id}/resource/{resource_id}/download', action='resource_download') m.connect('/dataset/{id}/resource/{resource_id}/embed', diff --git a/ckan/templates/package/base_form_page.html b/ckan/templates/package/base_form_page.html index 049d83b1ebb..176e2cd8e04 100644 --- a/ckan/templates/package/base_form_page.html +++ b/ckan/templates/package/base_form_page.html @@ -2,8 +2,11 @@ {% block primary_content %}
+ {% block page_header %}{% endblock %}
- {% block form %}{{ c.form | safe }}{% endblock %} + {% block primary_content_inner %} + {% block form %}{{ c.form | safe }}{% endblock %} + {% endblock %}
{% endblock %} diff --git a/ckan/templates/package/edit.html b/ckan/templates/package/edit.html index 4f15985d033..39229cdd322 100644 --- a/ckan/templates/package/edit.html +++ b/ckan/templates/package/edit.html @@ -1,9 +1,22 @@ -{% extends 'package/base_form_page.html' %} +{% extends 'package/base.html' %} {% set pkg = c.pkg_dict %} {% block breadcrumb_content_selected %}{% endblock %} +{% block content_action %} + {% link_for _('View dataset'), controller='package', action='read', id=pkg.name, class_='btn', icon='eye-open' %} +{% endblock %} + +{% block content_primary_nav %} + {{ h.build_nav_icon('dataset_edit', _('Edit'), id=pkg.name) }} + {{ h.build_nav_icon('dataset_resource', _('Resources'), id=pkg.name) }} +{% endblock %} + +{% block primary_content_inner %} + {% block form %}{{ c.form | safe }}{% endblock %} +{% endblock %} + {% block breadcrumb_content %} {{ super() }}
  • {% link_for _('Edit'), controller='package', action='edit', id=pkg.name %}
  • @@ -13,16 +26,7 @@ {% snippet 'package/snippets/resources.html', pkg=pkg, action='resource_edit' %} {% endblock %} -{% block content_action %} - {% link_for _('View dataset'), controller='package', action='read', id=pkg.name, class_='btn', icon='eye-open' %} -{% endblock %} - {% block secondary_content %} - {% snippet 'package/snippets/info.html', pkg=pkg, action='package_edit' %} -{% endblock %} - -{% block primary_content %} - - {{ super() }} + {% snippet 'package/snippets/info.html', pkg=pkg, show_resources=true, hide_follow_button=true %} {% endblock %} diff --git a/ckan/templates/package/edit_base.html b/ckan/templates/package/edit_base.html new file mode 100644 index 00000000000..37462163de3 --- /dev/null +++ b/ckan/templates/package/edit_base.html @@ -0,0 +1,15 @@ +{% extends 'package/base.html' %} + +{% set pkg = c.pkg_dict %} +{% set pkg_dict = c.pkg_dict %} + +{% block breadcrumb_content_selected %}{% endblock %} + +{% block breadcrumb_content %} + {{ super() }} +
  • {% link_for _('Edit'), controller='package', action='edit', id=pkg.name %}
  • +{% endblock %} + +{% block secondary_content %} + {% snippet 'package/snippets/info.html', pkg=pkg, hide_follow_button=true %} +{% endblock %} diff --git a/ckan/templates/package/new_resource.html b/ckan/templates/package/new_resource.html index 7eedbad761f..fa10fb463be 100644 --- a/ckan/templates/package/new_resource.html +++ b/ckan/templates/package/new_resource.html @@ -27,18 +27,3 @@

    {{ _('What\'s a resour {{ super() }} {% resource 'vendor/fileupload' %} {% endblock %} - -{% block primary_content %} - {% set res = c.resource %} - {% if pkg_dict and pkg_dict.state != 'draft' and res %} - - {% endif %} - {{ super() }} -{% endblock %} diff --git a/ckan/templates/package/read_base.html b/ckan/templates/package/read_base.html index daecd18bf75..820b8def6d1 100644 --- a/ckan/templates/package/read_base.html +++ b/ckan/templates/package/read_base.html @@ -50,20 +50,7 @@ {% block secondary_help_content %}{% endblock %} {% block package_info %} -
    -
    -

    {{ pkg.title or pkg.name }}

    -
    -
    -
    {{ _('Followers') }}
    -
    {{ h.SI_number_span(h.get_action('dataset_follower_count', {'id': pkg.id})) }}
    -
    -
    - -
    -
    + {% snippet "package/snippets/info.html", pkg=pkg %} {% endblock %} {% block package_organization %} diff --git a/ckan/templates/package/resource_data.html b/ckan/templates/package/resource_data.html index 30c9fe59e98..1179ed3bfec 100644 --- a/ckan/templates/package/resource_data.html +++ b/ckan/templates/package/resource_data.html @@ -1,45 +1,39 @@ -{% extends "package/new_resource.html" %} +{% extends "package/resource_edit_base.html" %} -{% set pkg_dict = c.pkg_dict %} -{% set res = c.resource %} +{% block subtitle %}{{ h.dataset_display_name(pkg) }} - {{ h.resource_display_name(res) }}{% endblock %} -{% block subtitle %}{{ h.dataset_display_name(pkg_dict) }} - {{ h.resource_display_name(res) }}{% endblock %} +{% block primary_content_inner %} -{% block breadcrumb_content_selected %}{% endblock %} + {% set action = h.url_for(controller='ckanext.datapusher.plugin:ResourceDataController', action='resource_data', id=pkg.name, resource_id=res.id) %} -{% block breadcrumb_content %} - {{ super() }} -
  • {{ _('Edit') }}
  • -{% endblock %} +
    -{% block content_action %} - {% link_for _('View resource'), controller='package', action='resource_read', id=pkg_dict.name, resource_id=res.id, class_='btn', icon='eye-open' %} -{% endblock %} + -{# logged_in is defined in new_resource.html #} -{% block form %} +

    + {{ _('Status:') }} + {{ status.status.capitalize() if status.status else _('Not Uploaded Yet') }} +

    - {% set action = h.url_for(controller='ckanext.datapusher.plugin:ResourceDataController', action='resource_data', id=pkg_dict.id, resource_id=res.id) %} + {% if status.error and status.error.message %} +
    + {{ _('Upload Error') }} — {{ status.error.message }} +
    + {% endif %} - -

    {{ _('Last Upload Status:') }} {% if status.status %} {{ status.status.capitalize() }} {% else %} {{ _('Not Uploaded Yet') }} {% endif %}

    - {% if status.error and status.error.message %} -

    {{ _('Upload Error:') }} {{ status.error.message }}

    - {% endif %} - {% if status.status %} -

    {{ _('Last Updated: ') }} {{ h.time_ago_from_timestamp(status.last_updated) }}

    - {% endif %} + {% if status.status %} +

    {{ _('Last Updated: ') }} {{ h.time_ago_from_timestamp(status.last_updated) }}

    + {% endif %} - - {% if status.status and status.task_info %} -

    {{ _('Upload Log ') }}

    - {{ h.debug_inspect(status.task_info.logs) }} - {% endif %} - {{ status }} -
    + {% if status.status and status.task_info %} +

    {{ _('Upload Log') }}

    + {{ h.debug_inspect(status.task_info.logs) }} + {% endif %} + + {{ status }} -{% endblock %} + -{% block secondary_content %} - {% snippet 'package/snippets/info.html', pkg=pkg_dict, active=pkg_dict.id, action='resource_edit' %} {% endblock %} diff --git a/ckan/templates/package/resource_edit.html b/ckan/templates/package/resource_edit.html index 52ac2ab4722..f5667f97350 100644 --- a/ckan/templates/package/resource_edit.html +++ b/ckan/templates/package/resource_edit.html @@ -1,21 +1,7 @@ -{% extends "package/new_resource.html" %} - -{% set pkg_dict = c.pkg_dict %} -{% set res = c.resource %} +{% extends "package/resource_edit_base.html" %} {% block subtitle %}{{ h.dataset_display_name(pkg_dict) }} - {{ h.resource_display_name(res) }}{% endblock %} -{% block breadcrumb_content_selected %}{% endblock %} - -{% block breadcrumb_content %} - {{ super() }} -
  • {{ _('Edit') }}
  • -{% endblock %} - -{% block content_action %} - {% link_for _('View resource'), controller='package', action='resource_read', id=pkg_dict.name, resource_id=res.id, class_='btn', icon='eye-open' %} -{% endblock %} - {# logged_in is defined in new_resource.html #} {% block form %}{{ h.snippet('package/snippets/resource_edit_form.html', data=data, errors=errors, error_summary=error_summary, pkg_name=pkg_dict.name, form_action=c.form_action, allow_upload=g.ofs_impl and logged_in) }}{% endblock %} diff --git a/ckan/templates/package/resource_edit_base.html b/ckan/templates/package/resource_edit_base.html new file mode 100644 index 00000000000..4608f9f2cf9 --- /dev/null +++ b/ckan/templates/package/resource_edit_base.html @@ -0,0 +1,24 @@ +{% extends "package/edit_base.html" %} + +{% set logged_in = true if c.userobj else false %} +{% set res = c.resource %} + +{% block content_primary_nav %} + {{ h.build_nav_icon('resource_edit', _('Edit Resource'), id=pkg.name, resource_id=res.id) }} + {% if 'datapusher' in g.plugins %} + {{ h.build_nav_icon('resource_data', _('Resource Data'), id=pkg.name, resource_id=res.id) }} + {% endif %} +{% endblock %} + +{% block content_action %} + {% link_for _('View resource'), controller='package', action='resource_read', id=pkg_dict.name, resource_id=res.id, class_='btn', icon='eye-open' %} +{% endblock %} + +{% block primary_content_inner %} + {% block form %}{% endblock %} +{% endblock %} + +{% block scripts %} + {{ super() }} + {% resource 'vendor/fileupload' %} +{% endblock %} diff --git a/ckan/templates/package/snippets/info.html b/ckan/templates/package/snippets/info.html index 704cc8225bf..6bcde9137f2 100644 --- a/ckan/templates/package/snippets/info.html +++ b/ckan/templates/package/snippets/info.html @@ -2,33 +2,29 @@ Displays a sidebard module with information for given package pkg - The package dict that owns the resources. -active - The active resource. -action - The action that this is coming from. Example: {% snippet "package/snippets/info.html", pkg=pkg %} #} -{% if pkg and h.check_access('package_update', {'id':pkg.id }) %} +{% if pkg %}
    -

    {{ _("Edit Dataset") }}

    - - {% set resources = pkg.resources or [] %} -

    {{ _("Edit Resources") }}

    - +
    +
    +

    {{ pkg.title or pkg.name }}

    +
    +
    +
    {{ _('Followers') }}
    +
    {{ h.SI_number_span(h.get_action('dataset_follower_count', {'id': pkg.id})) }}
    +
    +
    + {% if not hide_follow_button %} + + {% endif %} +
    +
    {% endif %} \ No newline at end of file diff --git a/ckanext/datapusher/plugin.py b/ckanext/datapusher/plugin.py index 2138497ad57..e6fa45fa61f 100644 --- a/ckanext/datapusher/plugin.py +++ b/ckanext/datapusher/plugin.py @@ -119,7 +119,7 @@ def before_map(self, m): m.connect( 'resource_data', '/dataset/{id}/resource_data/{resource_id}', controller='ckanext.datapusher.plugin:ResourceDataController', - action='resource_data') + action='resource_data', ckan_icon='cloud-upload') return m def get_actions(self):