Skip to content

Commit

Permalink
Merge branch '368-new-history-page-2'
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed Apr 8, 2013
2 parents b5b2f92 + 945b0f4 commit d1476fe
Show file tree
Hide file tree
Showing 15 changed files with 352 additions and 19 deletions.
2 changes: 1 addition & 1 deletion ckan/controllers/group.py
Expand Up @@ -680,7 +680,7 @@ def history(self, id):

context = {'model': model, 'session': model.Session,
'user': c.user or c.author,
'schema': self._form_to_db_schema()}
'schema': self._db_to_form_schema()}
data_dict = {'id': id}
try:
c.group_dict = self._action('group_show')(context, data_dict)
Expand Down
3 changes: 2 additions & 1 deletion ckan/model/tag.py
Expand Up @@ -230,7 +230,8 @@ def __init__(self, package=None, tag=None, state=None, **kwargs):
setattr(self, k, v)

def __repr__(self):
return '<PackageTag package=%s tag=%s>' % (self.package.name, self.tag.name)
s = u'<PackageTag package=%s tag=%s>' % (self.package.name, self.tag.name)
return s.encode('utf8')

def activity_stream_detail(self, activity_id, activity_type):
if activity_type == 'new':
Expand Down
12 changes: 12 additions & 0 deletions ckan/templates/group/history.html
@@ -0,0 +1,12 @@
{% extends "group/read_base.html" %}

{% block subtitle %}{{ _('History') }} - {{ c.group_dict.display_name }}{% endblock %}

{% block primary_content_inner %}
<section class="module-content">
<h1 class="hide-heading">{{ _('History') }}</h1>
{% block group_history_revisions %}
{% snippet "group/snippets/history_revisions.html", group_dict=c.group_dict, group_revisions=c.group_revisions %}
{% endblock %}
</section>
{% endblock %}
12 changes: 12 additions & 0 deletions ckan/templates/group/snippets/history_revisions.html
@@ -0,0 +1,12 @@
{% import 'macros/form.html' as form %}

<form class="dataset-form dataset-resource-form form-horizontal" method="post" data-module="basic-form">

{{ form.errors(error_summary) }}

<input type="hidden" name="group_name" value="{{ group_dict.name }}"/>
{% snippet 'group/snippets/revisions_table.html', group_dict=group_dict, group_revisions=group_revisions %}

<button class="btn btn-primary" name="diff" value="go-resources" type="submit">{{ _('Compare') }}</button>

</form>
31 changes: 31 additions & 0 deletions ckan/templates/group/snippets/revisions_table.html
@@ -0,0 +1,31 @@
{% import 'macros/form.html' as form %}

<table class="table table-striped table-bordered">
<thead>
<tr>
<th></th>
<th>{{ _('Revision') }}</th>
<th>{{ _('Timestamp') }}</th>
<th>{{ _('Author') }}</th>
<th>{{ _('Log Message') }}</th>
</tr>
</thead>
<tbody>
{% for rev in group_revisions %}
<tr>
<td nowrap="nowrap">
{{ h.radio('selected1', rev.id, checked=(loop.first)) }}
{{ h.radio('selected2', rev.id, checked=(loop.last)) }}
</td>
<td class="dataset-label">
{% link_for rev.id | truncate(6), controller='revision', action='read', id=rev.id %}
</td>
<td class="dataset-details">
{{ h.render_datetime(rev.timestamp, with_hours=True) }}
</td>
<td class="dataset-details">{{ h.linked_user(rev.author) }}</td>
<td class="dataset-details">{{ rev.message }}</td>
</tr>
{% endfor %}
</tbody>
</table>
12 changes: 12 additions & 0 deletions ckan/templates/package/history.html
@@ -0,0 +1,12 @@
{% extends "package/read_base.html" %}

{% block subtitle %}{{ _('History') }} - {{ c.pkg_dict.title or c.pkg_dict.name }}{% endblock %}

{% block primary_content_inner %}
<section class="module-content">
<h1 class="hide-heading">{{ _('History') }}</h1>
{% block package_history_revisions %}
{% snippet "package/snippets/history_revisions.html", pkg_dict=pkg, pkg_revisions=c.pkg_revisions %}
{% endblock %}
</section>
{% endblock %}
35 changes: 18 additions & 17 deletions ckan/templates/package/read_base.html
Expand Up @@ -17,23 +17,6 @@
{% endblock %}

{% block primary_content %}
{% block package_revision_info %}
{% if c.pkg_revision_id %}
<div class="module info">
<p class="module-content">
{% set timestamp = h.render_datetime(c.pkg_revision_timestamp, with_hours=True) %}
{% set url = h.url(controller='package', action='read', id=pkg.name) %}

{% if c.pkg_revision_not_latest %}
{% trans timestamp=timestamp, url=url %}This is an old revision of this dataset, as edited at {{ timestamp }}. It may differ significantly from the <a href="{{ url }}">current revision</a>.{% endtrans %}
{% else %}
{% trans timestamp=timestamp %}This is the current revision of this dataset, as edited at {{ timestamp }}.{% endtrans %}
{% endif %}
</div>
</div>
{% endif %}
{% endblock %}

