Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add file size display to resource table #1102

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ckanext/canada/i18n/fr/LC_MESSAGES/canada.po
Original file line number Diff line number Diff line change
Expand Up @@ -1487,6 +1487,9 @@ msgstr "Catégorie thématique"
msgid "Format"
msgstr "Format"

msgid "Type"
msgstr "Type"

msgid "Resource Type"
msgstr "Type de ressource"

Expand Down
1 change: 1 addition & 0 deletions ckanext/canada/schemas/presets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3423,6 +3423,7 @@ presets:
fr: Taille [estimative] d’une distribution en octets
form_panel: resource
validators: ignore_missing int_validator
display_snippet: size.html

# Field = Character Set.
# {This is the character set of the dataset}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{% set type_field = h.scheming_field_by_name(schema.resource_fields, 'resource_type') %}
{% set format_field = h.scheming_field_by_name(schema.resource_fields, 'format') %}
{% set lang_field = h.scheming_field_by_name(schema.resource_fields, 'language') %}
{% set size_field = h.scheming_field_by_name(schema.resource_fields, 'size') %}

{# FIXME: using tables for formatting #}
<tr>
Expand All @@ -36,6 +37,10 @@
{% snippet 'scheming/snippets/display_field.html',
field=lang_field, data=res, entity_type='dataset', object_type=pkg.type %}
</td>
<td nowrap class="td-center">
{% snippet 'scheming/snippets/display_field.html',
field=size_field, data=res, entity_type='dataset', object_type=pkg.type %}
</td>
<td nowrap class="td-center">
<a href="{{ res.url }}" title="{{_('Resource') ~ ' ' ~ res_num}}" class="resource-url-analytics btn btn-primary" target="_blank" data-pkg-id="{{ pkg.id }}" data-res-id="{{ res.id }}" data-org-id="{{ pkg.organization.id }}">
{{ _('Access') }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@
<h4>{% block resource_list_title %}{{ _('Resources') }}{% endblock %}</h4>
{% if pkg.resources %}
{% block resource_list_inner %}
<div style="width:100%;">
<table class="wb-tables table table-striped resource-list"
data-wb-tables='{"searching":false, "info":false,
"columnDefs": [ { "orderable": false, "targets": 4 }]}'>
"columnDefs": [ { "orderable": false, "targets": [4,5] }]}'>
<thead>
<tr>
<th scope="col" nowrap class="td-full">{{ _('Resource Name') }}</th>
<th scope="col" nowrap class="td-center">{{ _('Resource Type') }}</th>
<th scope="col" nowrap class="td-full">{{ _('Name') }}</th>
<th scope="col" nowrap class="td-center">{{ _('Type') }}</th>
<th scope="col" class="td-center">{{ _('Format') }}</th>
<th scope="col" class="td-center">{{ _('Language') }}</th>
<th scope="col" class="td-center">{{ _('File Size') }}</th>
<th scope="col" nowrap class="td-center">{{ _('Links') }}</th>
</tr>
</thead>
Expand All @@ -26,6 +28,7 @@ <h4>{% block resource_list_title %}{{ _('Resources') }}{% endblock %}</h4>
{% endfor %}

</table>
</div>
{% endblock %}
{% endif %}
{% else %}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ h.localised_filesize(data[field.field_name] | int) if data[field.field_name] }}