Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

Commit

Permalink
Only show LA Function and LA Service fields if the data is present, a…
Browse files Browse the repository at this point in the history
…s it is so rare.
  • Loading branch information
David Read committed Mar 1, 2016
1 parent f7fdd3e commit 8467bd4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
15 changes: 3 additions & 12 deletions ckanext/dgu/lib/helpers.py
Expand Up @@ -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')
Expand Down Expand Up @@ -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'):
Expand Down Expand Up @@ -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


Expand Down
3 changes: 1 addition & 2 deletions ckanext/dgu/theme/templates/package/read.html
Expand Up @@ -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 %}
Expand Down Expand Up @@ -202,7 +201,7 @@ <h2>Additional Links ({{h.additional_resources()|length + h.gemini_resources()|l
<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>
Expand Down

0 comments on commit 8467bd4

Please sign in to comment.