diff --git a/taiga/base/api/permissions.py b/taiga/base/api/permissions.py index b03d6c18..ec994b0b 100644 --- a/taiga/base/api/permissions.py +++ b/taiga/base/api/permissions.py @@ -20,7 +20,6 @@ import abc from functools import reduce -from taiga.base.utils import sequence as sq from taiga.permissions.services import user_has_perm, is_project_admin from django.apps import apps @@ -112,7 +111,7 @@ class Not(PermissionOperator): super().__init__(component) def check_permissions(self, *args, **kwargs): - component = sq.first(self.components) + component = self.components[0] return (not component.check_permissions(*args, **kwargs)) diff --git a/taiga/base/utils/sequence.py b/taiga/base/utils/sequence.py deleted file mode 100644 index 4e0c3e24..00000000 --- a/taiga/base/utils/sequence.py +++ /dev/null @@ -1,34 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2014-2016 Andrey Antukh -# Copyright (C) 2014-2016 Jesús Espino -# Copyright (C) 2014-2016 David Barragán -# Copyright (C) 2014-2016 Alejandro Alonso -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - - -def first(iterable): - if len(iterable) == 0: - return None - return iterable[0] - - -def next(data:list): - return data[1:] - - -def arithmetic_progression(step=1, start=1): - i = start - while True: - yield i - i += step diff --git a/taiga/projects/models.py b/taiga/projects/models.py index f6f6cc52..c23fcc4b 100644 --- a/taiga/projects/models.py +++ b/taiga/projects/models.py @@ -35,7 +35,6 @@ from taiga.base.utils.time import timestamp_ms from taiga.projects.tagging.models import TaggedMixin from taiga.projects.tagging.models import TagsColorsdMixin from taiga.base.utils.files import get_file_path -from taiga.base.utils.sequence import arithmetic_progression from taiga.base.utils.slug import slugify_uniquely from taiga.base.utils.slug import slugify_uniquely_for_queryset @@ -287,14 +286,8 @@ class Project(ProjectDefaults, TaggedMixin, TagsColorsdMixin, models.Model): if not self.slug: with advisory_lock("project-creation"): - base_name = "{}-{}".format(self.owner.username, self.name) - base_slug = slugify_uniquely(base_name, self.__class__) - slug = base_slug - for i in arithmetic_progression(): - if not type(self).objects.filter(slug=slug).exists() or i > 100: - break - slug = "{}-{}".format(base_slug, i) - self.slug = slug + base_slug = "{}-{}".format(self.owner.username, self.name) + self.slug = slugify_uniquely(base_slug, self.__class__) super().save(*args, **kwargs) else: super().save(*args, **kwargs)