Commit 616ec22a authored by Tom Mortimer-Jones's avatar Tom Mortimer-Jones
Browse files

Merge pull request #9 from datagovuk/jinjafication

Convert report template to Jinja2
parents 87b3d8e2 38b8ff15
<html xmlns:py="http://genshi.edgewall.org/"
xmlns:i18n="http://genshi.edgewall.org/i18n"
xmlns:xi="http://www.w3.org/2001/XInclude"
py:strip="">
<py:if test="c.options['organization'] == None"> {% if c.options['organization'] == None %}
<ul> <ul>
<li>Broken datasets: ${c.data['num_broken_packages']} / ${c.data['num_packages']} (${c.data.get('broken_package_percent')}%)</li> <li>Broken datasets: {{c.data['num_broken_packages']}} / {{c.data['num_packages']}} ({{c.data.get('broken_package_percent')}}%)</li>
<li>Broken links: ${c.data['num_broken_resources']} / ${c.data['num_resources']} (${c.data.get('broken_resource_percent')}%)</li> <li>Broken links: {{c.data['num_broken_resources']}} / {{c.data['num_resources']}} ({{c.data.get('broken_resource_percent')}}%)</li>
</ul> </ul>
<table class="table table-striped table-bordered table-condensed tablesorter" id="report-table"> <table class="table table-striped table-bordered table-condensed tablesorter" id="report-table">
<thead> <thead>
...@@ -18,28 +14,31 @@ ...@@ -18,28 +14,31 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr py:for="row in c.data['table']"> {% for row in c.data['table']%}
<!-- <td>${h.link_to(row['organization_title'], h.url_for(controller='ckanext.dgu.controllers.reports:ReportsController', action='view', report_name='broken_links', organization=row['organization_name'], **c.options))}</td>--> <tr>
<td>${h.link_to(row['organization_title'], h.relative_url_for(organization=row['organization_name']))}</td> <td>{{h.link_to(row['organization_title'], h.relative_url_for(organization=row['organization_name']))}}</td>
<td>${row['broken_package_count']}</td> <td>{{row['broken_package_count']}}</td>
<td>${row['broken_resource_count']}</td> <td>{{row['broken_resource_count']}}</td>
<td>${row.get('broken_resource_percent')}</td> <td>{{row.get('broken_resource_percent')}}</td>
</tr> </tr>
{% endfor %}
</tbody> </tbody>
</table> </table>
</py:if> {% endif %}
<py:if test="c.options['organization'] != None"> {% if c.options['organization'] != None %}
<ul> <ul>
<li>Broken datasets: ${c.data['num_broken_packages']} / ${c.data['num_packages']} (${c.data.get('broken_package_percent')}%)</li> <li>Broken datasets: {{c.data['num_broken_packages']}} / {{c.data['num_packages']}} ({{c.data.get('broken_package_percent')}}%)</li>
<li>Broken links: ${c.data['num_broken_resources']} / ${c.data['num_resources']} (${c.data.get('broken_resource_percent')}%)</li> <li>Broken links: {{c.data['num_broken_resources']}} / {{c.data['num_resources']}} ({{c.data.get('broken_resource_percent')}}%)</li>
</ul> </ul>
<table class="table table-striped table-bordered table-condensed tablesorter" id="report-table" style="width: 100%; table-layout: fixed;"> <table class="table table-striped table-bordered table-condensed tablesorter" id="report-table" style="width: 100%; table-layout: fixed;">
<thead> <thead>
<tr class="js-tooltip" style="letter-spacing: -1px; font-size: 13px;"> <tr class="js-tooltip" style="letter-spacing: -1px; font-size: 13px;">
<th style="width: 100px">Dataset</th> <th style="width: 100px">Dataset</th>
<th style="width: 45px">Notes</th> <th style="width: 45px">Notes</th>
<th py:if="c.options['include_sub_organizations']" style="width: 85px">Publisher</th> {% if c.options['include_sub_organizations'] %}
<th style="width: 85px">Publisher</th>
{% endif %}
<th style="width: 20px" title="Index/position of the resource in the dataset">Res</th> <th style="width: 20px" title="Index/position of the resource in the dataset">Res</th>
<th style="width: 190px">URL</th> <th style="width: 190px">URL</th>
<th style="width: 75px">Status</th> <th style="width: 75px">Status</th>
...@@ -51,21 +50,23 @@ ...@@ -51,21 +50,23 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr py:for="row_dict in c.data['table']"> {% for row_dict in c.data['table'] %}
<td><a href="${h.url_for(controller='package', action='read', id=row_dict['dataset_name'])}">${row_dict['dataset_title']}</a></td> <tr>
<td>${row_dict['dataset_notes']}</td> <td><a href="{{h.url_for(controller='package', action='read', id=row_dict['dataset_name'])}}">{{row_dict['dataset_title']}}</a></td>
<td py:if="c.options['include_sub_organizations']"><a href="/publisher/${row_dict['organization_name']}">${row_dict['organization_title']}</a></td> <td>{{row_dict['dataset_notes']}}</td>
<td><a href="/dataset/${row_dict['dataset_name']}/resource/${row_dict['resource_id']}">${row_dict['resource_position']}</a></td> {% if c.options['include_sub_organizations']%}
<td><a href="${row_dict['resource_url']}" style="word-wrap:break-word;">${row_dict['resource_url']}</a></td> <td><a href="/publisher/{{row_dict['organization_name']}}">{{row_dict['organization_title']}}</a></td>
<td>${row_dict.get('status', 'not recorded')}</td> {% endif %}
<td>${row_dict.get('reason', 'not recorded')}</td> <td><a href="/dataset/{{row_dict['dataset_name']}}/resource/{{row_dict['resource_id']}}">{{row_dict['resource_position']}}</a></td>
<td>${row_dict.get('failure_count', 'not recorded')}</td> <td><a href="{{row_dict['resource_url']}}" style="word-wrap:break-word;">{{row_dict['resource_url']}}</a></td>
<td>${h.render_datetime(row_dict.get('first_failure')) if row_dict.get('first_failure') else 'not recorded'}</td> <td>{{row_dict.get('status', 'not recorded')}}</td>
<td>${h.render_datetime(row_dict.get('last_updated')) if row_dict.get('last_updated') else 'not recorded'}</td> <td>{{row_dict.get('reason', 'not recorded')}}</td>
<td>${h.render_datetime(row_dict.get('last_success')) if row_dict.get('last_success') else 'not recorded'}</td> <td>{{row_dict.get('failure_count', 'not recorded')}}</td>
<td>{{h.render_datetime(row_dict.get('first_failure')) if row_dict.get('first_failure') else 'not recorded'}}</td>
<td>{{h.render_datetime(row_dict.get('last_updated')) if row_dict.get('last_updated') else 'not recorded'}}</td>
<td>{{h.render_datetime(row_dict.get('last_success')) if row_dict.get('last_success') else 'not recorded'}}</td>
</tr> </tr>
{% endfor %}
</tbody> </tbody>
</table> </table>
</py:if> {% endif %}
</html> \ No newline at end of file
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