Skip to content

Commit

Permalink
[#1200] Quick tidy up of the resource_edit based templates
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmartin committed Oct 15, 2013
1 parent 8f8d2ab commit 14a3808
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 113 deletions.
7 changes: 5 additions & 2 deletions ckan/config/routing.py
Expand Up @@ -222,7 +222,6 @@ def make_map():
])))
m.connect('/dataset/{action}/{id}',
requirements=dict(action='|'.join([
'edit',
'new_metadata',
'new_resource',
'history',
Expand All @@ -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}',
Expand All @@ -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',
Expand Down
5 changes: 4 additions & 1 deletion ckan/templates/package/base_form_page.html
Expand Up @@ -2,8 +2,11 @@

{% block primary_content %}
<section class="module">
{% block page_header %}{% endblock %}
<div class="module-content">
{% block form %}{{ c.form | safe }}{% endblock %}
{% block primary_content_inner %}
{% block form %}{{ c.form | safe }}{% endblock %}
{% endblock %}
</div>
</section>
{% endblock %}
Expand Down
26 changes: 15 additions & 11 deletions 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() }}
<li class="active">{% link_for _('Edit'), controller='package', action='edit', id=pkg.name %}</li>
Expand All @@ -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 %}
<header class="module-content page-header"></header>
{{ super() }}
{% snippet 'package/snippets/info.html', pkg=pkg, show_resources=true, hide_follow_button=true %}
{% endblock %}

15 changes: 15 additions & 0 deletions 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() }}
<li class="active">{% link_for _('Edit'), controller='package', action='edit', id=pkg.name %}</li>
{% endblock %}

{% block secondary_content %}
{% snippet 'package/snippets/info.html', pkg=pkg, hide_follow_button=true %}
{% endblock %}
15 changes: 0 additions & 15 deletions ckan/templates/package/new_resource.html
Expand Up @@ -27,18 +27,3 @@ <h2 class="module-heading"><i class="icon-info-sign"></i> {{ _('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 %}
<header class="module-content page-header">
<ul class="nav nav-tabs">
{{ h.build_nav_icon('resource_edit', _('Edit Resource'), id=pkg_dict.id, resource_id=res.id) }}
{% if 'datapusher' in g.plugins %}
{{ h.build_nav_icon('resource_data', _('Resource Data'), id=pkg_dict.id, resource_id=res.id) }}
{% endif %}
</ul>
</header>
{% endif %}
{{ super() }}
{% endblock %}
15 changes: 1 addition & 14 deletions ckan/templates/package/read_base.html
Expand Up @@ -50,20 +50,7 @@
{% block secondary_help_content %}{% endblock %}

{% block package_info %}
<div class="module context-info">
<div class="module-content">
<h1 class="heading">{{ pkg.title or pkg.name }}</h1>
<div class="nums">
<dl>
<dt>{{ _('Followers') }}</dt>
<dd>{{ h.SI_number_span(h.get_action('dataset_follower_count', {'id': pkg.id})) }}</dd>
</dl>
</div>
<div class="follow_button">
{{ h.follow_button('dataset', pkg.name) }}
</div>
</div>
</div>
{% snippet "package/snippets/info.html", pkg=pkg %}
{% endblock %}

{% block package_organization %}
Expand Down
60 changes: 27 additions & 33 deletions 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() }}
<li class="active"><a href="">{{ _('Edit') }}</a></li>
{% endblock %}
<form method="post" action="{{ action }}" >

{% 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 %}
<button class="btn btn-primary" name="save" type="submit">
{{ _('Upload Data') }}
</button>

{# logged_in is defined in new_resource.html #}
{% block form %}
<h3>
{{ _('Status:') }}
{{ status.status.capitalize() if status.status else _('Not Uploaded Yet') }}
</h3>

{% 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 %}
<div class="alert alert-error">
<strong>{{ _('Upload Error') }}</strong> &mdash; {{ status.error.message }}
</div>
{% endif %}

<form class="dataset-form dataset-resource-form form-horizontal" method="post" action="{{ action }}" >
<h3> {{ _('Last Upload Status:') }} {% if status.status %} {{ status.status.capitalize() }} {% else %} {{ _('Not Uploaded Yet') }} {% endif %} </h3>
{% if status.error and status.error.message %}
<h3> {{ _('Upload Error:') }} {{ status.error.message }} </h3>
{% endif %}
{% if status.status %}
<h3> {{ _('Last Updated: ') }} {{ h.time_ago_from_timestamp(status.last_updated) }} </h3>
{% endif %}
{% if status.status %}
<h3>{{ _('Last Updated: ') }} {{ h.time_ago_from_timestamp(status.last_updated) }} </h3>
{% endif %}

<button class="btn" name="save" value="go-dataset" type="submit">{{ _('Upload Data') }}</button>
{% if status.status and status.task_info %}
<h3> {{ _('Upload Log ') }} </h3>
{{ h.debug_inspect(status.task_info.logs) }}
{% endif %}
{{ status }}
</form>
{% if status.status and status.task_info %}
<h3>{{ _('Upload Log') }}</h3>
{{ h.debug_inspect(status.task_info.logs) }}
{% endif %}

{{ status }}

{% endblock %}
</form>

{% block secondary_content %}
{% snippet 'package/snippets/info.html', pkg=pkg_dict, active=pkg_dict.id, action='resource_edit' %}
{% endblock %}
16 changes: 1 addition & 15 deletions 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() }}
<li class="active"><a href="">{{ _('Edit') }}</a></li>
{% 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 %}

Expand Down
24 changes: 24 additions & 0 deletions 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 %}
38 changes: 17 additions & 21 deletions ckan/templates/package/snippets/info.html
Expand Up @@ -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 %}
<section class="module module-narrow">
<h2 class="module-heading"><i class="icon-sitemap"></i> {{ _("Edit Dataset") }}</h2>
<ul class="unstyled nav nav-simple">
<li class="nav-item{% if action == 'package_edit' %} active{% endif %}">
{% link_for h.dataset_display_name(pkg)|truncate(30), controller='package', action='edit', id=pkg.name %}
</li>
</ul>
{% set resources = pkg.resources or [] %}
<h2 class="module-heading"><i class="icon-reorder"></i> {{ _("Edit Resources") }}</h2>
<ul class="unstyled nav nav-simple">
{% block package_resource_list %}
{% for resource in resources %}
<li class="nav-item{{ ' active' if active == resource.id }}">
{% link_for h.resource_display_name(resource)|truncate(30), controller='package', action='resource_edit', id=pkg.name, resource_id=resource.id, inner_span=true %}
</li>
{% endfor %}
{% endblock %}
<li class="nav-btn"><a href="{{ h.url_for(controller='package', action='new_resource', id=pkg.name) }}" class="btn{% if action == 'resource_new' %} disabled{% endif %}"><i class="icon-plus"></i> {{ _('Add New Resource') }}</a></li>
</ul>
<div class="module context-info">
<div class="module-content">
<h1 class="heading">{{ pkg.title or pkg.name }}</h1>
<div class="nums">
<dl>
<dt>{{ _('Followers') }}</dt>
<dd>{{ h.SI_number_span(h.get_action('dataset_follower_count', {'id': pkg.id})) }}</dd>
</dl>
</div>
{% if not hide_follow_button %}
<div class="follow_button">
{{ h.follow_button('dataset', pkg.name) }}
</div>
{% endif %}
</div>
</div>
</section>
{% endif %}
2 changes: 1 addition & 1 deletion ckanext/datapusher/plugin.py
Expand Up @@ -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):
Expand Down

0 comments on commit 14a3808

Please sign in to comment.