本文整理汇总了Python中taiga.base.utils.slug.slugify_uniquely函数的典型用法代码示例。如果您正苦于以下问题:Python slugify_uniquely函数的具体用法?Python slugify_uniquely怎么用?Python slugify_uniquely使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了slugify_uniquely函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:yamila-moreno,项目名称:taiga-back,代码行数:7,代码来源:models.py
示例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)
开发者ID:rubixware,项目名称:taiga-back,代码行数:27,代码来源:models.py
示例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)
开发者ID:CrypticGator,项目名称:taiga-back,代码行数:31,代码来源:models.py
示例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)
开发者ID:bootinge,项目名称:taiga-back,代码行数:25,代码来源:api.py
示例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)
开发者ID:shreeshreee,项目名称:taiga-back,代码行数:25,代码来源:change_project_slug.py
示例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
开发者ID:WedjaaOpen,项目名称:taiga-contrib-gitlab-auth,代码行数:34,代码来源:services.py
示例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)
开发者ID:bdang2012,项目名称:taiga-back,代码行数:27,代码来源:models.py
示例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)
开发者ID:CrypticGator,项目名称:taiga-back,代码行数:7,代码来源:models.py
示例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)
开发者ID:0-T-0,项目名称:taiga-back,代码行数:9,代码来源:models.py
示例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()
开发者ID:BWStearns,项目名称:taiga-back,代码行数:14,代码来源:models.py
示例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()
开发者ID:spetpet,项目名称:taiga-back,代码行数:16,代码来源:models.py
示例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)
开发者ID:6ft,项目名称:taiga-back,代码行数:17,代码来源:models.py
示例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)
开发者ID:6ft,项目名称:taiga-back,代码行数:17,代码来源:api.py
示例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)
开发者ID:adebayo-dealdey,项目名称:taiga-back,代码行数:19,代码来源:models.py
示例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
开发者ID:sjaakiejj,项目名称:taiga-contrib-slack-auth,代码行数:43,代码来源:services.py
示例16: 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_extra_data = None
if not self.is_looking_for_people:
self.looking_for_people_note = ""
super().save(*args, **kwargs)
开发者ID:bclermont,项目名称:taiga-back,代码行数:21,代码来源:models.py
示例17: github_register
def github_register(username:str, email:str, full_name:str, github_id:int, bio:str, token:str=None):
"""
Register a new user from github.
This can raise `exc.IntegrityError` exceptions in
case of conflics found.
:returns: User
"""
user_model = apps.get_model("users", "User")
try:
# Github user association exist?
user = user_model.objects.get(github_id=github_id)
except user_model.DoesNotExist:
try:
# Is a user with the same email as the github user?
user = user_model.objects.get(email=email)
user.github_id = github_id
user.save(update_fields=["github_id"])
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,
github_id=github_id,
full_name=full_name,
bio=bio)
send_register_email(user)
user_registered_signal.send(sender=user.__class__, user=user)
if token:
membership = get_membership_by_token(token)
membership.user = user
membership.save(update_fields=["user"])
return user
开发者ID:FlorianBezagu,项目名称:taiga-back,代码行数:38,代码来源:services.py
示例18: ldap_register
def ldap_register(username: str, email: str, full_name: str):
"""
Register a new user from LDAP.
This can raise `exc.IntegrityError` exceptions in
case of conflict found.
:returns: User
"""
user_model = apps.get_model("users", "User")
try:
# LDAP user association exist?
user = user_model.objects.get(username=username)
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)
user_registered_signal.send(sender=user.__class__, user=user)
return user
开发者ID:artlepool,项目名称:taiga-contrib-ldap-auth,代码行数:23,代码来源:services.py
示例19: cancel
def cancel(self):
with advisory_lock("delete-user"):
deleted_user_prefix = "deleted-user-{}".format(timestamp_ms())
self.username = slugify_uniquely(deleted_user_prefix, 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 projects
self.owned_projects.update(blocked_code=BLOCKED_BY_OWNER_LEAVING)
# Remove all memberships
self.memberships.all().delete()
开发者ID:taigaio,项目名称:taiga-back,代码行数:24,代码来源:models.py
示例20: create_from_project
def create_from_project(self, request, **kwargs):
project_id = request.DATA.get('project_id', None)
template_name = request.DATA.get('template_name', None)
template_description = request.DATA.get('template_description', None)
if not template_name:
raise ParseError("Not valid template name")
template_slug = slugify_uniquely(template_name, models.ProjectTemplate)
try:
project = models.Project.objects.get(pk=project_id)
except models.Project.DoesNotExist:
raise ParseError("Not valid project_id")
template = models.ProjectTemplate(
name=template_name,
slug=template_slug,
description=template_description,
)
template.load_data_from_project(project)
template.save()
return Response(self.serializer_class(template).data, status=201)
开发者ID:yamila-moreno,项目名称:taiga-back,代码行数:24,代码来源:api.py
注:本文中的taiga.base.utils.slug.slugify_uniquely函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论