Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Delete stock location view
Mira Szewczyk3e2c72c93467
diff --git a/saleor/dashboard/product/urls.py b/saleor/dashboard/product/urls.pyindex 9ecd22cac6..2555f26eca 100644--- a/saleor/dashboard/product/urls.py+++ b/saleor/dashboard/product/urls.py@@ -58,4 +58,6 @@ urlpatterns = [name='product-stock-location-add'),url(r'stocklocations/(?P<location_pk>[0-9]+)/$', views.stock_location_edit,name='product-stock-location-edit'),+ url(r'stocklocations/((?P<location_pk>[0-9]+))/delete/$',+ views.stock_location_delete, name='product-stock-location-delete'),]diff --git a/saleor/dashboard/product/views.py b/saleor/dashboard/product/views.pyindex b8e13dfcdb..c47433e93b 100644--- a/saleor/dashboard/product/views.py+++ b/saleor/dashboard/product/views.py@@ -299,3 +299,17 @@ def stock_location_edit(request, location_pk=None):ctx = {'form': form, 'location': location}return TemplateResponse(request, 'dashboard/product/stock_locations/form.html', ctx)+++@staff_member_required+def stock_location_delete(request, location_pk):+ location = get_object_or_404(StockLocation, pk=location_pk)+ if request.method == 'POST':+ location.delete()+ messages.success(+ request, _('Deleted location %s') % location)+ return redirect('dashboard:product-stock-location-list')+ ctx = {'location': location}+ return TemplateResponse(+ request, 'dashboard/product/stock_locations/modal_confirm_delete.html',+ ctx)diff --git a/templates/dashboard/product/stock_locations/form.html b/templates/dashboard/product/stock_locations/form.htmlindex 6a26c06f2e..b82f75cc16 100644--- a/templates/dashboard/product/stock_locations/form.html+++ b/templates/dashboard/product/stock_locations/form.html@@ -16,8 +16,8 @@<ul id="attribute-delete" class="dropdown-content"><li><a class="modal-trigger-custom" href="#base-modal"- data-href="{% url 'dashboard:product-attribute-delete' pk=location.pk %}">- {% trans "Remove stock location" %}+ data-href="{% url 'dashboard:product-stock-location-delete' location.pk %}">+ {% trans "Remove attribute" %}</a></li></ul>diff --git a/templates/dashboard/product/stock_locations/modal_confirm_delete.html b/templates/dashboard/product/stock_locations/modal_confirm_delete.htmlnew file mode 100644index 0000000000..435f7cd4e7--- /dev/null+++ b/templates/dashboard/product/stock_locations/modal_confirm_delete.html@@ -0,0 +1,17 @@+{% load i18n %}++<form action="{% url 'dashboard:product-stock-location-delete' location.pk %}" method="post" novalidate>+ {% csrf_token %}+ <div class="modal-content">+ <h5>{% trans "Are you sure?" %}</h5>++ <p>+ {% blocktrans %}You are about to delete a stock location <strong>{{ location }}</strong>.{% endblocktrans %}+ </p>+ </div>++ <div class="modal-footer">+ <button type="submit" class="modal-action btn-flat blue-text">{% trans "Delete" %}</button>+ <a href="#!" class="modal-action modal-close btn-flat blue-text">{% trans "Cancel" %}</a>+ </div>+</form>