当前位置: 首页>>代码示例>>Python>>正文


Python utils.slugify_instance函数代码示例

本文整理汇总了Python中sentry.db.models.utils.slugify_instance函数的典型用法代码示例。如果您正苦于以下问题:Python slugify_instance函数的具体用法?Python slugify_instance怎么用?Python slugify_instance使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了slugify_instance函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: transfer_to

    def transfer_to(self, team):
        from sentry.models import ReleaseProject

        organization = team.organization

        # We only need to delete ReleaseProjects when moving to a different
        # Organization. Releases are bound to Organization, so it's not realistic
        # to keep this link unless we say, copied all Releases as well.
        if self.organization_id != organization.id:
            ReleaseProject.objects.filter(
                project_id=self.id,
            ).delete()

        self.organization = organization
        self.team = team

        try:
            with transaction.atomic():
                self.update(
                    organization=organization,
                    team=team,
                )
        except IntegrityError:
            slugify_instance(self, self.name, organization=organization)
            self.update(
                slug=self.slug,
                organization=organization,
                team=team,
            )
开发者ID:alshopov,项目名称:sentry,代码行数:29,代码来源:project.py

示例2: save

 def save(self, *args, **kwargs):
     if not self.slug:
         lock_key = 'slug:team'
         with Lock(lock_key):
             slugify_instance(self, self.name, organization=self.organization)
         super(Team, self).save(*args, **kwargs)
     else:
         super(Team, self).save(*args, **kwargs)
开发者ID:haojiang1,项目名称:sentry,代码行数:8,代码来源:team.py

示例3: save

 def save(self, *args, **kwargs):
     if not self.slug:
         lock_key = "slug:organization"
         with Lock(lock_key):
             slugify_instance(self, self.name, reserved=RESERVED_ORGANIZATION_SLUGS)
         super(Organization, self).save(*args, **kwargs)
     else:
         super(Organization, self).save(*args, **kwargs)
开发者ID:wuzhentang,项目名称:sentry,代码行数:8,代码来源:organization.py

示例4: save

 def save(self, *args, **kwargs):
     if not self.slug:
         lock_key = "slug:project"
         with Lock(lock_key):
             slugify_instance(self, self.name, organization=self.organization)
         super(Project, self).save(*args, **kwargs)
     else:
         super(Project, self).save(*args, **kwargs)
开发者ID:Batterfii,项目名称:sentry,代码行数:8,代码来源:project.py

示例5: save

 def save(self, *args, **kwargs):
     if not self.slug:
         lock = locks.get('slug:organization', duration=5)
         with TimedRetryPolicy(10)(lock.acquire):
             slugify_instance(self, self.name, reserved=RESERVED_ORGANIZATION_SLUGS)
         super(Organization, self).save(*args, **kwargs)
     else:
         super(Organization, self).save(*args, **kwargs)
开发者ID:NuttasitBoonwat,项目名称:sentry,代码行数:8,代码来源:organization.py

示例6: save

 def save(self, *args, **kwargs):
     if not self.slug:
         lock = locks.get('slug:project', duration=5)
         with TimedRetryPolicy(10)(lock.acquire):
             slugify_instance(self, self.name, organization=self.organization)
         super(Project, self).save(*args, **kwargs)
     else:
         super(Project, self).save(*args, **kwargs)
开发者ID:ForkRepo,项目名称:sentry,代码行数:8,代码来源:project.py

示例7: merge_to

    def merge_to(from_org, to_org):
        from sentry.models import (
            ApiKey, AuditLogEntry, OrganizationMember, OrganizationMemberTeam,
            Project, Team
        )

        for from_member in OrganizationMember.objects.filter(organization=from_org):
            try:
                to_member = OrganizationMember.objects.get(
                    organization=to_org,
                    user=from_member.user,
                )
            except OrganizationMember.DoesNotExist:
                from_member.update(organization=to_org)
                to_member = from_member
            else:
                qs = OrganizationMemberTeam.objects.filter(
                    organizationmember=from_member,
                    is_active=True,
                ).select_related()
                for omt in qs:
                    OrganizationMemberTeam.objects.create_or_update(
                        organizationmember=to_member,
                        team=omt.team,
                        defaults={
                            'is_active': True,
                        },
                    )

        for team in Team.objects.filter(organization=from_org):
            try:
                with transaction.atomic():
                    team.update(organization=to_org)
            except IntegrityError:
                slugify_instance(team, team.name, organization=to_org)
                team.update(
                    organization=to_org,
                    slug=team.slug,
                )

        for project in Project.objects.filter(organization=from_org):
            try:
                with transaction.atomic():
                    project.update(organization=to_org)
            except IntegrityError:
                slugify_instance(project, project.name, organization=to_org)
                project.update(
                    organization=to_org,
                    slug=project.slug,
                )

        for model in (ApiKey, AuditLogEntry):
            model.objects.filter(
                organization=from_org,
            ).update(organization=to_org)
开发者ID:280185386,项目名称:sentry,代码行数:55,代码来源:organization.py

示例8: forwards

    def forwards(self, orm):
        from sentry.constants import RESERVED_ORGANIZATION_SLUGS
        from sentry.db.models.utils import slugify_instance
        from sentry.utils.query import RangeQuerySetWrapperWithProgressBar

        Organization = orm['sentry.Organization']

        queryset = Organization.objects.filter(slug__isnull=True)

        for org in RangeQuerySetWrapperWithProgressBar(queryset):
            slugify_instance(org, org.name, RESERVED_ORGANIZATION_SLUGS)
            org.save()
            transaction.commit()
开发者ID:Kayle009,项目名称:sentry,代码行数:13,代码来源:0141_fill_org_slugs.py

示例9: save

 def save(self, *args, **kwargs):
     if not self.slug:
         lock = locks.get('slug:project', duration=5)
         with TimedRetryPolicy(10)(lock.acquire):
             slugify_instance(
                 self,
                 self.name,
                 organization=self.organization,
                 reserved=RESERVED_PROJECT_SLUGS)
         super(Project, self).save(*args, **kwargs)
     else:
         super(Project, self).save(*args, **kwargs)
     self.update_rev_for_option()
开发者ID:binlee1990,项目名称:sentry,代码行数:13,代码来源:project.py

示例10: create_team_and_keys_for_project

def create_team_and_keys_for_project(instance, created, **kwargs):
    if not created or kwargs.get('raw'):
        return

    if not instance.owner:
        return

    if not instance.team:
        team = Team(owner=instance.owner, name=instance.name)
        slugify_instance(team, instance.slug)
        team.save()
        update(instance, team=team)

    if not ProjectKey.objects.filter(project=instance, user__isnull=True).exists():
        ProjectKey.objects.create(
            project=instance,
        )
开发者ID:FortuneZhang,项目名称:sentry,代码行数:17,代码来源:core.py

示例11: forwards

    def forwards(self, orm):
        from sentry.constants import RESERVED_ORGANIZATION_SLUGS
        from sentry.db.models.utils import slugify_instance
        from sentry.utils.query import RangeQuerySetWrapperWithProgressBar

        Project = orm['sentry.Project']

        queryset = Project.objects.filter(
            organization__isnull=True
        ).select_related('team', 'team__organization')

        for project in RangeQuerySetWrapperWithProgressBar(queryset):
            project.organization = project.team.organization

            try:
                atomic_save(project)
            except IntegrityError:
                # we also need to update the slug here based on the new constraints
                slugify_instance(project, project.name, (
                    models.Q(organization=project.organization) | models.Q(team=project.team),
                ))
                project.save()
开发者ID:280185386,项目名称:sentry,代码行数:22,代码来源:0143_fill_project_orgs.py

示例12: handle

    def handle(self, **options):
        from django.db.models import Q
        from sentry.constants import RESERVED_ORGANIZATION_SLUGS
        from sentry.models import Organization, Project, Team, ProjectKey
        from sentry.db.models import update
        from sentry.db.models.utils import slugify_instance
        from sentry.utils.query import RangeQuerySetWrapperWithProgressBar

        print("Correcting data on organizations")
        queryset = Organization.objects.filter(
            slug__isnull=True,
        )
        for org in RangeQuerySetWrapperWithProgressBar(queryset):
            slugify_instance(org, org.name, RESERVED_ORGANIZATION_SLUGS)
            org.save()

        # Create teams for any projects that are missing them
        print("Correcting data on projects")
        queryset = Project.objects.filter(
            Q(team__isnull=True) | Q(organization__isnull=True),
        ).select_related('owner')
        for project in RangeQuerySetWrapperWithProgressBar(queryset):
            if not project.team:
                organization = Organization(
                    name=project.name,
                    owner=project.owner,
                )
                slugify_instance(organization, organization.name, RESERVED_ORGANIZATION_SLUGS)
                organization.save()

                team = Team(
                    name=project.name,
                    owner=project.owner,
                    oprganization=organization,
                )
                slugify_instance(team, team.name, RESERVED_ORGANIZATION_SLUGS)
                team.save()

            update(project, organization=team.organization, team=team)

        # Create missing project keys
        print("Creating missing project keys")
        queryset = Team.objects.all()
        for team in RangeQuerySetWrapperWithProgressBar(queryset):
            for member in team.member_set.select_related('user'):
                for project in team.project_set.all():
                    try:
                        created = ProjectKey.objects.get_or_create(
                            project=project,
                            user=member.user,
                        )[1]
                    except ProjectKey.MultipleObjectsReturned:
                        pass
开发者ID:BlueMoebius,项目名称:sentry,代码行数:53,代码来源:repair.py

示例13: test_max_length

 def test_max_length(self):
     org = Organization(name='matt')
     slugify_instance(org, 'matt', max_length=2)
     assert org.slug == 'ma', org.slug
     assert not Organization.objects.filter(slug='ma').exists()
开发者ID:280185386,项目名称:sentry,代码行数:5,代码来源:test_utils.py

示例14: test_reserved

 def test_reserved(self):
     base_slug = self.organization.slug
     org = Organization(name='foo')
     slugify_instance(org, base_slug, reserved=(base_slug,))
     assert not org.slug.startswith(base_slug + '-'), org.slug
     assert not Organization.objects.filter(slug=org.slug).exists()
开发者ID:280185386,项目名称:sentry,代码行数:6,代码来源:test_utils.py

示例15: save

 def save(self, *args, **kwargs):
     if not self.slug:
         slugify_instance(self, self.name, reserved=RESERVED_TEAM_SLUGS)
     super(Team, self).save(*args, **kwargs)
开发者ID:Getsidecar,项目名称:sentry,代码行数:4,代码来源:team.py


注:本文中的sentry.db.models.utils.slugify_instance函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。