• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.User类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: owner

    def owner(self):
        user = User(username="owner", email="[email protected]")
        user.set_password('owner')
        user.save()

        Team.objects.create(owner=user, name='foo', slug='foo')

        return user
开发者ID:CaseCommonsDevOps,项目名称:sentry,代码行数:8,代码来源:tests.py


示例2: create_user

    def create_user(self, email, **kwargs):
        kwargs.setdefault('username', email)
        kwargs.setdefault('is_staff', True)
        kwargs.setdefault('is_superuser', True)

        user = User(email=email, **kwargs)
        user.set_password('admin')
        user.save()

        return user
开发者ID:catufunwa,项目名称:sentry,代码行数:10,代码来源:fixtures.py


示例3: createuser

def createuser(email, password, superuser, no_password, no_input):
    "Create a new user."
    if not no_input:
        if not email:
            email = _get_email()

        if not (password or no_password):
            password = _get_password()

        if superuser is None:
            superuser = _get_superuser()

    if superuser is None:
        superuser = False

    if not email:
        raise click.ClickException('Invalid or missing email address.')

    # TODO(mattrobenolt): Accept password over stdin?
    if not no_password and not password:
        raise click.ClickException('No password set and --no-password not passed.')

    from sentry import roles
    from sentry.models import User
    from django.conf import settings

    user = User(
        email=email,
        username=email,
        is_superuser=superuser,
        is_staff=superuser,
        is_active=True,
    )

    if password:
        user.set_password(password)

    user.save()

    click.echo('User created: %s' % (email,))

    # TODO(dcramer): kill this when we improve flows
    if settings.SENTRY_SINGLE_ORGANIZATION:
        from sentry.models import Organization, OrganizationMember
        org = Organization.get_default()
        if superuser:
            role = roles.get_top_dog().id
        else:
            role = org.default_role
        OrganizationMember.objects.create(
            organization=org,
            user=user,
            role=role,
        )
        click.echo('Added to organization: %s' % (org.slug,))
开发者ID:delkyd,项目名称:sentry,代码行数:55,代码来源:createuser.py


示例4: member

    def member(self):
        user = User(username="member", email="[email protected]")
        user.set_password('member')
        user.save()

        TeamMember.objects.create(
            user=user,
            team=self.team,
            type=MEMBER_USER,
        )
        return user
开发者ID:CaseCommonsDevOps,项目名称:sentry,代码行数:11,代码来源:tests.py


示例5: member

    def member(self):
        user = User(username="member", email="[email protected]")
        user.set_password('member')
        user.save()

        om = self.create_member(
            organization=self.team.organization,
            user=user,
            type=MEMBER_USER,
            teams=[self.team],
        )
        return user
开发者ID:carriercomm,项目名称:sentry-1,代码行数:12,代码来源:tests.py


示例6: member

    def member(self):
        user = User(username="member", email="[email protected]")
        user.set_password('member')
        user.save()

        om = OrganizationMember.objects.create(
            organization=self.team.organization,
            user=user,
            type=MEMBER_USER,
        )
        om.teams.add(self.team)
        return user
开发者ID:BlueMoebius,项目名称:sentry,代码行数:12,代码来源:tests.py


示例7: create_user

    def create_user(self, email=None, **kwargs):
        if not email:
            email = uuid4().hex + "@example.com"

        kwargs.setdefault("username", email)
        kwargs.setdefault("is_staff", True)
        kwargs.setdefault("is_superuser", False)

        user = User(email=email, **kwargs)
        user.set_password("admin")
        user.save()

        return user
开发者ID:noah-lee,项目名称:sentry,代码行数:13,代码来源:fixtures.py


