{% import 'macros/form.html' as form %} {% set data = data or {} %} {% set errors = errors or {} %} {% set action = form_action or h.url_for(controller='package', action='new_resource', id=pkg_name) %}
{% block stages %} {# An empty stages variable will not show the stages #} {% if stage %} {{ h.snippet('package/snippets/stages.html', stages=stage, pkg_name=pkg_name) }} {% endif %} {% endblock %} {{ form.errors(error_summary) }} {% block basic_fields_url %} {% set is_upload = (data.url_type == 'upload') %} {{ form.image_upload(data, errors, field_url='url', field_upload='upload', field_clear='clear_upload', is_upload_enabled=h.uploads_enabled(), is_url=data.url and not is_upload, is_upload=is_upload, upload_label=_('File'), url_label=_('URL')) }} {% endblock %} {% block basic_fields_name %} {{ form.input('name', id='field-name', label=_('Name'), placeholder=_('eg. January 2011 Gold Prices'), value=data.name, error=errors.name, classes=['control-full']) }} {% endblock %} {% block basic_fields_description %} {{ form.markdown('description', id='field-description', label=_('Description'), placeholder=_('Some useful notes about the data'), value=data.description, error=errors.description) }} {% endblock %} {% block basic_fields_format %} {% set format_attrs = {'data-module': 'autocomplete', 'data-module-source': '/api/2/util/resource/format_autocomplete?incomplete=?'} %} {% call form.input('format', id='field-format', label=_('Format'), placeholder=_('eg. CSV, XML or JSON'), value=data.format, error=errors.format, classes=['control-medium'], attrs=format_attrs) %} {{ _('This will be guessed automatically. Leave blank if you wish') }} {% endcall %} {% endblock %} {% block budget_fields %} {% call form.select('country', id='field-country', label=_('Country'), options=h.get_countries(), selected=data.country, error=errors.country, classes=['control-small']) %} {{ _('The country the data applies to.') }} {{ _('This field is optional.') }} {% endcall %} {% call form.select('currency', id='field-currency', label=_('Currency'), options=h.get_currencies(), selected=data.currency, error=errors.currency, classes=['control-small']) %} {{ _('The currency of amounts in this data are in.') }} {{ _('This field is optional.') }} {% endcall %} {% call form.input('year', id='field-year', label=_('Year'), placeholder=_('e.g. 2012, 2014'), value=data.year, error=errors.year, classes=['control-small']) %} {{ _('The year this data refers to.') }} {{ _('This field is optional.') }} {% endcall %} {% call form.select('status', id='field-status', label=_('Publication status'), options=h.get_statuses(), selected=data.status, error=errors.status, classes=['control-small']) %} {{ _('The status of this data in the publication workflow, if applicable.') }} {{ _('This field is optional.') }} {% endcall %} {% endblock %} {% block metadata_fields %} {% if include_metadata %} {# TODO: Where do these come from, they don't exist in /package/new_package_form.html #} {# {{ form.select('resource_type', id='field-type', label=_('Resource Type'), options=[{'value': 'empty', 'text': _('Select a type…')}], selected="empty", error=errors.type) }} #} {{ form.input('last_modified', id='field-last-modified', label=_('Last Modified'), placeholder=_('eg. 2012-06-05'), value=data.last_modified, error=errors.last_modified, classes=[]) }} {{ form.input('size', id='field-size', label=_('File Size'), placeholder=_('eg. 1024'), value=data.size, error=errors.size, classes=[]) }} {{ form.input('mimetype', id='field-mimetype', label=_('MIME Type'), placeholder=_('eg. application/json'), value=data.mimetype, error=errors.mimetype, classes=[]) }} {{ form.input('mimetype_inner', id='field-mimetype-inner', label=_('MIME Type'), placeholder=_('eg. application/json'), value=data.mimetype_inner, error=errors.mimetype_inner, classes=[]) }} {% endif %} {% endblock %}
{% block delete_button %} {% if data.id %} {% if h.check_access('resource_delete', {'id': data.id}) %} {% set locale = h.dump_json({'content': _('Are you sure you want to delete this resource?')}) %} {% block delete_button_text %}{{ _('Delete') }}{% endblock %} {% endif %} {% endif %} {% endblock %} {% if stage %} {% block previous_button %} {% endblock %} {% block again_button %} {% endblock %} {% block save_button %} {% endblock %} {% else %} {% block add_button %} {% endblock %} {% endif %}