Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Enforce the POST method on VAT rates fetching

NyanKiyoshi232f5ecb0019
diff --git a/saleor/dashboard/taxes/views.py b/saleor/dashboard/taxes/views.py
index 31e52987b7..9eef38f8bc 100644
--- a/saleor/dashboard/taxes/views.py
+++ b/saleor/dashboard/taxes/views.py
@@ -8,6 +8,7 @@ from django.core.management import call_command
from django.shortcuts import get_object_or_404, redirect
from django.template.response import TemplateResponse
from django.utils.translation import pgettext_lazy
+from django.views.decorators.http import require_POST
from django_countries.fields import Country
from django_prices_vatlayer.models import VAT
@@ -61,6 +62,7 @@ def configure_taxes(request):
@staff_member_required
+@require_POST
@permission_required('site.manage_settings')
def fetch_tax_rates(request):
try:
diff --git a/templates/dashboard/taxes/list.html b/templates/dashboard/taxes/list.html
index f539c3aef4..70e7bda19e 100644
--- a/templates/dashboard/taxes/list.html
+++ b/templates/dashboard/taxes/list.html
@@ -121,9 +121,12 @@
<a class="btn-flat waves-effect" href="{% url 'dashboard:configure-taxes' %}">
{% trans "Configure taxes" context "Site settings configure taxes action" %}
</a>
- <a class="btn-flat waves-effect load-action" href="{% url 'dashboard:fetch-tax-rates' %}">
- {% trans "Fetch tax rates" context "Site settings fetch tax rates action" %}
- </a>
+ <form method="POST" action="{% url 'dashboard:fetch-tax-rates' %}" style="display: inline">
+ <button type="submit" class="btn-flat waves-effect">
+ {% csrf_token %}
+ {% trans "Fetch tax rates" context "Site settings fetch tax rates action" %}
+ </button>
+ </form>
</div>
</div>
</div>