Skip to content

Commit a1f7a12

Browse files
Show only template predifined resource metadata fields on UI additional info table
1 parent ff5e4db commit a1f7a12

1 file changed

Lines changed: 97 additions & 0 deletions

File tree

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{% extends "package/resource_read.html" %}
2+
3+
{%- set exclude_fields = [
4+
'name',
5+
'description',
6+
'url',
7+
'format',
8+
] -%}
9+
{%- set schema = h.scheming_get_dataset_schema(dataset_type) -%}
10+
11+
{% block resource_additional_information_inner %}
12+
{% if res.datastore_active %}
13+
{% block resource_data_dictionary %}
14+
{{ super() }}
15+
{% endblock %}
16+
{% endif %}
17+
18+
<div class="module-content">
19+
{%- block additional_info_heading -%}<h2>{{ _('Additional Information') }}</h2>{%- endblock -%}
20+
<table class="table table-striped table-bordered table-condensed">
21+
{%- block additional_info_table_head -%}
22+
<thead>
23+
<tr>
24+
<th scope="col">{{ _('Field') }}</th>
25+
<th scope="col">{{ _('Value') }}</th>
26+
</tr>
27+
</thead>
28+
{%- endblock -%}
29+
<tbody>
30+
{%- block resource_last_updated -%}
31+
<tr>
32+
<th scope="row">{{ _('Data last updated') }}</th>
33+
<td>{{ h.render_datetime(res.last_modified) or h.render_datetime(res.created) or _('unknown') }}</td>
34+
</tr>
35+
{%- endblock -%}
36+
{%- block resource_metadata_last_updated -%}
37+
<tr>
38+
<th scope="row">{{ _('Metadata last updated') }}</th>
39+
<td>{{ h.render_datetime(res.metadata_modified) or h.render_datetime(res.created) or _('unknown') }}</td>
40+
</tr>
41+
{%- endblock -%}
42+
{%- block resource_created -%}
43+
<tr>
44+
<th scope="row">{{ _('Created') }}</th>
45+
<td>{{ h.render_datetime(res.created) or _('unknown') }}</td>
46+
</tr>
47+
{%- endblock -%}
48+
{%- block resource_format -%}
49+
<tr>
50+
<th scope="row">{{ _('Format') }}</th>
51+
<td>{{ res.format or res.mimetype_inner or res.mimetype or _('unknown') }}</td>
52+
</tr>
53+
{%- endblock -%}
54+
{%- block resource_license -%}
55+
<tr>
56+
<th scope="row">{{ _('License') }}</th>
57+
<td>{% snippet "snippets/license.html", pkg_dict=pkg, text_only=True %}</td>
58+
</tr>
59+
{%- endblock -%}
60+
{%- block resource_fields -%}
61+
{%- for field in schema.resource_fields -%}
62+
{%- if field.field_name not in exclude_fields
63+
and field.display_snippet is not none -%}
64+
<tr>
65+
<th scope="row">
66+
{{- h.scheming_language_text(field.label) -}}
67+
</th>
68+
<td>
69+
{%- snippet 'scheming/snippets/display_field.html',
70+
field=field, data=res, entity_type='dataset',
71+
object_type=dataset_type -%}
72+
</td>
73+
</tr>
74+
{%- endif -%}
75+
{%- endfor -%}
76+
{%- endblock -%}
77+
{%- block resource_more_items -%}
78+
{#- Whitelist only these raw resource-dict fields, relabel them, and
79+
render as plain rows (no toggle-more) so no "Show more" button appears. -#}
80+
{%- set item_labels = {
81+
'package id': _('Package id'),
82+
'id': _('Resource id'),
83+
'resource id': _('Resource id'),
84+
'size': _('Size'),
85+
} -%}
86+
{% for key, value in h.format_resource_items(res.items()) %}
87+
{% if key in item_labels %}
88+
<tr><th scope="row">{{ item_labels[key] }}</th><td>{{ value }}</td></tr>
89+
{% endif %}
90+
{% endfor %}
91+
{%- endblock -%}
92+
</tbody>
93+
</table>
94+
95+
96+
</div>
97+
{% endblock %}

0 commit comments

Comments
 (0)