Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete Datastore Table Button #197

Merged
merged 9 commits into from
Feb 1, 2024
24 changes: 13 additions & 11 deletions ckanext/xloader/templates/xloader/resource_data.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,32 @@
{% set delete_action = h.url_for('xloader.delete_datastore_table', id=pkg.id, resource_id=res.id) %}
JVickery-TBS marked this conversation as resolved.
Show resolved Hide resolved
{% set show_table = true %}

{% block upload_ds_button %}
<form method="post" action="{{ action }}" class="datapusher-form mb-3 mr-3 d-inline-block">
{{ h.csrf_input() if 'csrf_input' in h }}
<button class="btn btn-primary" name="save" type="submit">
<i class="fa fa-cloud-upload"></i> {{ _('Upload to DataStore') }}
</button>
</form>
{% endblock %}

<div class="clear-fix mx-1 d-inline-block"></div>

{% block delete_ds_button %}
{% if res.datastore_active %}
<form method="post" action="{{ delete_action }}" class="mb-3 d-inline-block">
{{ h.csrf_input() if 'csrf_input' in h }}
<a href="{{ h.url_for('xloader.delete_datastore_table', id=pkg.id, resource_id=res.id) }}"
class="btn btn-danger pull-left"
class="btn btn-danger"
type="submit"
data-module="confirm-action"
data-module-with-data=true
data-module-content="{{ _('Are you sure you want to delete the DataStore and Data Dictionary?') }}"
>{% block delete_datastore_button_text %}<i class="fa fa-remove"></i>{{ _('Delete from DataStore') }}{% endblock %}</a>
>{% block delete_datastore_button_text %}<i class="fa fa-trash-alt"></i> {{ _('Delete from DataStore') }}{% endblock %}</a>
</form>
{% endif %}
{% endblock %}

{% block upload_ds_button %}
<form method="post" action="{{ action }}" class="datapusher-form mb-3 d-inline-block">
{{ h.csrf_input() if 'csrf_input' in h }}
<button class="btn btn-primary" name="save" type="submit">
<i class="fa fa-cloud-upload"></i> {{ _('Upload to DataStore') }}
</button>
</form>
{% endblock %}

{% if status.error and status.error.message %}
{% set show_table = false %}
<div class="alert alert-error">
Expand Down
10 changes: 9 additions & 1 deletion ckanext/xloader/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ def get_blueprints():

@xloader.route("/dataset/<id>/resource_data/<resource_id>", methods=("GET", "POST"))
def resource_data(id, resource_id):
return utils.resource_data(id, resource_id)
rows = request.args.get('rows')
JVickery-TBS marked this conversation as resolved.
Show resolved Hide resolved
if rows:
try:
rows = int(rows)
if rows < 0:
rows = None
except ValueError:
rows = None
return utils.resource_data(id, resource_id, rows)


@xloader.route("/dataset/<id>/delete-datastore/<resource_id>", methods=("GET", "POST"))
Expand Down
Loading