From dd55ab62f9fba128c66e7418bc280a0d1a0d346d Mon Sep 17 00:00:00 2001 From: duker Date: Fri, 7 Sep 2018 08:22:18 +0300 Subject: [PATCH] #550 Merge fixes --- shopelectro/models.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/shopelectro/models.py b/shopelectro/models.py index 2cb05e2f..4c43ee8c 100644 --- a/shopelectro/models.py +++ b/shopelectro/models.py @@ -1,11 +1,17 @@ -from typing import Optional +import random +import string +from itertools import chain, groupby +from operator import attrgetter +import typing from uuid import uuid4 from django.conf import settings from django.db import models from django.urls import reverse +from django.utils.text import slugify from django.utils.translation import ugettext_lazy as _ from mptt.querysets import TreeQuerySet +from unidecode import unidecode from catalog.models import ( AbstractCategory, @@ -19,6 +25,13 @@ from pages.models import CustomPage, ModelPage, Page, SyncPageMixin, PageManager +def randomize_slug(slug: str) -> str: + slug_hash = ''.join( + random.choices(string.ascii_lowercase, k=settings.SLUG_HASH_SIZE) + ) + return f'{slug}_{slug_hash}' + + class SECategoryQuerySet(TreeQuerySet): def get_categories_tree_with_pictures(self) -> 'SECategoryQuerySet': categories_with_pictures = (