Commit 65d736b0 authored by Tom Mortimer-Jones's avatar Tom Mortimer-Jones
Browse files

Add a publication delay field

parent eb8fc5c6
......@@ -48,6 +48,12 @@ update_frequency = [('', ''),
('monthly', 'monthly'),
('other', 'other - please specify')]
publication_delay = [('', ''),
('minimal', 'Minimal or no delay'),
('good', 'Less than half the update frequency'),
('reasonable', 'About the same as the update frequency'),
('extreme', 'Longer than the update frequency')]
temporal_granularity = [("", ""),
("year", "year"),
("quarter", "quarter"),
......@@ -242,6 +248,7 @@ class DatasetForm(p.SingletonPlugin):
'last_major_modification': [ignore_missing, date_to_db, convert_to_extras],
'update_frequency': [ignore_missing, use_other, unicode, convert_to_extras],
'update_frequency-other': [ignore_missing],
'publication_delay': [ignore_missing, unicode, convert_to_extras],
'precision': [ignore_missing, unicode, convert_to_extras],
'geographic_granularity': [ignore_missing, use_other, unicode, convert_to_extras],
'geographic_granularity-other': [ignore_missing],
......@@ -309,6 +316,7 @@ class DatasetForm(p.SingletonPlugin):
'last_major_modification': [convert_from_extras, ignore_missing, date_to_form],
'date_update_future': [convert_from_extras, ignore_missing, date_to_form],
'update_frequency': [convert_from_extras, ignore_missing, extract_other(update_frequency)],
'publication_delay': [convert_from_extras, ignore_missing],
'precision': [convert_from_extras, ignore_missing],
'geographic_granularity': [convert_from_extras, ignore_missing, extract_other(geographic_granularity)],
'geographic_coverage': [convert_from_extras, ignore_missing, convert_geographic_to_form],
......
......@@ -714,7 +714,7 @@ def get_package_fields(package, pkg_extras, dataset_was_harvested,
from ckanext.dgu.lib.resource_helpers import DatasetFieldNames, DisplayableFields
from ckanext.dgu.schema import THEMES
field_names = DatasetFieldNames(['date_added_to_dgu', 'mandate', 'temporal_coverage', 'geographic_coverage'])
field_names = DatasetFieldNames(['date_added_to_dgu', 'mandate', 'temporal_coverage', 'geographic_coverage', 'publication_delay'])
field_names_display_only_if_value = ['date_update_future', 'precision', 'update_frequency', 'temporal_granularity', 'taxonomy_url', 'data_modified'] # (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')
......@@ -811,6 +811,14 @@ def get_package_fields(package, pkg_extras, dataset_was_harvested,
except ValueError:
pass # Not JSON for some reason...
publication_delay = pkg_extras.get('publication_delay')
if publication_delay:
mapping = dict(get_dgu_dataset_form_options('publication_delay'))
try:
publication_delay = mapping[publication_delay]
except KeyError:
publication_delay = ''
field_value_map = {
# field_name : {display info}
'date_added_to_dgu': {'label': 'Added to data.gov.uk', 'value': package.metadata_created.strftime('%d/%m/%Y')},
......@@ -825,6 +833,7 @@ def get_package_fields(package, pkg_extras, dataset_was_harvested,
'date_updated': {'label': 'Date data last updated', 'value': DateType.db_to_form(pkg_extras.get('date_updated', ''))},
'date_released': {'label': 'Date data last released', 'value': DateType.db_to_form(pkg_extras.get('date_released', ''))},
'temporal_coverage': {'label': 'Temporal coverage', 'value': temporal_coverage},
'publication_delay': {'label': 'Publication delay', 'value': publication_delay},
'geographic_coverage': {'label': 'Geographic coverage', 'value': GeoCoverageType.strip_off_binary(pkg_extras.get('geographic_coverage', ''))},
'resource-type': {'label': 'Gemini2 resource type', 'value': pkg_extras.get('resource-type')},
'spatial-data-service-type': {'label': 'Gemini2 service type', 'value': pkg_extras.get('spatial-data-service-type')},
......
......@@ -141,6 +141,8 @@ organisation_name_mapping = {
update_frequency_options = ['never', 'discontinued', 'annual', 'quarterly', 'monthly']
publication_delay_options = ['minimal', 'good', 'reasonable', 'extreme']
geographic_granularity_options = ['national', 'regional', 'local authority', 'ward', 'point']
temporal_granularity_options = ['year', 'quarter', 'month', 'week', 'day', 'hour', 'point']
......
......@@ -115,8 +115,9 @@ Passed in:
<!-- The resource fieldset for a timeseries dataset -->
<fieldset id="package_type-timeseries">
<div class="well form-inline">
<label for="update_frequency" class="js-tooltip" title="How frequently new data files are published. For one-off data, use 'never'. For those once updated but now discontinued, use 'discontinued'.">
<div class="well">
<div class="form-group form-inline">
<label for="update_frequency" class="col-xs-3 js-tooltip" title="How frequently new data files are published. For one-off data, use 'never'. For those once updated but now discontinued, use 'discontinued'.">
Update frequency <i class="icon-info-sign"></i>
</label>
<select style="width: 200px;" class="form-control" id="update_frequency" name="update_frequency">
......@@ -128,8 +129,20 @@ Passed in:
</select>
<label style="margin-left: 20px;" class="" for="update_frequency-other">Other:</label>
<input class="form-control" style="width: 200px;" id="update_frequency-other" name="update_frequency-other" type="text" value="{{data.get('update_frequency-other', '')}}"/>
</div><!-- /well -->
</div>
{{ m.display_error(errors, 'update_frequency') }}
<div class="form-group">
<label for="publication_delay" class="col-xs-3 js-tooltip" title="How long is the delay between creating and publishing the data?">Publication delay <i class="icon-info-sign"></i></label>
<select style="width: 200px;" class="form-control" id="publication_delay" name="publication_delay">
{% for name, desc in h.get_dgu_dataset_form_options('publication_delay') %}
<option value="{{name}}" {% if data.get('publication_delay', '') == name %}selected="selected"{% endif %} >
{{desc}}
</option>
{% endfor %}
</select>
</div>
{{ m.display_error(errors, 'publication_delay') }}
</div><!-- /well -->
<table class="flexitable table table-bordered table-condensed table-striped" id="timeseries_resources-table">
<thead>
......
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