diff --git a/shop/transition.py b/shop/transition.py index e52757f07..7d11d89ff 100644 --- a/shop/transition.py +++ b/shop/transition.py @@ -1,10 +1,11 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals +from urllib.parse import urlparse + from django.contrib.auth.models import AnonymousUser from django.db import models from django.http.request import HttpRequest -from django.utils.six.moves.urllib.parse import urlparse from post_office import mail from post_office.models import EmailTemplate from shop.conf import app_settings diff --git a/shop/views/catalog.py b/shop/views/catalog.py index 939fc611b..d229fe2b8 100644 --- a/shop/views/catalog.py +++ b/shop/views/catalog.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals import os -from distutils.version import LooseVersion +from urllib.parse import urlsplit from django.db import models from django.http.response import Http404, HttpResponseRedirect @@ -10,7 +10,6 @@ from django.shortcuts import get_object_or_404 from django.utils.cache import add_never_cache_headers from django.utils.encoding import force_str -from django.utils.six.moves.urllib import parse as urlparse from django.utils.translation import get_language_from_request from rest_framework import generics @@ -21,7 +20,6 @@ from rest_framework.response import Response from rest_framework.utils.urls import replace_query_param -from cms import __version__ as CMS_VERSION from cms.views import details from shop.conf import app_settings @@ -57,7 +55,7 @@ class ProductListPagination(pagination.LimitOffsetPagination): def adjust_offset(self, url, page_offset): if url is None: return - (scheme, netloc, path, query, fragment) = urlparse.urlsplit(force_str(url)) + (scheme, netloc, path, query, fragment) = urlsplit(force_str(url)) query_dict = QueryDict(query) try: offset = pagination._positive_int( @@ -94,12 +92,12 @@ class ProductListView(generics.ListAPIView): ``` urlpatterns = [ url(r'^$', ProductListView.as_view()), - url(r'^(?P[\w-]+)/?$', ProductRetrieveView.as_view()), # see below + url(r'^(?P[\w-]+)/?$', ProductRetrieveView.as_view(**params)), # see below ... ] ``` - You may add these attributes to the ``as_view()`` method: + These attributes can be added to the ``as_view(**params)`` method: :param renderer_classes: A list or tuple of REST renderer classes. @@ -117,7 +115,6 @@ class ProductListView(generics.ListAPIView): :param redirect_to_lonely_product: If ``True``, redirect onto a lonely product in the catalog. Defaults to ``False``. """ - renderer_classes = (CMSPageRenderer, JSONRenderer, BrowsableAPIRenderer) product_model = ProductModel serializer_class = app_settings.PRODUCT_SUMMARY_SERIALIZER @@ -285,11 +282,7 @@ def dispatch(self, request, *args, **kwargs): try: return super(ProductRetrieveView, self).dispatch(request, *args, **kwargs) except Http404: - if LooseVersion(CMS_VERSION) < LooseVersion('3.5'): - is_root = request.current_page.is_root() - else: - is_root = request.current_page.node.is_root() - if is_root: + if request.current_page.node.is_root(): return details(request, kwargs.get('slug')) raise except: