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


Python SignupCode.create方法代码示例

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


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

示例1: invite

# 需要导入模块: from account.models import SignupCode [as 别名]
# 或者: from account.models.SignupCode import create [as 别名]
    def invite(cls, from_user, to_email, message=None, send=True):
        if not from_user.invitationstat.can_send():
            raise NotEnoughInvitationsError()

        signup_code = SignupCode.create(
            email=to_email,
            inviter=from_user,
            expiry=settings.PINAX_INVITATIONS_DEFAULT_EXPIRATION,
            check_exists=False  # before we are called caller must check for existence
        )
        signup_code.save()
        join = cls.objects.create(
            from_user=from_user,
            message=message,
            status=JoinInvitation.STATUS_SENT,
            signup_code=signup_code
        )

        def send_invite(*args, **kwargs):
            signup_code.send(*args, **kwargs)
            InvitationStat.objects.filter(user=from_user).update(
                invites_sent=models.F("invites_sent") + 1
            )
            invite_sent.send(sender=cls, invitation=join)
        if send:
            send_invite()
        else:
            join.send_invite = send_invite
        return join
开发者ID:pinax,项目名称:pinax-invitations,代码行数:31,代码来源:models.py

示例2: cohort_member_add

# 需要导入模块: from account.models import SignupCode [as 别名]
# 或者: from account.models.SignupCode import create [as 别名]
def cohort_member_add(request, pk):
    
    if not request.user.is_staff:
        raise Http404()
    
    cohort = Cohort.objects.get(pk=pk)
    
    if "invite_next" in request.POST:
        try:
            N = int(request.POST["invite_next"])
        except ValueError:
            return redirect("waitinglist_cohort_detail", cohort.id)
        # people who are NOT invited or on the site already
        waiting_list = WaitingListEntry.objects.exclude(
            email__in=SignupCode.objects.values("email")
        ).exclude(
            email__in=User.objects.values("email")
        )
        emails = waiting_list.values_list("email", flat=True)[:N]
    else:
        email = request.POST["email"].strip()
        if email:
            emails = [email]
        else:
            emails = []
    
    for email in emails:
        if not SignupCode.objects.filter(email=email).exists():
            signup_code = SignupCode.create(email=email, max_uses=1, expiry=730)
            signup_code.save()
            SignupCodeCohort.objects.create(signup_code=signup_code, cohort=cohort)
    
    return redirect("waitinglist_cohort_detail", cohort.id)
开发者ID:aibon,项目名称:django-waitinglist,代码行数:35,代码来源:views.py

示例3: setUp

# 需要导入模块: from account.models import SignupCode [as 别名]
# 或者: from account.models.SignupCode import create [as 别名]
 def setUp(self):
     self.to_user = User.objects.create(username="foo1")
     self.from_user = User.objects.create(username="foo2")
     self.signup_code = SignupCode.create(email="[email protected]")
     self.signup_code.save()
     self.status = JoinInvitation.STATUS_ACCEPTED
     self.invitation = JoinInvitation.objects.create(
         from_user=self.from_user, status=self.status, signup_code=self.signup_code
     )
开发者ID:Mondego,项目名称:pyreco,代码行数:11,代码来源:allPythonContent.py

示例4: handle

# 需要导入模块: from account.models import SignupCode [as 别名]
# 或者: from account.models.SignupCode import create [as 别名]
 def handle(self, *args, **options):
     site = Site.objects.get_current()
     
     expiry = int(args[2]) if len(args) > 2 else 768
     with open(args[1], mode="w") as fh:
         for i in range(int(args[0])):
             signup = SignupCode.create(max_uses=1, expiry=expiry, check_exists=False)
             fh.write("http://{0}{1}?code={2},".format(site.domain,
                                                       urlresolvers.reverse('account_signup'),
                                                       signup.code))
             signup.save()
开发者ID:jinktv,项目名称:django-user-accounts,代码行数:13,代码来源:create_signups.py

示例5: test_valid_code

# 需要导入模块: from account.models import SignupCode [as 别名]
# 或者: from account.models.SignupCode import create [as 别名]
 def test_valid_code(self):
     signup_code = SignupCode.create()
     signup_code.save()
     with self.settings(ACCOUNT_OPEN_SIGNUP=False):
         data = {
             "username": "foo",
             "password": "bar",
             "password_confirm": "bar",
             "email": "[email protected]",
             "code": signup_code.code,
         }
         response = self.client.post(reverse("account_signup"), data)
         self.assertEqual(response.status_code, 302)
开发者ID:TengyuMaVandy,项目名称:ffci,代码行数:15,代码来源:test_views.py

示例6: test_register_with_moderation

# 需要导入模块: from account.models import SignupCode [as 别名]
# 或者: from account.models.SignupCode import create [as 别名]
 def test_register_with_moderation(self):
     signup_code = SignupCode.create()
     signup_code.save()
     with self.settings(ACCOUNT_OPEN_SIGNUP=True, ACCOUNT_APPROVAL_REQUIRED=True):
         data = {
             "username": "foo",
             "password": "bar",
             "password_confirm": "bar",
             "email": "[email protected]",
             "code": signup_code.code,
         }
         response = self.client.post(reverse("account_signup"), data)
         self.assertEqual(response.status_code, 200)
         self.assertFalse(self.client.session.get('_auth_user_id'))
         u = User.objects.get(username=data['username'])
         self.assertFalse(u.is_active)
开发者ID:GeoNode,项目名称:geonode-user-accounts,代码行数:18,代码来源:test_views.py

示例7: invite

# 需要导入模块: from account.models import SignupCode [as 别名]
# 或者: from account.models.SignupCode import create [as 别名]
 def invite(cls, from_user, to_email, message=None):
     if not from_user.invitationstat.can_send():
         raise NotEnoughInvitationsError()
     
     signup_code = SignupCode.create(
         email=to_email,
         inviter=from_user,
         expiry=DEFAULT_INVITE_EXPIRATION,
         check_exists=False # before we are called caller must check for existence
     )
     signup_code.save()
     join = cls.objects.create(
         from_user=from_user,
         message=message,
         status=JoinInvitation.STATUS_SENT,
         signup_code=signup_code
     )
     signup_code.send()
     stat = from_user.invitationstat
     stat.invites_sent += 1
     stat.save()
     invite_sent.send(sender=cls, invitation=join)
     return join
开发者ID:codenittygrritty,项目名称:kaleo,代码行数:25,代码来源:models.py


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