<article class="module prose">
{% block page_header %}
<header class="module-content page-header">
Expand All @@ -46,6 +29,24 @@
</ul>
</header>
{% endblock %}

{% block package_revision_info %}
{% if c.pkg_revision_id %}
<div class="module info alert alert-info">
<p class="module-content">
{% set timestamp = h.render_datetime(c.pkg_revision_timestamp, with_hours=True) %}
{% set url = h.url(controller='package', action='read', id=pkg.name) %}

{% if c.pkg_revision_not_latest %}
{% trans timestamp=timestamp, url=url %}This is an old revision of this dataset, as edited at {{ timestamp }}. It may differ significantly from the <a href="{{ url }}">current revision</a>.{% endtrans %}
{% else %}
{% trans timestamp=timestamp %}This is the current revision of this dataset, as edited at {{ timestamp }}.{% endtrans %}
{% endif %}
</p>
</div>
{% endif %}
{% endblock %}

{% block primary_content_inner %}{% endblock %}
</article>
{% endblock %}
Expand Down
12 changes: 12 additions & 0 deletions ckan/templates/package/snippets/history_revisions.html
@@ -0,0 +1,12 @@
{% import 'macros/form.html' as form %}

<form class="dataset-form dataset-resource-form form-horizontal" method="post" data-module="basic-form">

{{ form.errors(error_summary) }}

<input type="hidden" name="pkg_name" value="{{ pkg_dict.name }}"/>
{% snippet 'package/snippets/revisions_table.html', pkg_dict=pkg_dict, pkg_revisions=pkg_revisions %}

<button class="btn btn-primary" name="diff" value="go-resources" type="submit">{{ _('Compare') }}</button>

</form>
31 changes: 31 additions & 0 deletions ckan/templates/package/snippets/revisions_table.html
@@ -0,0 +1,31 @@
{% import 'macros/form.html' as form %}

<table class="table table-striped table-bordered">
<thead>
<tr>
<th></th>
<th>{{ _('Revision') }}</th>
<th>{{ _('Timestamp') }}</th>
<th>{{ _('Author') }}</th>
<th>{{ _('Log Message') }}</th>
</tr>
</thead>
<tbody>
{% for rev in pkg_revisions %}
<tr>
<td nowrap="nowrap">
{{ h.radio('selected1', rev.id, checked=(loop.first)) }}
{{ h.radio('selected2', rev.id, checked=(loop.last)) }}
</td>
<td class="dataset-label">
{% link_for rev.id | truncate(6), controller='revision', action='read', id=rev.id %}
</td>
<td class="dataset-details">
<a href="{{ h.url_for(controller='package', action='read',id='%s@%s' % (pkg_dict.name, rev.timestamp))}}" title="{{_('Read dataset as of %s') % rev.timestamp }}">{{ h.render_datetime(rev.timestamp, with_hours=True) }}</a>
</td>
<td class="dataset-details">{{ h.linked_user(rev.author) }}</td>
<td class="dataset-details">{{ rev.message }}</td>
</tr>
{% endfor %}
</tbody>
</table>
1 change: 1 addition & 0 deletions ckan/templates/revision/__init__.py
@@ -0,0 +1 @@
# empty file needed for pylons to find templates in this directory
56 changes: 56 additions & 0 deletions ckan/templates/revision/diff.html
@@ -0,0 +1,56 @@
{% extends "revision/read_base.html" %}

{% set pkg = c.pkg %}
{% set group = c.group %}

{% block subtitle %}{{ _('Differences')}}{% endblock %}

{% block breadcrumb_content %}
{% if c.diff_entity == 'package' %}
{% set dataset = pkg.title or pkg.name %}
<li>{% link_for _('Datasets'), controller='package', action='search', highlight_actions = 'new index' %}</li>
<li>{% link_for dataset, controller='package', action='read', id=pkg.name %}</li>
<li class="active"><a href="" title="{{ _('Revision Differences') }}">{{ _('Revision Differences') }}</a></li>
{% elif c.diff_entity == 'group' %}
{% set group = group.display_name or group.name %}
<li>{% link_for _('Groups'), controller='group', action='index' %}</li>
<li>{% link_for group, controller='group', action='read', id=group.name %}</li>
<li class="active"><a href="" title="{{ _('Revision Differences') }}">{{ _('Revision Differences') }}</a></li>
{% endif %}
{% endblock %}

{% block primary_content_inner %}
<h1>{{ _('Revision Differences') }} -
{% if c.diff_entity == 'package' %}
{% link_for pkg.title, controller='package', action='read', id=pkg.name %}
{% elif c.diff_entity == 'group' %}
{% link_for group.display_name, controller='group', action='read', id=group.name %}
{% endif %}
</h1>

