-
Notifications
You must be signed in to change notification settings - Fork 2k
/
package_basic_fields.html
118 lines (102 loc) · 5.82 KB
/
package_basic_fields.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
{% import 'macros/form.html' as form %}
{% block package_basic_fields_title %}
{{ form.input('title', id='field-title', label=_('Title'), placeholder=_('eg. A descriptive title'), value=data.title, error=errors.title, classes=['control-full', 'control-large'], attrs={'data-module': 'slug-preview-target'}) }}
{% endblock %}
{% block package_basic_fields_url %}
{% set prefix = h.url_for(controller='package', action='read', id='') %}
{% set domain = h.url_for(controller='package', action='read', id='', qualified=true) %}
{% set domain = domain|replace("http://", "")|replace("https://", "") %}
{% set attrs = {'data-module': 'slug-preview-slug', 'data-module-prefix': domain, 'data-module-placeholder': '<dataset>'} %}
{{ form.prepend('name', id='field-name', label=_('URL'), prepend=prefix, placeholder=_('eg. my-dataset'), value=data.name, error=errors.name, attrs=attrs, is_required=true) }}
{% endblock %}
{% block package_basic_fields_custom %}{% endblock %}
{% block package_basic_fields_description %}
{{ form.markdown('notes', id='field-notes', label=_('Description'), placeholder=_('eg. Some useful notes about the data'), value=data.notes, error=errors.notes) }}
{% endblock %}
{% block package_basic_fields_tags %}
{% set tag_attrs = {'data-module': 'autocomplete', 'data-module-tags': '', 'data-module-source': '/api/2/util/tag/autocomplete?incomplete=?'} %}
{{ form.input('tag_string', id='field-tags', label=_('Tags'), placeholder=_('eg. economy, mental health, government'), value=data.tag_string, error=errors.tags, classes=['control-full'], attrs=tag_attrs) }}
{% endblock %}
{% block package_basic_fields_license %}
<div class="control-group">
{% set error = errors.license_id %}
<label class="control-label" for="field-license">{{ _("License") }}</label>
<div class="controls">
<select id="field-license" name="license_id" data-module="autocomplete">
{% set existing_license_id = data.get('license_id') %}
{% for license_id, license_desc in h.license_options(existing_license_id) %}
<option value="{{ license_id }}" {% if existing_license_id == license_id %}selected="selected"{% endif %}>{{ license_desc }}</option>
{% endfor %}
</select>
{% if error %}<span class="error-block">{{ error }}</span>{% endif %}
<span class="info-block info-inline">
<i class="icon-info-sign"></i>
{% trans %}
License definitions and additional information can be found
at <a href="http://opendefinition.org/licenses/">opendefinition.org</a>
{% endtrans %}
</span>
</div>
</div>
{% endblock %}
{% block package_basic_fields_org %}
{# if we have a default group then this wants remembering #}
{% if data.group_id %}
<input type="hidden" name="groups__0__id" value="{{ data.group_id }}" />
{% endif %}
{% set dataset_is_draft = data.get('state', 'draft').startswith('draft') or data.get('state', 'none') == 'none' %}
{% set dataset_has_organization = data.owner_org or data.group_id %}
{% set organizations_available = h.organizations_available('create_dataset') %}
{% set user_is_sysadmin = h.check_access('sysadmin') %}
{% set show_organizations_selector = organizations_available %}
{% set show_visibility_selector = dataset_has_organization or (organizations_available and (user_is_sysadmin or dataset_is_draft)) %}
{% if show_organizations_selector and show_visibility_selector %}
<div data-module="dataset-visibility">
{% endif %}
{% if show_organizations_selector %}
{% set existing_org = data.owner_org or data.group_id %}
<div class="control-group">
<label for="field-organizations" class="control-label">{{ _('Organization') }}</label>
<div class="controls">
<select id="field-organizations" name="owner_org" data-module="autocomplete">
{% if h.check_config_permission('create_unowned_dataset') %}
<option value="" {% if not selected_org and data.id %} selected="selected" {% endif %}>{{ _('No organization') }}</option>
{% endif %}
{% for organization in organizations_available %}
{# get out first org from users list only if there is not an existing org #}
{% set selected_org = (existing_org and existing_org == organization.id) or (not existing_org and not data.id and organization.id == organizations_available[0].id) %}
<option value="{{ organization.id }}" {% if selected_org %} selected="selected" {% endif %}>{{ organization.display_name }}</option>
{% endfor %}
</select>
</div>
</div>
{% endif %}
{% if show_visibility_selector %}
{% block package_metadata_fields_visibility %}
<div class="control-group">
<label for="field-private" class="control-label">{{ _('Visibility') }}</label>
<div class="controls">
<select id="field-private" name="private">
{% for option in [('True', _('Private')), ('False', _('Public'))] %}
<option value="{{ option[0] }}" {% if option[0] == data.private|trim %}selected="selected"{% endif %}>{{ option[1] }}</option>
{% endfor %}
</select>
</div>
</div>
{% endblock %}
{% endif %}
{% if show_organizations_selector and show_visibility_selector %}
</div>
{% endif %}
{% if data.id and h.check_access('package_delete', {'id': data.id}) and data.state != 'active' %}
<div class="control-group">
<label for="field-state" class="control-label">{{ _('State') }}</label>
<div class="controls">
<select id="field-state" name="state">
<option value="active" {% if data.get('state', 'none') == 'active' %} selected="selected" {% endif %}>{{ _('Active') }}</option>
<option value="deleted" {% if data.get('state', 'none') == 'deleted' %} selected="selected" {% endif %}>{{ _('Deleted') }}</option>
</select>
</div>
</div>
{% endif %}
{% endblock %}