Skip to content

Commit

Permalink
drop support form django-CMS < 3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
jrief committed May 4, 2020
1 parent 00ee6d7 commit ba76821
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions shop/models/product.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from distutils.version import LooseVersion
from functools import reduce
import operator
from urllib.parse import urljoin

from cms import __version__ as CMS_VERSION

from django.apps import apps
from django.conf import settings
from django.core import cache, checks
Expand Down Expand Up @@ -272,7 +269,7 @@ def get_product_variant(self, **kwargs):
def get_product_variants(self):
"""
Hook for returning a queryset of variants for the given product.
If the product has no variants, then the queryset contains just that product.
If the product has no variants, then the queryset contains just itself.
"""
return self._meta.model.objects.filter(pk=self.pk)

Expand Down Expand Up @@ -352,7 +349,7 @@ def check(cls, **kwargs):

def update_search_index(self):
"""
Update the document model inside the Elasticsearch index after changing relevant parts
Update the Document inside the Elasticsearch index after changing relevant parts
of the product.
"""
documents = elasticsearch_registry.get_documents([ProductModel])
Expand Down Expand Up @@ -393,10 +390,7 @@ def get_absolute_url(self):
"""
# sorting by highest level, so that the canonical URL
# associates with the most generic category
if LooseVersion(CMS_VERSION) < LooseVersion('3.5'):
cms_page = self.cms_pages.order_by('depth').last()
else:
cms_page = self.cms_pages.order_by('node__path').last()
cms_page = self.cms_pages.order_by('node__path').last()
if cms_page is None:
return urljoin('/category-not-assigned/', self.slug)
return urljoin(cms_page.get_absolute_url(), self.slug)

0 comments on commit ba76821

Please sign in to comment.