Skip to content

Commit 559962b

Browse files
authored
Disable download (#502)
1 parent a1311bd commit 559962b

File tree

6 files changed

+24
-3
lines changed

6 files changed

+24
-3
lines changed

ckanext/querytool/controllers/querytool.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ def querytool_edit(self, querytool=None, data=None,
248248
_querytool['icon'] = data['icon']
249249
_querytool['selection_label'] = data.get('selection_label')
250250
_querytool['report_caption'] = data.get('report_caption')
251+
_querytool['download_options'] = data.get('download_options')
251252

252253
try:
253254
junk = _get_action('querytool_update', _querytool)

ckanext/querytool/logic/action/update.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def querytool_update(context, data_dict):
2727
:param y_axis_columns
2828
:param selection_label
2929
:param report_caption
30+
:param download_options
3031
'''
3132

3233
# we need the querytool name in the context for name validation
@@ -60,7 +61,7 @@ def querytool_update(context, data_dict):
6061
'dataset_name', 'owner_org', 'icon', 'image_url', 'image_display_url',
6162
'filters', 'sql_string', 'related_querytools',
6263
'chart_resource', 'y_axis_columns', 'additional_description', 'selection_label',
63-
'report_caption']
64+
'report_caption', 'download_options']
6465

6566
dataset_name = data.get('dataset_name')
6667
dataset = _get_action('package_show')(context, {'id': dataset_name})

ckanext/querytool/logic/schema.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ def querytool_schema():
3737
'image_url': [ignore_missing, unicode],
3838
'selection_label': [ignore_missing, unicode],
3939
'report_caption': [ignore_missing, unicode],
40+
'download_options': [ignore_missing, boolean_validator],
4041
}

ckanext/querytool/model.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def setup():
3838
Session.execute('ALTER TABLE ckanext_querytool ADD COLUMN IF NOT EXISTS image_display_url TEXT;')
3939
Session.execute('ALTER TABLE ckanext_querytool ADD COLUMN IF NOT EXISTS selection_label TEXT;')
4040
Session.execute('ALTER TABLE ckanext_querytool ADD COLUMN IF NOT EXISTS report_caption TEXT;')
41+
Session.execute('ALTER TABLE ckanext_querytool ADD COLUMN IF NOT EXISTS download_options BOOLEAN;')
4142
Session.commit()
4243
inspector = Inspector.from_engine(engine)
4344

@@ -160,6 +161,8 @@ def define_query_tool_table():
160161
default=u''),
161162
Column('report_caption', types.UnicodeText,
162163
default=u''),
164+
Column('download_options', types.Boolean,
165+
default=True),
163166
Index('ckanext_querytool_id_idx',
164167
'id'))
165168

ckanext/querytool/templates/querytool/admin/snippets/edit_data_form.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,17 @@
107107
</select>
108108
</div>
109109
</div>
110+
111+
<div class="control-group">
112+
<label for="field-download" class="control-label">{{ _('Download Options') }}</label>
113+
<div class="controls">
114+
<select id="field-download" name="download_options">
115+
{% for option in [(True, _('Enabled')), (False, _('Disabled'))] %}
116+
<option value="{{ option[0] }}" {% if option[0] == data.download_options %}selected="selected"{% endif %}>{{ option[1] }}</option>
117+
{% endfor %}
118+
</select>
119+
</div>
120+
</div>
110121
<hr>
111122
<fieldset id="related_querytools">
112123
{% if data.related_querytools %}

ckanext/querytool/templates/querytool/public/read.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ <h1>{{ querytools[0].title }}</h1>
112112

113113
<div class="controls-wrap" id="{{ querytool.name }}" >
114114
<div class="btn-download">
115-
<div class="btn-group dropdown">
115+
116+
{% set show_download = querytool.download_options %}
117+
{% if show_download == true %}
118+
<div class="btn-group dropdown">
116119
<button class="btn btn-round dropdown-toggle" data-toggle="dropdown" href="#">
117120
{{ _('Download') }} <img src="/base/images/download.svg" width="15" />
118121
</button>
@@ -140,7 +143,8 @@ <h1>{{ querytools[0].title }}</h1>
140143
</li>
141144
</ul>
142145
</div>
143-
146+
{% endif %}
147+
144148
<button class="btn btn-round" href="#embed-{{ querytools[0].name }}"
145149
data-module="tool-embed"
146150
data-module-id="{{ querytools[0].id }}" >{{ _('Share') }} <img src="/base/images/share.svg" width="15"/> </button>

0 commit comments

Comments
 (0)