From e5d78099cf8865d98f16c1d6017e61b1fcb1cf13 Mon Sep 17 00:00:00 2001 From: Thomas Steen Rasmussen Date: Tue, 17 May 2016 20:56:11 +0200 Subject: [PATCH] move .public to category instead of product --- shop/models.py | 6 +----- shop/views.py | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/shop/models.py b/shop/models.py index 297344df..b47988a7 100644 --- a/shop/models.py +++ b/shop/models.py @@ -106,6 +106,7 @@ class ProductCategory(CreatedUpdatedModel, UUIDModel): name = models.CharField(max_length=150) slug = models.SlugField() + public = models.BooleanField(default=True) def __str__(self): return self.name @@ -142,11 +143,6 @@ class Product(CreatedUpdatedModel, UUIDModel): ) ) - public = models.BooleanField( - default=True, - help_text='Is this product publicly available in the webshop?' - ) - objects = ProductQuerySet.as_manager() def __str__(self): diff --git a/shop/views.py b/shop/views.py index f19ebad9..53f0916e 100644 --- a/shop/views.py +++ b/shop/views.py @@ -170,7 +170,7 @@ class ProductDetailView(LoginRequiredMixin, FormView, DetailView): context_object_name = 'product' def dispatch(self, request, *args, **kwargs): - if not self.get_object().public: + if not self.get_object().category.public: ### this product is not publicly available raise Http404("Product not found")