Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Move check for unpublish restrictions to view
oldPadavanf1c81766ef8d
diff --git a/saleor/dashboard/collection/views.py b/saleor/dashboard/collection/views.pyindex 1ea0a926bc..20b22db240 100644--- a/saleor/dashboard/collection/views.py+++ b/saleor/dashboard/collection/views.py@@ -67,7 +67,12 @@ def collection_update(request, pk=None):msg = pgettext_lazy('Collection message', 'Updated collection')messages.success(request, msg)return redirect('dashboard:collection-update', pk=collection.pk)- ctx = {'collection': collection, 'form': form}+ is_unpublish_restricted = (+ collection == request.site.settings.homepage_collection and+ collection.is_published)+ ctx = {+ 'collection': collection, 'form': form,+ 'is_unpublish_restricted': is_unpublish_restricted}return TemplateResponse(request, 'dashboard/collection/detail.html', ctx)diff --git a/templates/dashboard/collection/detail.html b/templates/dashboard/collection/detail.htmlindex 025651bc18..752ba12eba 100644--- a/templates/dashboard/collection/detail.html+++ b/templates/dashboard/collection/detail.html@@ -90,7 +90,7 @@<div class="switch" id="collection-is-published"><label><input id="toggle-publish-switch" type="checkbox" {% if collection.is_published %} checked {% endif %}- {% if site.settings.homepage_collection == collection and collection.is_published %} disabled {% endif %} >+ {% if is_unpublish_restricted %} disabled {% endif %} ><span class="lever"></span><span class="label">{% if collection.is_published %}@@ -103,7 +103,7 @@</div>{% csrf_token %}</form>- {% if site.settings.homepage_collection == collection and collection.is_published %}+ {% if is_unpublish_restricted %}<div class="label label-default">{% trans "Can't unpublish homepage collection" context "Collection field" %}</div>{% endif %}<h5>{% render_collection_availability collection %}</h5>