Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: django-oscar/django-oscar
...
head fork: django-oscar/django-oscar
  • 3 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
3  oscar/apps/basket/abstract_models.py
View
@@ -3,6 +3,7 @@
import datetime
from django.db import models
+from django.db.models import query
from django.utils.translation import ugettext as _
from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
@@ -64,7 +65,7 @@ def all_lines(self):
want to reload them from the DB.
"""
if self.id is None:
- return []
+ return query.EmptyQuerySet(model=self.__class__)
if self._lines is None:
self._lines = self.lines.all()
return self._lines
17 oscar/apps/catalogue/views.py
View
@@ -5,14 +5,14 @@
from oscar.apps.catalogue.signals import product_viewed, product_search
-product_model = get_model('catalogue', 'product')
+Product = get_model('catalogue', 'product')
ProductReview = get_model('reviews', 'ProductReview')
-category_model = get_model('catalogue', 'category')
+Category = get_model('catalogue', 'category')
class ProductDetailView(DetailView):
context_object_name = 'product'
- model = product_model
+ model = Product
view_signal = product_viewed
template_folder = "catalogue"
_product = None
@@ -62,11 +62,11 @@ def get_template_names(self):
def get_product_base_queryset():
"""
- Get ``QuerySet`` for product model with related
+ Return ``QuerySet`` for product model with related
content pre-loaded. The ``QuerySet`` returns unfiltered
results for further filtering.
"""
- return product_model.browsable.select_related(
+ return Product.browsable.select_related(
'product_class',
).prefetch_related(
'reviews',
@@ -74,7 +74,6 @@ def get_product_base_queryset():
'product_options',
'product_class__options',
'stockrecord',
- 'stockrecord__partner',
'images',
).all()
@@ -90,8 +89,8 @@ class ProductCategoryView(ListView):
def get_categories(self):
slug = self.kwargs['category_slug']
try:
- category = category_model.objects.get(slug=slug)
- except category_model.DoesNotExist:
+ category = Category.objects.get(slug=slug)
+ except Category.DoesNotExist:
raise Http404()
categories = list(category.get_descendants())
categories.append(category)
@@ -120,7 +119,7 @@ class ProductListView(ListView):
template_name = 'catalogue/browse.html'
paginate_by = 20
search_signal = product_search
- model = product_model
+ model = Product
def get_search_query(self):
q = self.request.GET.get('q', None)

No commit comments for this range

Something went wrong with that request. Please try again.