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


Python User.set_password方法代码示例

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


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

示例1: owner

# 需要导入模块: from sentry.models import User [as 别名]
# 或者: from sentry.models.User import set_password [as 别名]
    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,代码行数:10,代码来源:tests.py

示例2: create_user

# 需要导入模块: from sentry.models import User [as 别名]
# 或者: from sentry.models.User import set_password [as 别名]
    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:peterbe,项目名称:sentry,代码行数:12,代码来源:fixtures.py

示例3: createuser

# 需要导入模块: from sentry.models import User [as 别名]
# 或者: from sentry.models.User import set_password [as 别名]
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,代码行数:57,代码来源:createuser.py

示例4: member

# 需要导入模块: from sentry.models import User [as 别名]
# 或者: from sentry.models.User import set_password [as 别名]
    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,代码行数:13,代码来源:tests.py

示例5: member

# 需要导入模块: from sentry.models import User [as 别名]
# 或者: from sentry.models.User import set_password [as 别名]
    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,代码行数:14,代码来源:tests.py

示例6: member

# 需要导入模块: from sentry.models import User [as 别名]
# 或者: from sentry.models.User import set_password [as 别名]
    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,代码行数:14,代码来源:tests.py

示例7: create_user

# 需要导入模块: from sentry.models import User [as 别名]
# 或者: from sentry.models.User import set_password [as 别名]
    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:helloguille,项目名称:sentry,代码行数:15,代码来源:fixtures.py

示例8: handle

# 需要导入模块: from sentry.models import User [as 别名]
# 或者: from sentry.models.User import set_password [as 别名]
    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,代码行数:52,代码来源:createuser.py

示例9: create_user

# 需要导入模块: from sentry.models import User [as 别名]
# 或者: from sentry.models.User import set_password [as 别名]
    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,代码行数:22,代码来源:fixtures.py

示例10: handle

# 需要导入模块: from sentry.models import User [as 别名]
# 或者: from sentry.models.User import set_password [as 别名]
    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,代码行数:43,代码来源:createuser.py

示例11: EmailAuthBackendTest

# 需要导入模块: from sentry.models import User [as 别名]
# 或者: from sentry.models.User import set_password [as 别名]
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,代码行数:23,代码来源:tests.py

示例12: owner

# 需要导入模块: from sentry.models import User [as 别名]
# 或者: from sentry.models.User import set_password [as 别名]
    def owner(self):
        user = User(username="owner", email="[email protected]")
        user.set_password('owner')
        user.save()

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

示例13: configure

# 需要导入模块: from sentry.models import User [as 别名]
# 或者: from sentry.models.User import set_password [as 别名]
#!/srv/sentry/application/current/bin/python
{% from "sentry/map.jinja" import sentry with context %}

from sentry.utils.runner import configure
configure()

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

user = User()
user.username = '{{sentry.bootstrap.username}}'
user.email = '{{sentry.bootstrap.email}}'
user.is_superuser = True
user.set_password('{{sentry.bootstrap.password}}')
user.save()

organization = Organization()
organization.name = '{{sentry.bootstrap.organization}}'
organization.owner = user
organization.save()

team = Team()
team.organization = organization
team.name = '{{sentry.bootstrap.team}}'
team.owner = user
team.save()

project = Project()
project.organization = organization
project.team = team
project.owner = user
project.name = '{{sentry.bootstrap.project}}'
开发者ID:ministryofjustice,项目名称:sentry-formula,代码行数:33,代码来源:bootstrap.py

示例14: configure

# 需要导入模块: from sentry.models import User [as 别名]
# 或者: from sentry.models.User import set_password [as 别名]
# 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
    project.add_team(team)
    project.name = 'Cern Open Data Portal'
    project.organization = organization
    project.save()
开发者ID:artfisica,项目名称:opendata.cern.ch,代码行数:32,代码来源:initialize.py

示例15: test_requires_password_on_valid_accounts

# 需要导入模块: from sentry.models import User [as 别名]
# 或者: from sentry.models.User import set_password [as 别名]
 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,代码行数:7,代码来源:tests.py


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