Commit 8467bd42 authored by David Read's avatar David Read
Browse files

Only show LA Function and LA Service fields if the data is present, as it is so rare.

parent f7fdd3e0
......@@ -728,15 +728,16 @@ def get_resource_fields(resource, pkg_extras):
# calculate displayable field values
return DisplayableFields(field_names, field_value_map, pkg_extras)
def get_package_fields(package, package_dict, pkg_extras, dataset_was_harvested,
is_location_data, dataset_is_from_ns_pubhub, is_local_government_data):
is_location_data, dataset_is_from_ns_pubhub):
from ckan.lib.base import h
from ckan.lib.field_types import DateType
from ckanext.dgu.schema import GeoCoverageType
from ckanext.dgu.lib.resource_helpers import DatasetFieldNames, DisplayableFields
field_names = DatasetFieldNames(['date_added_to_dgu', 'mandate', 'temporal_coverage', 'geographic_coverage', 'schema', 'codelist', 'sla'])
field_names_display_only_if_value = ['date_update_future', 'precision', 'update_frequency', 'temporal_granularity', 'taxonomy_url', 'data_issued', 'data_modified'] # (mostly deprecated) extra field names, but display values anyway if the metadata is there
field_names_display_only_if_value = ['date_update_future', 'precision', 'update_frequency', 'temporal_granularity', 'taxonomy_url', 'data_issued', 'data_modified', 'la-function', 'la-service'] # (mostly deprecated) extra field names, but display values anyway if the metadata is there
if is_an_official():
field_names_display_only_if_value.append('external_reference')
field_names_display_only_if_value.append('import_source')
......@@ -777,8 +778,6 @@ def get_package_fields(package, package_dict, pkg_extras, dataset_was_harvested,
for date_dict in json_list(pkg_extras.get('dataset-reference-date'))])
elif dataset_is_from_ns_pubhub:
field_names.add(['national_statistic', 'categories'])
if is_local_government_data:
field_names.add(('la-function', 'la-service'))
field_names.add_after('date_added_to_dgu', 'theme')
if pkg_extras.get('theme-secondary'):
......@@ -1521,14 +1520,6 @@ def dataset_is_from_ns_pubhub(pkg_dict):
if get_pkg_dict_extra(pkg_dict, 'external_reference') == 'ONSHUB':
return True
def is_local_government_data(pkg_dict):
if pkg_dict['organization']:
from ckan import model
org = model.Group.get(pkg_dict['organization']['id'])
if org:
if org.extras.get('category') == 'local-council':
return True
# end of 'Type'/'Source' of dataset functions
......
......@@ -50,7 +50,6 @@
{% set is_location_data = h.is_location_data(c.pkg_dict) %}
{% set dataset_is_from_ns_pubhub = h.dataset_is_from_ns_pubhub(c.pkg_dict) %}
{% set is_local_government_data = h.is_local_government_data(c.pkg_dict) %}
<!-- Warn if reading old revision -->
{% if c.pkg_revision_id %}
......@@ -202,7 +201,7 @@
<h2>Additional Information</h2>
<table class="table table-bordered table-condensed table-dgu-fixed-size dgu-table" style="margin-bottom: 45px;">
<tbody>
{% for field_dict, label_attributes, value_attributes in h.get_package_fields(c.pkg, c.pkg_dict, h.as_dict(c.pkg_extras), h.was_dataset_harvested(c.pkg_extras), is_location_data, dataset_is_from_ns_pubhub, is_local_government_data) %}
{% for field_dict, label_attributes, value_attributes in h.get_package_fields(c.pkg, c.pkg_dict, h.as_dict(c.pkg_extras), h.was_dataset_harvested(c.pkg_extras), is_location_data, dataset_is_from_ns_pubhub) %}
<tr>
{# TODO: label_attributes and value_attributes are dicts, we need to decouple them #}
<td class="key" {{m.dict_to_attributes(label_attributes)}}>{{field_dict.get('label') or field_dict['name']}}</td>
......
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