示例8: handle

    def handle(self, **options):
        email = options['email']
        is_superuser = options['is_superuser']
        password = options['password']

        if not options['noinput']:
            try:
                if not email:
                    email = self.get_email()

                if not (password or options['nopassword']):
                    password = self.get_password()

                if is_superuser is None:
                    is_superuser = self.get_superuser()
            except KeyboardInterrupt:
                self.stderr.write("\nOperation cancelled.")
                sys.exit(1)

        if not email:
            raise CommandError('Invalid or missing email address')

        if not options['nopassword'] and not password:
            raise CommandError('No password set and --no-password not passed')

        user = User(
            email=email,
            username=email,
            is_superuser=is_superuser,
            is_staff=is_superuser,
            is_active=True,
        )

        if password:
            user.set_password(password)

        user.save()

        self.stdout.write('User created: %s' % (email,))

        # TODO(dcramer): kill this when we improve flows
        if settings.SENTRY_SINGLE_ORGANIZATION:
            org = Organization.objects.all()[0]
            OrganizationMember.objects.create(
                organization=org,
                user=user,
                type=OrganizationMemberType.OWNER,
                has_global_access=user.is_superuser,
            )
            self.stdout.write('Added to organization: %s' % (org.slug,))
开发者ID:KinKir,项目名称:sentry,代码行数:50,代码来源:createuser.py


示例9: create_user

    def create_user(self, email=None, **kwargs):
        if not email:
            email = uuid4().hex + '@example.com'

        kwargs.setdefault('username', email)
        kwargs.setdefault('is_staff', True)
        kwargs.setdefault('is_active', True)
        kwargs.setdefault('is_superuser', False)

        user = User(email=email, **kwargs)
        user.set_password('admin')
        user.save()

        # UserEmail is created by a signal
        UserEmail.objects.filter(
            user=user,
            email=email,
        ).update(is_verified=True)

        return user
开发者ID:duanshuaimin,项目名称:sentry,代码行数:20,代码来源:fixtures.py


示例10: handle

    def handle(self, **options):
        email = options['email']
        is_superuser = options['is_superuser']

        if not options['noinput']:
            try:
                if not email:
                    email = self.get_email()

                if not options['nopassword']:
                    password = self.get_password()

                if is_superuser is None:
                    is_superuser = self.get_superuser()
            except KeyboardInterrupt:
                self.stderr.write("\nOperation cancelled.")
                sys.exit(1)

        else:
            password = None

        if not email:
            raise CommandError('Invalid or missing email address')

        if not options['nopassword'] and not password:
            raise CommandError('No password set and --no-password not passed')

        user = User(
            email=email,
            username=email,
            is_superuser=is_superuser,
            is_staff=is_superuser,
            is_active=True,
        )

        if password:
            user.set_password(password)

        user.save()

        self.stdout.write('User created: %s' % (email,))
开发者ID:BlueMoebius,项目名称:sentry,代码行数:41,代码来源:createuser.py


示例11: EmailAuthBackendTest

class EmailAuthBackendTest(TestCase):
    def setUp(self):
        self.user = User(username="foo", email="[email protected]")
        self.user.set_password("bar")
        self.user.save()

    @property
    def backend(self):
        return EmailAuthBackend()

    def test_can_authenticate_with_username(self):
        result = self.backend.authenticate(username='foo', password='bar')
        self.assertEquals(result, self.user)

    def test_can_authenticate_with_email(self):
        result = self.backend.authenticate(username='[email protected]', password='bar')
        self.assertEquals(result, self.user)

    def test_does_not_authenticate_with_invalid_password(self):
        result = self.backend.authenticate(username='foo', password='pizza')
        self.assertEquals(result, None)
开发者ID:Kayle009,项目名称:sentry,代码行数:21,代码来源:tests.py


示例12: nobody

 def nobody(self):
     user = User(username="nobody", email="[email protected]")
     user.set_password('nobody')
     user.save()
     return user
开发者ID:CaseCommonsDevOps,项目名称:sentry,代码行数:5,代码来源:tests.py


示例13: owner

    def owner(self):
        user = User(username="owner", email="[email protected]")
        user.set_password('owner')
        user.save()

        return user
开发者ID:carriercomm,项目名称:sentry-1,代码行数:6,代码来源:tests.py


示例14: admin

 def admin(self):
     user = User(username="admin", email="[email protected]", is_staff=True, is_superuser=True)
     user.set_password('admin')
     user.save()
     return user
开发者ID:CaseCommonsDevOps,项目名称:sentry,代码行数:5,代码来源:tests.py


示例15: createuser

