Skip to content

Commit

Permalink
[#1049] Adds bulk process template to groups edit
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmartin committed Sep 19, 2013
1 parent 4699c64 commit 5ce4b68
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 13 deletions.
2 changes: 2 additions & 0 deletions ckan/config/routing.py
Expand Up @@ -292,6 +292,8 @@ def make_map():
ckan_icon='edit')
m.connect('group_members', '/group/members/{id}', action='members',
ckan_icon='group'),
m.connect('group_bulk_process', '/group/bulk_process/{id}',
action='bulk_process', ckan_icon='sitemap'),
m.connect('group_activity', '/group/activity/{id}/{offset}',
action='activity', ckan_icon='time'),
m.connect('group_read', '/group/{id}', action='read',
Expand Down
23 changes: 10 additions & 13 deletions ckan/controllers/group.py
Expand Up @@ -221,17 +221,14 @@ def _read(self, id, limit):
sort_by = request.params.get('sort', None)

def search_url(params):
if group_type == 'organization':
if c.action == 'bulk_process':
url = self._url_for(controller='organization',
action='bulk_process',
id=id)
else:
url = self._url_for(controller='organization',
action='read',
id=id)
if c.action == 'bulk_process':
url = self._url_for(controller='organization',
action='bulk_process',
id=id)
else:
url = self._url_for(controller='group', action='read', id=id)
url = self._url_for(controller='organization',
action='read',
id=id)
params = [(k, v.encode('utf-8') if isinstance(v, basestring)
else str(v)) for k, v in params]
return url + u'?' + urlencode(params)
Expand Down Expand Up @@ -350,9 +347,9 @@ def bulk_process(self, id):

group_type = self._get_group_type(id.split('@')[0])

if group_type != 'organization':
# FIXME: better error
raise Exception('Must be an organization')
# if group_type != 'organization':
# # FIXME: better error
# raise Exception('Must be an organization')

# check we are org admin

Expand Down
102 changes: 102 additions & 0 deletions ckan/templates/group/bulk_process.html
@@ -0,0 +1,102 @@
{% extends "group/edit_base.html" %}

{% block subtitle %}{{ _('Edit datasets') }} - {{ super() }}{% endblock %}

{% block page_primary_action %}
{% link_for _('Add dataset'), controller='package', action='new', group=c.group_dict.id, class_='btn btn-primary', icon='plus-sign-alt' %}
{% endblock %}

{% block primary_content_inner %}
<div class="clearfix">
<h1 class="hide-heading">{{ _('Edit datasets') }}</h1>
<div class="primary">
<h3 class="page-heading">
{% block page_heading %}
{%- if c.page.item_count -%}
{{ c.page.item_count }} datasets{{ _(" found for \"{query}\"").format(query=c.q) if c.q }}
{%- elif request.params -%}
{{ _('Sorry no datasets found for "{query}"').format(query=c.q) }}
{%- else -%}
{{ _('Datasets') }}
{%- endif -%}
{% endblock %}
</h3>
{% block form %}
{% if c.page.item_count %}
<form method="POST" data-module="basic-form">
<table class="table table-bordered table-header table-hover table-bulk-edit table-edit-hover" data-module="table-selectable-rows">
<col width="8">
<col width="120">
<thead>
<tr>
<th></th>
<th class="table-actions">
<div class="btn-group">
<button name="bulk_action" value="delete" class="btn btn-danger" type="submit">
<i class="icon-remove"></i>
{{ _('Delete') }}
</button>
</div>
</th>
</tr>
</thead>
<tbody>
{% for package in c.packages %}
{% set truncate = truncate or 180 %}
{% set truncate_title = truncate_title or 80 %}
{% set title = package.title or package.name %}
{% set notes = h.markdown_extract(package.notes, extract_length=truncate) %}
<tr>
<td>
<input type="checkbox" name="dataset_{{ package.id }}">
</td>
<td class="context">
<a href="{% url_for controller='package', action='edit', id=package.name %}" class="edit pull-right">
{{ _('Edit') }}
</a>
<h3 class="dataset-heading">
{{ h.link_to(h.truncate(title, truncate_title), h.url_for(controller='package', action='read', id=package.name)) }}
{% if package.get('state', '').startswith('draft') %}
<span class="label label-info">{{ _('Draft') }}</span>
{% elif package.get('state', '').startswith('deleted') %}
<span class="label label-important">{{ _('Deleted') }}</span>
{% endif %}
{% if package.private %}
<span class="label label-important">{{ _('Private') }}</span>
{% endif %}
</h3>
{% if notes %}
<p>{{ notes|urlize }}</p>
{% else %}
<p class="empty">{{ _("This dataset has no description") }}</p>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</form>
{% else %}
<p class="empty">{{ _('This organization has no datasets associated to it') }}</p>
{% endif %}
{% endblock %}
</div>
<aside class="tertiary">
{% block tertiary_content %}

{% block search_form %}
{% set sorting = [
(_('Name Ascending'), 'title_string asc'),
(_('Name Descending'), 'title_string desc'),
(_('Last Modified'), 'data_modified desc') ]
%}
{% snippet 'snippets/search_form.html', type='dataset', query=c.q, sorting=sorting, sorting_selected=c.sort_by_selected, no_title=true, search_class=' ' %}
{% endblock %}
{% for facet in c.facet_titles %}
{{ h.snippet('snippets/facet_list.html', title=c.facet_titles[facet], name=facet, extras={'id':c.group_dict.id}) }}
{% endfor %}
{% endblock %}
</aside>
</div>
{{ c.page.pager() }}
{% endblock %}
1 change: 1 addition & 0 deletions ckan/templates/group/edit_base.html
Expand Up @@ -16,6 +16,7 @@

{% block content_primary_nav %}
{{ h.build_nav_icon('group_edit', _('Edit'), id=c.group_dict.name) }}
{{ h.build_nav_icon('group_bulk_process', _('Datasets'), id=c.group_dict.name) }}
{{ h.build_nav_icon('group_members', _('Members'), id=c.group_dict.name) }}
{% endblock %}

Expand Down

0 comments on commit 5ce4b68

Please sign in to comment.