<p>
<strong>From:</strong> {% link_for c.revision_from.id, controller='revision', action='read', id=c.revision_from.id %} -
{{ h.render_datetime(c.revision_from.timestamp, with_hours=True) }}
</p>
<p>
<strong>To:</strong> {% link_for c.revision_to.id, controller='revision', action='read', id=c.revision_to.id %} -
{{ h.render_datetime(c.revision_to.timestamp, with_hours=True) }}
</p>

{% if c.diff %}
<table class="table table-bordered table-striped">
<tr>
<th>{{ _('Field') }}</th>
<th>{{ _('Difference') }}</th>
</tr>
{% for field, diff in c.diff %}
<tr>
<td>{{ field }}</td>
<td><pre>{{ diff }}</pre></td>
</tr>
{% endfor %}
</table>
{% else %}
<h3>{{ _('No Differences') }}</h3>
{% endif %}
{% endblock %}
19 changes: 19 additions & 0 deletions ckan/templates/revision/list.html
@@ -0,0 +1,19 @@
{% extends "revision/read_base.html" %}

{% block subtitle %}{{ _('Revision History') }}{% endblock %}

{% block breadcrumb_content %}
<li class="active"><a href="" title="{{ _('Revision History') }}">{{ _('Revisions') }}</a></li>
{% endblock %}

{% block primary_content_inner %}
<h1>{{ _('Revision History') }}</h1>

{{ c.page.pager() }}

{% block revisions_list %}
{% snippet "revision/snippets/revisions_list.html", revisions=c.page.items %}
{% endblock %}

{{ c.page.pager() }}
{% endblock %}
93 changes: 93 additions & 0 deletions ckan/templates/revision/read.html
@@ -0,0 +1,93 @@
{% extends "revision/read_base.html" %}

{% set rev = c.revision %}

{% block subtitle %}{{ _('Revision') }} {{ rev.id }}{% endblock %}

{% block breadcrumb_content %}
<li>{% link_for _('Revisions'), controller='revision', action='index' %}</li>
<li class="active"><a href="" title="{{ _('Revision') }} {{ rev.id }}">{{ rev.id |truncate(35) }}</a></li>
{% endblock %}

{% block actions_content %}
{% if c.revision_change_state_allowed %}
<form
method="POST"
action="{{ h.url_for(controller='revision',
action='edit',
id=c.revision.id) }}"
>
<li>
{% if rev.state != 'deleted' %}
<button type="submit" name="action" value="delete" class="btn btn-danger">
<i class="icon-trash"></i> {{ _('Delete') }}
</button>
{% endif %}
{% if rev.state == 'deleted' %}
<button type="submit" name="action" value="undelete" class="btn btn-danger">
<i class="icon-trash"></i>
{{ _('Undelete') }}
</button>
{% endif %}
</li>
</form>
{% endif %}
{% endblock %}

{% block primary_content_inner %}
<h1>{{ _('Revision') }}: {{ rev.id }}</h1>

<div class="state-{{ rev.state }}">
<div class="embedded-content">
{% if rev.state != 'active' %}
<p class="state-notice">
{{ rev.state }}
</p>
{% endif %}

<p>
<strong>{{ _('Author') }}:</strong> {{ h.linked_user(rev.author) }}
</p>
<p>
<strong>{{ _('Timestamp') }}:</strong> {{ h.render_datetime(rev.timestamp, with_hours=True) }}
</p>
<p>
<strong>{{ _('Log Message') }}:</strong>
</p>
<p>
{{ rev.message }}
</p>
</div>

<div class="embedded-content">
<h2>{{ _('Changes') }}</h2>
<h3>{{ _('Datasets') }}</h3>
<ul>
{% for pkg in c.packages %}
<li>
{{ h.link_to(pkg.name, h.url_for(controller='package', action='read', id=pkg.name)) }}
</li>
{% endfor %}
</ul>

<h3>{{ _('Datasets\' Tags') }}</h3>
<ul>
{% for pkgtag in c.pkgtags %}
<li>
Dataset - {{ h.link_to(pkgtag.package.name, h.url_for(controller='package', action='read', id=pkgtag.package.name)) }},
Tag - {{ h.link_to(pkgtag.tag.name, h.url_for(controller='tag', action='read', id=pkgtag.tag.name)) }}
</li>
{% endfor %}
</ul>

<h3>{{ _('Groups') }}</h3>
<ul>
{% for group in c.groups %}
<li>
{{ h.link_to(group.name, h.url_for(controller='group', action='read', id=group.name)) }}
</li>
{% endfor %}
</ul>
</div>
</div>
{% endblock %}
19 changes: 19 additions & 0 deletions ckan/templates/revision/read_base.html
@@ -0,0 +1,19 @@
{% extends "page.html" %}

{% block secondary_content %}

{% block secondary_help_content %}{% endblock %}

{% block package_social %}
{% snippet "snippets/social.html" %}
{% endblock %}

{% endblock %}

{% block primary_content %}
<article class="module prose">
<section class="module-content">
{% block primary_content_inner %}{% endblock %}
</section>
</article>
{% endblock %}

0 comments on commit d1476fe

Please sign in to comment.