Skip to content
This repository
  • 3 commits
  • 2 files changed
  • 0 comments
  • 1 contributor
3  oscar/apps/basket/abstract_models.py
@@ -3,6 +3,7 @@
3 3
 import datetime
4 4
 
5 5
 from django.db import models
  6
+from django.db.models import query
6 7
 from django.utils.translation import ugettext as _
7 8
 from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
8 9
 
@@ -64,7 +65,7 @@ def all_lines(self):
64 65
         want to reload them from the DB.
65 66
         """
66 67
         if self.id is None:
67  
-            return []
  68
+            return query.EmptyQuerySet(model=self.__class__)
68 69
         if self._lines is None:
69 70
             self._lines = self.lines.all()
70 71
         return self._lines
17  oscar/apps/catalogue/views.py
@@ -5,14 +5,14 @@
5 5
 
6 6
 from oscar.apps.catalogue.signals import product_viewed, product_search
7 7
 
8  
-product_model = get_model('catalogue', 'product')
  8
+Product = get_model('catalogue', 'product')
9 9
 ProductReview = get_model('reviews', 'ProductReview')
10  
-category_model = get_model('catalogue', 'category')
  10
+Category = get_model('catalogue', 'category')
11 11
 
12 12
 
13 13
 class ProductDetailView(DetailView):
14 14
     context_object_name = 'product'
15  
-    model = product_model
  15
+    model = Product
16 16
     view_signal = product_viewed
17 17
     template_folder = "catalogue"
18 18
     _product = None
@@ -62,11 +62,11 @@ def get_template_names(self):
62 62
 
63 63
 def get_product_base_queryset():
64 64
     """
65  
-    Get ``QuerySet`` for product model with related 
  65
+    Return ``QuerySet`` for product model with related
66 66
     content pre-loaded. The ``QuerySet`` returns unfiltered
67 67
     results for further filtering.
68 68
     """
69  
-    return product_model.browsable.select_related(
  69
+    return Product.browsable.select_related(
70 70
         'product_class',
71 71
     ).prefetch_related(
72 72
         'reviews',
@@ -74,7 +74,6 @@ def get_product_base_queryset():
74 74
         'product_options',
75 75
         'product_class__options',
76 76
         'stockrecord',
77  
-        'stockrecord__partner',
78 77
         'images',
79 78
     ).all()
80 79
 
@@ -90,8 +89,8 @@ class ProductCategoryView(ListView):
90 89
     def get_categories(self):
91 90
         slug = self.kwargs['category_slug']
92 91
         try:
93  
-            category = category_model.objects.get(slug=slug)
94  
-        except category_model.DoesNotExist:
  92
+            category = Category.objects.get(slug=slug)
  93
+        except Category.DoesNotExist:
95 94
             raise Http404()
96 95
         categories = list(category.get_descendants())
97 96
         categories.append(category)
@@ -120,7 +119,7 @@ class ProductListView(ListView):
120 119
     template_name = 'catalogue/browse.html'
121 120
     paginate_by = 20
122 121
     search_signal = product_search
123  
-    model = product_model
  122
+    model = Product
124 123
 
125 124
     def get_search_query(self):
126 125
         q = self.request.GET.get('q', None)

No commit comments for this range

Something went wrong with that request. Please try again.