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

Fixes BS5 class and add CSRF support to all forms #167

Merged
merged 3 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<p>{{ _('Are you sure you want to remove this user as a Showcase Admin - {name}?').format(name=c.user_dict.name) }}</p>
<p class="form-actions">
<form action="{{ h.url_for(showcase_admin_remove_route) }}" method="post">
{{ h.csrf_input() if 'csrf_input' in h }}
<input type="hidden" name="user" value="{{ c.user_id }}" />
<button class="btn" type="submit" name="cancel" >{{ _('Cancel') }}</button>
<button class="btn btn-primary" type="submit" name="delete" >{{ _('Confirm Remove') }}</button>
Expand Down
3 changes: 2 additions & 1 deletion ckanext/showcase/templates/admin/manage_showcase_admins.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ <h1 class="page-heading">
</h1>
{% block form %}
<form class="dataset-form form-horizontal add-member-form" method='post'>
{{ h.csrf_input() if 'csrf_input' in h }}
<div class="row-fluid">
<div class="control-group control-medium">
<label class="control-label" for="username">
Expand Down Expand Up @@ -52,7 +53,7 @@ <h3 class="page-heading">{{ _('Showcase Admins') }}</h3>
{{ h.linked_user(user_dict['id'], maxlength=20) }}
{% set locale = h.dump_json({'content': _('Are you sure you want to remove this user from the Showcase Admin list?')}) %}
<div class="btn-group pull-right">
<a class="btn btn-danger btn-small" href="{{ h.url_for(showcase_admin_remove_route, user=user_dict['id']) }}" data-module="confirm-action" data-module-i18n="{{ locale }}" title="{{ _('Remove') }}">{% block delete_button_text %}<i class="icon-remove"></i> {{ _('Remove') }}{% endblock %}</a>
<a class="btn btn-danger btn-sm" href="{{ h.url_for(showcase_admin_remove_route, user=user_dict['id']) }}" data-module="confirm-action" data-module-i18n="{{ locale }}" title="{{ _('Remove') }}">{% block delete_button_text %}<i class="icon-remove"></i> {{ _('Remove') }}{% endblock %}</a>
</div>
</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{% block primary_content_inner %}
{% if h.check_access('ckanext_showcase_update') and c.showcase_dropdown %}
<form method="post" class="form-horizontal" id="showcase-add">
{{ h.csrf_input() if 'csrf_input' in h }}
<select id="field-add_showcase" name="showcase_added" data-module="autocomplete">
{% for option in c.showcase_dropdown %}
<option value="{{ option[0] }}"> {{ option[1] }}</option>
Expand Down
2 changes: 1 addition & 1 deletion ckanext/showcase/templates/package/read_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

{% block content_primary_nav %}
{{ super() }}
{{ h.build_nav_icon(showcase_dataset_showcase_list_route, _('Showcases'), id=pkg.name) }}
{{ h.build_nav_icon(showcase_dataset_showcase_list_route, _('Showcases'), id=pkg.name, icon='trophy') }}
{% endblock %}
1 change: 1 addition & 0 deletions ckanext/showcase/templates/showcase/add_datasets.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ <h3 class="page-heading">
{% block package_search_results_list %}
{% if c.page.items %}
<form method="POST" data-module="basic-form">
{{ h.csrf_input() if 'csrf_input' in h }}
{#{% block errors %}{{ form.errors(error_summary) }}{% endblock %}#}
<table class="table table-bordered table-header table-hover table-bulk-edit table-edit-hover" data-module="table-selectable-rows">
<col width="8">
Expand Down
1 change: 1 addition & 0 deletions ckanext/showcase/templates/showcase/confirm_delete.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<p>{{ _('Are you sure you want to delete showcase - {showcase_name}?').format(showcase_name=pkg.name) }}</p>
<p class="form-actions">
<form action="{{ h.url_for(showcase_delete_route, id=c.pkg_dict.name) }}" method="post">
{{ h.csrf_input() if 'csrf_input' in h }}
<button class="btn" type="submit" name="cancel" >{{ _('Cancel') }}</button>
<button class="btn btn-primary" type="submit" name="delete" >{{ _('Confirm Delete') }}</button>
</form>
Expand Down
2 changes: 2 additions & 0 deletions ckanext/showcase/templates/showcase/manage_datasets.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ <h3 class="page-heading">{{ _('Datasets available to add to this showcase') }}</
{% block package_search_results_list %}
{% if c.page.items %}
<form method="POST" data-module="basic-form">
{{ h.csrf_input() if 'csrf_input' in h }}
{#{% block errors %}{{ form.errors(error_summary) }}{% endblock %}#}
<table class="table table-bordered table-header table-hover table-bulk-edit table-edit-hover" data-module="table-selectable-rows">
<col width="8">
Expand Down Expand Up @@ -96,6 +97,7 @@ <h3 class="dataset-heading">
<h3 class="page-heading">{{ _('Datasets in this showcase') }}</h3>
{% if c.showcase_pkgs %}
<form method="POST" data-module="basic-form">
{{ h.csrf_input() if 'csrf_input' in h }}
<table class="table table-bordered table-header table-hover table-bulk-edit table-edit-hover" data-module="table-selectable-rows">
<col width="8">
<col width="120">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ <h3 class="media-heading">{{ h.link_to(title|truncate(truncate_title), h.url_for
</a>
{% endblock %}
{% if show_remove %}
<form method="post"><input type="hidden" value="{{ package.id }}" name="remove_showcase_id" /><input value="{{ _('Remove') }}" type="submit" class="btn btn-danger btn-small media-edit" title="{{ _('Remove dataset from this showcase') }}"/></form>
<form method="post">
{{ h.csrf_input() if 'csrf_input' in h }}
<input type="hidden" value="{{ package.id }}" name="remove_showcase_id" />
<input value="{{ _('Remove') }}" type="submit" class="btn btn-danger btn-sm media-edit" title="{{ _('Remove dataset from this showcase') }}"/>
</form>
{% endif %}
{% endblock %}
</li>
Expand Down