From 39c698bdf1ec58de2bc5a2e29c1c8fa94058d6b3 Mon Sep 17 00:00:00 2001 From: Alissa Date: Wed, 30 Aug 2023 15:53:43 -0400 Subject: [PATCH] Edit views so any user who adds artwork to shop can edit or delete the product --- hugo/templates/hugo.html | 3 +- shop/templates/shop/includes/shop-nav.html | 35 ---------------------- shop/templates/shop/shop.html | 8 ----- shop/views.py | 8 ----- templates/includes/shop-nav.html | 3 +- 5 files changed, 3 insertions(+), 54 deletions(-) delete mode 100644 shop/templates/shop/includes/shop-nav.html diff --git a/hugo/templates/hugo.html b/hugo/templates/hugo.html index c9b4f4e4..a776a1cf 100644 --- a/hugo/templates/hugo.html +++ b/hugo/templates/hugo.html @@ -14,8 +14,7 @@ {% endblock %} {% block content %}
-
- +
@@ -107,13 +106,6 @@

{% endif %} - {% if product.style %} -

- - {{ product.style.friendly_name }} - -

- {% endif %} {% if request.user == product.user %}
diff --git a/shop/views.py b/shop/views.py index 1e5da46f..1a873f46 100644 --- a/shop/views.py +++ b/shop/views.py @@ -184,10 +184,6 @@ def add_product(request): @login_required def edit_product(request, product_id): """ A view so shop manager can edit existing products """ - if not request.user.is_superuser: - messages.error(request, 'Sorry, only store owners can do that.') - return redirect(reverse('home')) - product = get_object_or_404(Product, pk=product_id) if request.method == 'POST': form = EditProductForm(request.POST, request.FILES, instance=product) @@ -215,10 +211,6 @@ def edit_product(request, product_id): @login_required def delete_product(request, product_id): """ A view so shop manager can delete existing products """ - if not request.user.is_superuser: - messages.error(request, 'Sorry, only store owners can do that.') - return redirect(reverse('home')) - product = get_object_or_404(Product, pk=product_id) product.delete() messages.success(request, 'Product deleted!') diff --git a/templates/includes/shop-nav.html b/templates/includes/shop-nav.html index 4892cf2b..8946e038 100644 --- a/templates/includes/shop-nav.html +++ b/templates/includes/shop-nav.html @@ -7,7 +7,8 @@ Digital Art
  • - Pop Art + Pop Art