def createuser(email, password, superuser, no_password, no_input):
    "Create a new user."
    if not no_input:
        if not email:
            email = _get_email()

        if not (password or no_password):
            password = _get_password()

        if superuser is None:
            superuser = _get_superuser()

    if superuser is None:
        superuser = False

    if not email:
        raise click.ClickException('Invalid or missing email address.')

    # TODO(mattrobenolt): Accept password over stdin?
    if not no_password and not password:
        raise click.ClickException('No password set and --no-password not passed.')

    from sentry import roles
    from sentry.models import User
    from django.conf import settings

    user = User(
        email=email,
        username=email,
        is_superuser=superuser,
        is_staff=superuser,
        is_active=True,
    )

    if password:
        user.set_password(password)

    user.save()

    click.echo('User created: %s' % (email, ))

    # TODO(dcramer): kill this when we improve flows
    if settings.SENTRY_SINGLE_ORGANIZATION:
        from sentry.models import (Organization, OrganizationMember, OrganizationMemberTeam, Team)

        org = Organization.get_default()
        if superuser:
            role = roles.get_top_dog().id
        else:
            role = org.default_role
        member = OrganizationMember.objects.create(
            organization=org,
            user=user,
            role=role,
        )

        # if we've only got a single team let's go ahead and give
        # access to that team as its likely the desired outcome
        teams = list(Team.objects.filter(organization=org)[0:2])
        if len(teams) == 1:
            OrganizationMemberTeam.objects.create(
                team=teams[0],
                organizationmember=member,
            )
        click.echo('Added to organization: %s' % (org.slug, ))
开发者ID:Kayle009,项目名称:sentry,代码行数:65,代码来源:createuser.py


示例16: test_requires_password_on_valid_accounts

 def test_requires_password_on_valid_accounts(self):
     user = User()
     user.set_password('foo')
     form = AccountSettingsForm(user=user)
     self.assertIn('old_password', form.fields)
开发者ID:CaseCommonsDevOps,项目名称:sentry,代码行数:5,代码来源:tests.py


示例17: configure

#!/usr/bin/env python

import sys

# Bootstrap the Sentry environment
from sentry.utils.runner import configure
configure()

# Add default superuser
from sentry.models import User

user = User()
user.username = sys.argv[1]
user.email = sys.argv[2]
user.is_superuser = True
user.set_password(sys.argv[3])
user.save()
开发者ID:tylrtrmbl,项目名称:sentry-in-a-box,代码行数:17,代码来源:create_sentry_superuser.py


示例18: configure

Based on example code from: 'https://docs.sentry.io/server/faq/'

"""

# Bootstrap the Sentry environment
from sentry.models import Organization, OrganizationMember, \
    OrganizationMemberTeam, Project, ProjectKey, Team, User
from sentry.utils.runner import configure

configure()


# Make an assumption that if 'admin' -User exists Sentry has been initialized
if not User.objects.filter(username='admin').exists():
    user = User()
    user.username = 'admin'
    user.email = '[email protected]'
    user.is_superuser = True
    user.set_password('admin')
    user.save()

    organization = Organization.objects.filter(slug='sentry')[0]

    team = Team()
    team.name = 'COD'
    team.organization = organization
    team.save()

    project = Project()
    project.team = team
开发者ID:artfisica,项目名称:opendata.cern.ch,代码行数:30,代码来源:initialize.py


示例19: test_requires_password_on_valid_accounts

 def test_requires_password_on_valid_accounts(self):
     user = User()
     user.set_password('foo')
     form = RemoveProjectForm(user=user, project_list=[])
     self.assertIn('password', form.fields)
开发者ID:Hosting-Scripts,项目名称:sentry,代码行数:5,代码来源:tests.py


示例20: configure

from sentry.utils.runner import configure
configure()

from sentry.models import Team, Project, ProjectKey, User, Organization

user = User()
user.username = 'admin'
user.email = '[email protected]'
user.is_superuser = True
user.set_password('admin')
user.save()

organization = Organization()
organization.name = 'MyOrg'
organization.owner = user
organization.save()

team = Team()
team.name = 'Sentry'
team.organization = organization
team.owner = user
team.save()

project = Project()
project.team = team
project.name = 'Default'
project.organization = organization
project.save()

f = open('dsn', 'wb')
key = ProjectKey.objects.filter(project=project)[0]
开发者ID:kemchos,项目名称:docker-sentry,代码行数:31,代码来源:sentry.init.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.UserEmail类代码示例发布时间:2022-05-27
下一篇:
Python models.TagKey类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap