Skip to content

Commit

Permalink
Drop support for Python 2
Browse files Browse the repository at this point in the history
  • Loading branch information
jrief committed Apr 27, 2020
1 parent a174f69 commit 20c611c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
3 changes: 2 additions & 1 deletion shop/transition.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
17 changes: 5 additions & 12 deletions shop/views/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
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
from django.http.request import QueryDict
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
Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -94,12 +92,12 @@ class ProductListView(generics.ListAPIView):
```
urlpatterns = [
url(r'^$', ProductListView.as_view()),
url(r'^(?P<slug>[\w-]+)/?$', ProductRetrieveView.as_view()), # see below
url(r'^(?P<slug>[\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.
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 20c611c

Please sign in to comment.