[#18] Allow reactivation of sources
Due to #607 in CKAN core, once a source was deleted you could not reactivate it again. As a workaround, if the source is deleted the Delete button is not shown and the state select is, so you can set it to 'active'. Also fixed wrong redirect after deletion.
This commit is contained in:
parent
23d1d5742c
commit
2ee3f33f51
|
@ -31,7 +31,8 @@ class ViewController(BaseController):
|
||||||
p.toolkit.get_action('harvest_source_delete')(context, {'id':id})
|
p.toolkit.get_action('harvest_source_delete')(context, {'id':id})
|
||||||
|
|
||||||
h.flash_success(_('Harvesting source successfully inactivated'))
|
h.flash_success(_('Harvesting source successfully inactivated'))
|
||||||
redirect(h.url_for('harvest'))
|
|
||||||
|
redirect(h.url_for('{0}_admin'.format(DATASET_TYPE_NAME), id=id))
|
||||||
except p.toolkit.ObjectNotFound:
|
except p.toolkit.ObjectNotFound:
|
||||||
abort(404,_('Harvest source not found'))
|
abort(404,_('Harvest source not found'))
|
||||||
except p.toolkit.NotAuthorized:
|
except p.toolkit.NotAuthorized:
|
||||||
|
|
|
@ -70,11 +70,23 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if data.get('id', None) and h.check_access('harvest_source_delete', {'id': data.id}) and data.get('state', 'none') == 'deleted' %}
|
||||||
|
<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 %}
|
||||||
|
|
||||||
<p class="form-actions">
|
<p class="form-actions">
|
||||||
{% block delete_button %}
|
{% block delete_button %}
|
||||||
{% if h.check_access('harvest_source_delete', {'id': data.id}) %}
|
{% if data.get('id', None) and h.check_access('harvest_source_delete', {'id': data.id}) and not data.get('state', 'none') == 'deleted' %}
|
||||||
{% set locale = h.dump_json({'content': _('Are you sure you want to delete this harvest source?')}) %}
|
{% set locale = h.dump_json({'content': _('Are you sure you want to delete this harvest source?')}) %}
|
||||||
<a class="btn btn-danger pull-left" href="{% url_for 'harvest_delete', id=data.id %}" data-module="confirm-action" data-module-i18n="{{ locale }}">{% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a>
|
<a class="btn btn-danger pull-left" href="{% url_for 'harvest_delete', id=data.name %}" data-module="confirm-action" data-module-i18n="{{ locale }}">{% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue