本文整理汇总了Python中taiga.base.utils.slug.slugify_uniquely函数的典型用法代码示例。如果您正苦于以下问题:Python slugify_uniquely函数的具体用法?Python slugify_uniquely怎么用?Python slugify_uniquely使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了slugify_uniquely函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save
def save(self, *args, **kwargs):
if not self.slug:
self.slug = slugify_uniquely(self.name, self.__class__)
if not self.videoconferences:
self.videoconferences_salt = None
super().save(*args, **kwargs)
示例2: save
def save(self, *args, **kwargs):
if not self._importing or not self.modified_date:
self.modified_date = timezone.now()
if not self.is_backlog_activated:
self.total_milestones = None
self.total_story_points = None
if not self.videoconferences:
self.videoconferences_extra_data = None
if not self.is_looking_for_people:
self.looking_for_people_note = ""
if self.anon_permissions is None:
self.anon_permissions = []
if self.public_permissions is None:
self.public_permissions = []
if not self.slug:
with advisory_lock("project-creation"):
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)
示例3: save
def save(self, *args, **kwargs):
if not self._importing or not self.modified_date:
self.modified_date = timezone.now()
if not self.slug:
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
if not self.is_backlog_activated:
self.total_milestones = None
self.total_story_points = None
if not self.videoconferences:
self.videoconferences_extra_data = None
if not self.is_looking_for_people:
self.looking_for_people_note = ""
if self.anon_permissions == None:
self.anon_permissions = []
if self.public_permissions == None:
self.public_permissions = []
super().save(*args, **kwargs)
示例4: create_template
def create_template(self, request, **kwargs):
template_name = request.DATA.get('template_name', None)
template_description = request.DATA.get('template_description', None)
if not template_name:
raise response.BadRequest(_("Not valid template name"))
if not template_description:
raise response.BadRequest(_("Not valid template description"))
template_slug = slugify_uniquely(template_name, models.ProjectTemplate)
project = self.get_object()
self.check_permissions(request, 'create_template', project)
template = models.ProjectTemplate(
name=template_name,
slug=template_slug,
description=template_description,
)
template.load_data_from_project(project)
template.save()
return response.Created(serializers.ProjectTemplateSerializer(template).data)
示例5: handle
def handle(self, *args, **options):
current_slug = options["current_slug"]
new_slug = options["new_slug"]
try:
project = Project.objects.get(slug=current_slug)
except Project.DoesNotExist:
raise CommandError("There is no project with the slug '{}'".format(current_slug))
slug = slugify_uniquely(new_slug, Project)
if slug != new_slug:
raise CommandError("Invalid new slug, maybe you can try with '{}'".format(slug))
# Change slug
self.stdout.write(self.style.SUCCESS("-> Change slug to '{}'.".format(slug)))
project.slug = slug
project.save()
# Reset diff cache in history entries
self.stdout.write(self.style.SUCCESS("-> Reset value_diff cache for history entries."))
HistoryEntry.objects.filter(project=project).update(values_diff_cache=None)
# Regenerate timeline
self.stdout.write(self.style.SUCCESS("-> Regenerate timeline entries."))
rebuild_timeline(None, None, project.id)
示例6: gitlab_register
def gitlab_register(username:str, email:str, full_name:str, gitlab_id:int, bio:str):
"""
Register a new user from gitlab.
This can raise `exc.IntegrityError` exceptions in
case of conflics found.
:returns: User
"""
auth_data_model = apps.get_model("users", "AuthData")
user_model = apps.get_model("users", "User")
try:
# Gitlab user association exist?
auth_data = auth_data_model.objects.get(key="gitlab", value=gitlab_id)
user = auth_data.user
except auth_data_model.DoesNotExist:
try:
# Is a user with the same email as the gitlab user?
user = user_model.objects.get(email=email)
auth_data_model.objects.create(user=user, key="gitlab", value=gitlab_id, extra={})
except user_model.DoesNotExist:
# Create a new user
username_unique = slugify_uniquely(username, user_model, slugfield="username")
user = user_model.objects.create(email=email,
username=username_unique,
full_name=full_name,
bio=bio)
auth_data_model.objects.create(user=user, key="gitlab", value=gitlab_id, extra={})
send_register_email(user)
user_registered_signal.send(sender=user.__class__, user=user)
return user
示例7: save
def save(self, *args, **kwargs):
if not self._importing or not self.modified_date:
self.modified_date = timezone.now()
if not self.slug:
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
if not self.videoconferences:
self.videoconferences_salt = None
# binh comments
#if self.pk is None:
# self.is_backlog_activated = True
# self.is_kanban_activated = True
# self.is_wiki_activated = True
super().save(*args, **kwargs)
示例8: save
def save(self, *args, **kwargs):
if not self._importing or not self.modified_date:
self.modified_date = timezone.now()
if not self.slug:
self.slug = slugify_uniquely(self.name, self.__class__)
super().save(*args, **kwargs)
示例9: save
def save(self, *args, **kwargs):
if not self._importing or not self.modified_date:
self.modified_date = timezone.now()
if not self.slug:
with advisory_lock("milestone-creation-{}".format(self.project_id)):
self.slug = slugify_uniquely(self.name, self.__class__)
super().save(*args, **kwargs)
else:
super().save(*args, **kwargs)
示例10: cancel
def cancel(self):
self.username = slugify_uniquely("deleted-user", User, slugfield="username")
self.email = "{}@taiga.io".format(self.username)
self.is_active = False
self.full_name = "Deleted user"
self.color = ""
self.bio = ""
self.default_language = ""
self.default_timezone = ""
self.colorize_tags = True
self.token = None
self.github_id = None
self.set_unusable_password()
self.save()
示例11: cancel
def cancel(self):
self.username = slugify_uniquely("deleted-user", User, slugfield="username")
self.email = "{}@taiga.io".format(self.username)
self.is_active = False
self.full_name = "Deleted user"
self.color = ""
self.bio = ""
self.lang = ""
self.theme = ""
self.timezone = ""
self.colorize_tags = True
self.token = None
self.set_unusable_password()
self.delete_photo()
self.save()
self.auth_data.all().delete()
示例12: save
def save(self, *args, **kwargs):
if not self._importing or not self.modified_date:
self.modified_date = timezone.now()
if not self.slug:
base_slug = slugify_uniquely(self.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
if not self.videoconferences:
self.videoconferences_salt = None
super().save(*args, **kwargs)
示例13: destroy
def destroy(self, request, pk=None):
user = self.get_object()
self.check_permissions(request, "destroy", user)
user.username = slugify_uniquely("deleted-user", models.User, slugfield="username")
user.email = "{}@taiga.io".format(user.username)
user.is_active = False
user.full_name = "Deleted user"
user.color = ""
user.bio = ""
user.default_language = ""
user.default_timezone = ""
user.colorize_tags = True
user.token = None
user.github_id = None
user.set_unusable_password()
user.save()
return Response(status=status.HTTP_204_NO_CONTENT)
示例14: cancel
def cancel(self):
self.username = slugify_uniquely("deleted-user", User, slugfield="username")
self.email = "{}@taiga.io".format(self.username)
self.is_active = False
self.full_name = "Deleted user"
self.color = ""
self.bio = ""
self.lang = ""
self.theme = ""
self.timezone = ""
self.colorize_tags = True
self.token = None
self.set_unusable_password()
self.photo = None
self.save()
self.auth_data.all().delete()
#Blocking all owned users
self.owned_projects.update(blocked_code=BLOCKED_BY_OWNER_LEAVING)
示例15: slack_register
def slack_register(username:str, email:str, full_name:str, slack_id:int, bio:str, token:str=None):
"""
Register a new user from slack.
This can raise `exc.IntegrityError` exceptions in
case of conflics found.
:returns: User
"""
auth_data_model = apps.get_model("users", "AuthData")
user_model = apps.get_model("users", "User")
try:
# slack user association exist?
auth_data = auth_data_model.objects.get(key="slack", value=slack_id)
user = auth_data.user
except auth_data_model.DoesNotExist:
try:
# Is a user with the same email as the slack user?
user = user_model.objects.get(email=email)
auth_data_model.objects.create(user=user, key="slack", value=slack_id, extra={})
except user_model.DoesNotExist:
# Create a new user
username_unique = slugify_uniquely(username, user_model, slugfield="username")
user = user_model.objects.create(email=email,
username=username_unique,
full_name=full_name,
bio=bio)
auth_data_model.objects.create(user=user, key="slack", value=slack_id, extra={})
send_register_email(user)
user_registered_signal.send(sender=user.__class__, user=user)
if token:
membership = get_membership_by_token(token)
try:
membership.user = user
membership.save(update_fields=["user"])
except IntegrityError:
raise exc.IntegrityError(_("This user is already a member of the project."))
return user