Commit b4a72b1b authored by Ross Jones's avatar Ross Jones
Browse files

Updated templates for reports BUT....

unpublished.html is missing the options section, not sure why. Perhaps a
ckanext-report bug? Also missing on live.
parent 2fa3f0bc
......@@ -1989,3 +1989,16 @@ def is_plugin_enabled(plugin_name):
def config_get(key, default=None):
return config.get(key, default)
def report_match_organization_name(name, dct):
return filter(lambda d: d['organization_name'] == name, dct)
def report_match_rows(rows, typ, quarter):
return [row for row in rows if (row[3]==typ and row[4]==quarter)]
def report_timestamps_split(timestamps):
return [render_datetime(timestamp) for timestamp in timestamps.split(' ')]
def report_users_split(users):
return [linked_user(user) for user in users.split(' ')]
<html xmlns:py="http://genshi.edgewall.org/"
xmlns:i18n="http://genshi.edgewall.org/i18n"
xmlns:xi="http://www.w3.org/2001/XInclude"
py:strip="">
<div class="widget-container">
<div class="widget-container">
<p>
Number of datasets without resources: {{data['table']|length}}
</p>
<p>
NB: "Last resource deleted" is blank if there is no history of any resources for the dataset.
</p>
<p>
Number of datasets without resources: ${len(c.data['table'])}
</p>
<p>
NB: "Last resource deleted" is blank if there is no history of any resources for the dataset.
</p>
<table class="table table-bordered table-condensed tablesorter" id="report-table" style="width: 100%;table-layout:fixed; margin-top: 8px;">
<thead>
<tr>
<th style="width: 80px">Dataset</th>
<th style="width: 80px">Organization</th>
<th style="width: 50px">Notes</th>
<th style="width: 50px">Date created on DGU</th>
<th style="width: 50px">Date modified on DGU</th>
<th style="width: 50px">Date last resource deleted</th>
<th style="width: 100px">Last resource URL</th>
</tr>
</thead>
<tbody>
<py:for each="dataset in c.data['table']">
<tr>
<td><a href="/dataset/${dataset['name']}">${dataset['title']}</a></td>
<td><a href="/publisher/${dataset['organization name']}">${dataset['organization title']}</a></td>
<td>${dataset['dataset_notes']}</td>
<td>${h.render_datetime(dataset['metadata created'], date_format='%d/%m/%Y')}</td>
<td>${h.render_datetime(dataset['metadata modified'], date_format='%d/%m/%Y')}</td>
<td>${h.render_datetime(dataset['last resource deleted'], date_format='%d/%m/%Y')}</td>
<td style="overflow: hidden; text-overflow: ellipsis"><a href="${dataset['last resource url']}">${dataset['last resource url']}</a></td>
</tr>
</py:for>
</tbody>
</table>
<table class="table table-bordered table-condensed tablesorter" id="report-table" style="width: 100%;table-layout:fixed; margin-top: 8px;">
<thead>
<tr>
<th style="width: 80px">Dataset</th>
<th style="width: 80px">Organization</th>
<th style="width: 50px">Notes</th>
<th style="width: 50px">Date created on DGU</th>
<th style="width: 50px">Date modified on DGU</th>
<th style="width: 50px">Date last resource deleted</th>
<th style="width: 100px">Last resource URL</th>
</tr>
</thead>
<tbody>
{% for dataset in data['table'] %}
<tr>
<td><a href="/dataset/{{dataset['name']}}">{{dataset['title']}}</a></td>
<td><a href="/publisher/{{dataset['organization name']}}">{{dataset['organization title']}}</a></td>
<td>{{dataset['dataset_notes']}}</td>
<td>{{h.render_datetime(dataset['metadata created'], date_format='%d/%m/%Y')}}</td>
<td>{{h.render_datetime(dataset['metadata modified'], date_format='%d/%m/%Y')}}</td>
<td>{{h.render_datetime(dataset['last resource deleted'], date_format='%d/%m/%Y')}}</td>
<td style="overflow: hidden; text-overflow: ellipsis"><a href="{{dataset['last resource url']}}">{{dataset['last resource url']}}</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</html>
</div>
<html xmlns:py="http://genshi.edgewall.org/"
xmlns:i18n="http://genshi.edgewall.org/i18n"
xmlns:xi="http://www.w3.org/2001/XInclude"
py:strip="">
<div class="widget-container">
<div class="widget-container">
<p>
{{data['dataset_count']}} {% if not data['include_published'] %}unpublished{% endif %} datasets / {{data['dataset_count_with_feedback']}} with feedback
</p>
<p>
${c.data['dataset_count']} <py:if test="not c.options['include_published']">unpublished</py:if> datasets / ${c.data['dataset_count_with_feedback']} with feedback
</p>
<table class="table table-bordered table-condensed tablesorter" id="report-table" style="width: 100%;table-layout:fixed; margin-top: 8px;">
<thead>
<tr>
<th>Dataset</th>
<th>Publish Date</th>
<th>Publisher</th>
<th>Economic growth</th>
<th>Social growth</th>
<th>Effective services</th>
<th>Linked data</th>
<th>Other</th>
<th>Total</th>
</tr>
</thead>
<tbody>
{% for stats in data['table'] %}
<tr>
<td><a href="{{h.url_for(controller='ckanext.dgu.controllers.feedback:FeedbackController', action='view', id=stats['package-name'])}}">{{stats['package-title']}}</a></td>
<td>{{h.render_datetime(stats.get('publish-date',''), date_format='%d/%m/%Y')}}</td>
<td><a href="{{h.relative_url_for(organization=stats['organization-name'])}}">{{stats.get('organization-title','')}}</a></td>
<td>{{stats.get('economic',0)}}</td>
<td>{{stats.get('social',0)}}</td>
<td>{{stats.get('effective',0)}}</td>
<td>{{stats.get('linked',0)}}</td>
<td>{{stats.get('other',0)}}</td>
<td>{{stats.get('total-comments',0)}}</td>
</tr>
{% endfor %}
</tbody>
</table>
<table class="table table-bordered table-condensed tablesorter" id="report-table" style="width: 100%;table-layout:fixed; margin-top: 8px;">
<thead>
<tr>
<th>Dataset</th>
<th>Publish Date</th>
<th>Publisher</th>
<th>Economic growth</th>
<th>Social growth</th>
<th>Effective services</th>
<th>Linked data</th>
<th>Other</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<py:for each="stats in c.data['table']">
<tr>
<td><a href="${h.url_for(controller='ckanext.dgu.controllers.feedback:FeedbackController', action='view', id=stats['package-name'])}">${stats['package-title']}</a></td>
<td>${h.render_datetime(stats.get('publish-date',''), date_format='%d/%m/%Y')}</td>
<td><a href="${h.relative_url_for(organization=stats['organization-name'])}">${stats.get('organization-title','')}</a></td>
<td>${stats.get('economic',0)}</td>
<td>${stats.get('social',0)}</td>
<td>${stats.get('effective',0)}</td>
<td>${stats.get('linked',0)}</td>
<td>${stats.get('other',0)}</td>
<td>${stats.get('total-comments',0)}</td>
</tr>
</py:for>
</tbody>
</table>
<a class='pull-right' py:if="c.options['organization']" href="${h.relative_url_for(organization=None)}">View all publishers</a>
</div>
</html>
</div>
<html xmlns:py="http://genshi.edgewall.org/"
xmlns:i18n="http://genshi.edgewall.org/i18n"
xmlns:xi="http://www.w3.org/2001/XInclude"
py:strip="">
<div class="widget-container">
<div class="widget-container">
<p>
NII totals: ${c.data['num_resources']} resources in ${c.data['num_datasets']} datasets across ${c.data['num_organizations']} organizations
</p>
<p>
Broken: ${c.data['num_broken_resources']} broken resources in ${c.data['num_broken_datasets']} broken datasets across ${c.data['num_broken_organizations']} organizations
</p>
<ul>
<py:for each="publisher_name, publisher_title in c.data['organizations']">
<li><a href="#${publisher_name}">${publisher_title}</a></li>
</py:for>
</ul>
<p>
NII totals: {{data['num_resources']}} resources in {{data['num_datasets']}} datasets across {{data['num_organizations']}} organizations
</p>
<p>
Broken: {{data['num_broken_resources']}} broken resources in {{data['num_broken_datasets']}} broken datasets across {{data['num_broken_organizations']}} organizations
</p>
<ul>
{% for publisher_name, publisher_title in data['organizations'] %}
<li><a href="{${publisher_name}}">{{publisher_title}}</a></li>
{% endfor %}
</ul>
<py:for each="publisher_name, publisher_title in c.data['organizations']">
<h2><a name="${publisher_name}" href="/publisher/${publisher_name}">${publisher_title}</a></h2>
<table class="table table-bordered">
<thead>
<tr>
<th>Dataset</th>
<th>Notes</th>
<th>Broken resource count</th>
<th>Broken resources</th>
</tr>
</thead>
<tbody>
<py:for each="dataset in __import__('itertools').ifilter(lambda d: d['organization_name'] == publisher_name, c.data['table'])">
<tr py:attrs="{'class':'warning' if dataset['num_broken_resources'] > 0 else None}">
<td><a href="/dataset/${dataset['name']}">${dataset['title']}</a></td>
<td>${dataset['dataset_notes']}</td>
<td>${dataset['num_broken_resources']}</td>
<td>
<ul py:if="dataset['broken_resources']">
<py:for each="rdesc,rid in dataset['broken_resources']">
<li>
<a href="/dataset/${dataset['name']}/resource/${rid}">${rdesc or "Unnamed"}</a>
</li>
</py:for>
</ul>
</td>
</tr>
</py:for>
</tbody>
</table>
{% for publisher_name, publisher_title in data['organizations'] %}
<h2><a name="{{publisher_name}}" href="/publisher/{{publisher_name}}">{{publisher_title}}</a></h2>
<table class="table table-bordered">
<thead>
<tr>
<th>Dataset</th>
<th>Notes</th>
<th>Broken resource count</th>
<th>Broken resources</th>
</tr>
</thead>
<tbody>
{% for dataset in h.report_match_organization_name(publisher_name, data['table']) %}
<tr {% if dataset['num_broken_resources'] > 0 %}class="warning"{% endif %}>
<td><a href="/dataset/{{dataset['name']}}">{{dataset['title']}}</a></td>
<td>{{dataset['dataset_notes']}}</td>
<td>{{dataset['num_broken_resources']}}</td>
<td>
{% if dataset['broken_resources'] %}
<ul>
{% for rdesc,rid in dataset['broken_resources'] %}
<li>
<a href="/dataset/{{dataset['name']}}/resource/{{rid}}">{{rdesc or "Unnamed"}}</a>
</li>
{% endfor %}
</ul>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</py:for>
</div>
</html>
{% endfor %}
</div>
<html xmlns:py="http://genshi.edgewall.org/"
xmlns:i18n="http://genshi.edgewall.org/i18n"
xmlns:xi="http://www.w3.org/2001/XInclude"
py:strip="">
<label class="checkbox">
<input type="checkbox" name="include_published" value="1" class="inline js-auto-submit" py:attrs="{'checked': 'checked'} if c.options['include_published'] else {}"/>
Include published datasets
</label>
</html>
{#
Option snippet - organization
value - Value of this option
#}
<label class="checkbox">
<input type="checkbox" name="include_published" value="1" class="inline js-auto-submit" {% if value %}checked="checked"{% endif %}/>
Include published datasets
</label>
<html xmlns:py="http://genshi.edgewall.org/"
xmlns:i18n="http://genshi.edgewall.org/i18n"
xmlns:xi="http://www.w3.org/2001/XInclude"
py:strip="">
{% for quarter in data['quarters'] %}
<div style="margin-top: 10px; margin-bottom:10px;">
<h3>
{{quarter.capitalize()}} Quarter
({{h.render_datetime(data['quarters'][quarter][0])}} -
{{h.render_datetime(data['quarters'][quarter][1])}})
</h3>
{% for type in ('created', 'modified') %}
<div style="margin-top: 10px; margin-bottom:10px;">
{% with %}
{% set rows = h.match_rows(rows, typ, quarter) %}
<p>{{type.capitalize()}} ({{rows|length}}):</p>
<div py:for="quarter in c.data['quarters']" style="margin-top: 10px; margin-bottom:10px;">
<h3>
${quarter.capitalize()} Quarter
(${h.render_datetime(c.data['quarters'][quarter][0])} -
${h.render_datetime(c.data['quarters'][quarter][1])})
</h3>
<div py:for="type in ('created', 'modified')" style="margin-top: 10px; margin-bottom:10px;">
<py:with vars="rows = [row for row in c.data['table'] if (row[3]==type and row[4]==quarter)]">
<p>${type.capitalize()} (${len(rows)}):</p>
<table py:if="rows" class="table table-bordered table-condensed tablesorter" id="report-table" style="width: 100%; margin-top: 8px;">
<tr>
<th style="width: 500px">Dataset</th>
<th style="width: 100px">Notes</th>
<th style="width: 100px">${type.capitalize()}</th>
<th style="width: 150px">By</th>
<th style="width: 100px">Published data</th>
</tr>
<py:for each="name,title,notes,created_or_modified,quarter_,timestamps,users,pub in rows">
<tr>
<td><a href="${h.url_for(controller='package',action='read',id=name)}">${ title }</a></td>
<td>${notes}</td>
<td>${ h.literal(', '.join((h.render_datetime(timestamp) for timestamp in timestamps.split(' ')))) }</td>
<td>${ h.literal(', '.join((h.linked_user(user) for user in users.split(' ')))) }</td>
<td><span py:if="pub">Yes</span>
<span py:if="not pub">No</span>
</td>
</tr>
</py:for>
</table>
<p py:if="not rows" style="font-style: italic; margin-left:20px">None</p>
</py:with>
</div>
{% if rows %}
<table class="table table-bordered table-condensed tablesorter" id="report-table" style="width: 100%; margin-top: 8px;">
<tr>
<th style="width: 500px">Dataset</th>
<th style="width: 100px">Notes</th>
<th style="width: 100px">{{type.capitalize()}}</th>
<th style="width: 150px">By</th>
<th style="width: 100px">Published data</th>
</tr>
{% for name,title,notes,created_or_modified,quarter_,timestamps,users,pub in rows %}
<tr>
<td><a href="{{h.url_for(controller='package',action='read',id=name)}}">{{ title }}</a></td>
<td>{{notes}}</td>
<td>{{ h.literal(', '.join(h.report_timestamp_split(timestamps))) }}</td>
<td>{{ h.literal(', '.join(h,report_users_split(users))) }}</td>
<td>
{% if pub %}
<span >Yes</span>
{% else %}
<span >No</span>
{% endif %}
</td>
</tr>
{% endfor %}
</table>
{% else %}
<p style="font-style: italic; margin-left:20px">None</p>
{% endif %}
{% endwith %}
</div>
</html>
{% endfor %}
</div>
{% endfor %}
<html xmlns:py="http://genshi.edgewall.org/"
xmlns:i18n="http://genshi.edgewall.org/i18n"
xmlns:xi="http://www.w3.org/2001/XInclude"
py:strip="">
<ul>
<li>Datasets: ${c.data['num_datasets']}</li>
<li>Resources: ${c.data['num_resources']}</li>
</ul>
<table class="table table-bordered table-condensed" id="report-table" style="width: 100%; table-layout: fixed;">
<thead>
<tr class="js-tooltip">
<th style="width: 60px" py:if="c.options['include_sub_organizations']" >Publisher</th>
<th style="width: 100px">Dataset</th>
<th style="width: 40px">Notes</th>
<th style="width: 30px" title="Index/position of the resource in the dataset">Index</th>
<th style="width: 100px">URL</th>
<th style="width: 100px">Description</th>
<th style="width: 30px">Format</th>
<th style="width: 50px">Created</th>
</tr>
</thead>
<tbody>
<tr py:for="row_dict in c.data['table']">
<td py:if="c.options['include_sub_organizations']"><a href="/publisher/${row_dict['publisher_name']}">${row_dict['publisher_title']}</a></td>
<td><a href="${h.url_for(controller='package', action='read', id=row_dict['package_name'])}">${row_dict['package_title']}</a></td>
<td>${row_dict.get('package_notes')}</td>
<td><a href="/dataset/${row_dict['package_name']}/resource/${row_dict['resource_id']}">${row_dict['resource_position']}</a></td>
<td><a href="${row_dict['resource_url']}" style="word-wrap:break-word;">${row_dict['resource_url']}</a></td>
<td>${row_dict.get('resource_description', 'not recorded')}</td>
<td>${row_dict.get('resource_format', 'not recorded')}</td>
<td>${row_dict.get('resource_created').strftime('%d/%m/%y %H:%M') if row_dict.get('resource_created') else 'not recorded'}</td>
</tr>
</tbody>
</table>
<ul>
<li>Datasets: {{data['num_datasets']}}</li>
<li>Resources: {{data['num_resources']}}</li>
</ul>
</html>
<table class="table table-bordered table-condensed" id="report-table" style="width: 100%; table-layout: fixed;">
<thead>
<tr class="js-tooltip">
<th style="width: 60px" >Publisher</th>
<th style="width: 100px">Dataset</th>
<th style="width: 40px">Notes</th>
<th style="width: 30px" title="Index/position of the resource in the dataset">Index</th>
<th style="width: 100px">URL</th>
<th style="width: 100px">Description</th>
<th style="width: 30px">Format</th>
<th style="width: 50px">Created</th>
</tr>
</thead>
<tbody>
{% for row_dict in data['table'] %}
<tr>
<td><a href="/publisher/{{row_dict['publisher_name']}}">{{row_dict['publisher_title']}}</a></td>
<td><a href="{{h.url_for(controller='package', action='read', id=row_dict['package_name'])}}">{{row_dict['package_title']}}</a></td>
<td>{{row_dict.get('package_notes')}}</td>
<td><a href="/dataset/{{row_dict['package_name']}}/resource/{{row_dict['resource_id']}}">{{row_dict['resource_position']}}</a></td>
<td><a href="{{row_dict['resource_url']}}" style="word-wrap:break-word;">{{row_dict['resource_url']}}</a></td>
<td>{{row_dict.get('resource_description', 'not recorded')}}</td>
<td>{{row_dict.get('resource_format', 'not recorded')}}</td>
<td>{{row_dict.get('resource_created').strftime('%d/%m/%y %H:%M') if row_dict.get('resource_created') else 'not recorded'}}</td>
</tr>
{% endfor %}
</tbody>
</table>
<html xmlns:py="http://genshi.edgewall.org/"
xmlns:i18n="http://genshi.edgewall.org/i18n"
xmlns:xi="http://www.w3.org/2001/XInclude"
py:strip="">
<div class="widget-container">
<p>
Number of unpublished datasets: ${len(c.data['table'])}
</p>
<table class="table table-bordered table-condensed tablesorter" id="report-table" style="width: 100%;table-layout:fixed; margin-top: 8px;">
<thead>
<tr>
<th style="width: 80px">Dataset</th>
<th style="width: 80px">Organization</th>
<th style="width: 200px">Description</th>
<th style="width: 80px">Publish date</th>
<th style="width: 50px">Will not be released</th>
<th style="width: 150px">Release notes</th>
</tr>
</thead>
<tbody>
<py:for each="dataset in c.data['table']">
<tr>
<td><a href="/dataset/${dataset['name']}">${dataset['title']}</a></td>
<td><a href="/publisher/${dataset['organization name']}">${dataset['organization title']}</a></td>
<td>${dataset['notes']}</td>
<td>${dataset['publish date']}</td>
<td>${dataset['will not be released']}</td>
<td>${dataset['release notes']}</td>
</tr>
</py:for>
</tbody>
</table>
</div>
</html>
<div class="widget-container">
<p>
Number of unpublished datasets: {{data['table']|length }}
</p>
<table class="table table-bordered table-condensed tablesorter" id="report-table" style="width: 100%;table-layout:fixed; margin-top: 8px;">
<thead>
<tr>
<th style="width: 80px">Dataset</th>
<th style="width: 80px">Organization</th>
<th style="width: 200px">Description</th>
<th style="width: 80px">Publish date</th>
<th style="width: 50px">Will not be released</th>
<th style="width: 150px">Release notes</th>
</tr>
</thead>
<tbody>
{% for dataset in data['table'] %}
<tr>
<td><a href="/dataset/{{dataset['name']}}">{{dataset['title']}}</a></td>
<td><a href="/publisher/{{dataset['organization name']}}">{{dataset['organization title']}}</a></td>
<td>{{dataset['notes']}}</td>
<td>{{dataset['publish date']}}</td>
<td>{{dataset['will not be released']}}</td>
<td>{{dataset['release notes']}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment