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


Python models.SignupCode类代码示例

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


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

示例1: cohort_member_add

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,代码行数:33,代码来源:views.py

示例2: invite

    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,代码行数:29,代码来源:models.py

示例3: setUp

 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,代码行数:9,代码来源:allPythonContent.py

示例4: setup_signup_code

 def setup_signup_code(self):
     code = self.get_code()
     if code:
         try:
             self.signup_code = SignupCode.check_code(code)
         except SignupCode.InvalidCode:
             self.signup_code = None
         self.signup_code_present = True
     else:
         self.signup_code = None
         self.signup_code_present = False
开发者ID:worseisbetter,项目名称:django-user-accounts,代码行数:11,代码来源:views.py

示例5: is_open

 def is_open(self):
     code = self.request.REQUEST.get('code')
     if code:
         try:
             self.signup_code = SignupCode.check(code)
         except SignupCode.InvalidCode:
             return settings.ACCOUNT_OPEN_SIGNUP
         else:
             return True
     else:
         return settings.ACCOUNT_OPEN_SIGNUP
开发者ID:CharlesCliff,项目名称:dannysite.com,代码行数:11,代码来源:views.py

示例6: handle

 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,代码行数:11,代码来源:create_signups.py

示例7: clean_code

 def clean_code(self):
     try:
         signup_code = SignupCode.check(self.cleaned_data.get("code"))
     except SignupCode.InvalidCode:
         if not settings.ACCOUNT_OPEN_SIGNUP:
             raise forms.ValidationError(_("Signup code is invalid."))
         else:
             return None
     else:
         if not settings.ACCOUNT_OPEN_SIGNUP and signup_code is None:
             raise forms.ValidationError(_("Code is required to signup."))
         return signup_code
开发者ID:soon404,项目名称:django-user-accounts,代码行数:12,代码来源:forms.py

示例8: test_valid_code

 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,代码行数:13,代码来源:test_views.py

示例9: test_register_with_moderation

 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,代码行数:16,代码来源:test_views.py

示例10: is_open

 def is_open(self):
     code = self.request.REQUEST.get("code")
     if code:
         try:
             self.signup_code = SignupCode.check(code)
         except SignupCode.InvalidCode:
             if self.messages.get("invalid_signup_code"):
                 messages.add_message(
                     self.request,
                     self.messages["invalid_signup_code"]["level"],
                     self.messages["invalid_signup_code"]["text"] % {
                         "code": code
                     }
                 )
             return settings.ACCOUNT_OPEN_SIGNUP
         else:
             return True
     else:
         return settings.ACCOUNT_OPEN_SIGNUP
开发者ID:LokiikoL,项目名称:django-user-accounts,代码行数:19,代码来源:views.py

示例11: is_open

 def is_open(self):
     code = self.request.REQUEST.get('code')
     if code:
         try:
             self.signup_code = SignupCode.check(code)
         except SignupCode.InvalidCode:
             if self.messages.get('invalid_signup_code'):
                 messages.add_message(
                     self.request,
                     self.messages['invalid_signup_code']['level'],
                     self.messages['invalid_signup_code']['text'].format(**{
                         'code': code
                     })
                 )
             return settings.ACCOUNT_OPEN_SIGNUP
         else:
             return True
     else:
         return settings.ACCOUNT_OPEN_SIGNUP
开发者ID:RyanLyu,项目名称:dannysite.com,代码行数:19,代码来源:views.py

示例12: get

 def get(self, *args, **kwargs):
     if self.request.user.is_authenticated():
         return redirect(default_redirect(self.request, settings.ACCOUNT_LOGIN_REDIRECT_URL))
     code = self.request.GET.get("code")
     try:
         self.signup_code = SignupCode.check(code)
     except SignupCode.InvalidCode:
         if not settings.ACCOUNT_OPEN_SIGNUP:
             return self.closed(code=code)
         else:
             if self.messages.get("invalid_signup_code"):
                 messages.add_message(
                     self.request,
                     self.messages["invalid_signup_code"]["level"],
                     self.messages["invalid_signup_code"]["text"] % {
                         "code": code
                     }
                 )
     if not settings.ACCOUNT_OPEN_SIGNUP and self.signup_code is None:
         return self.closed()
     return super(SignupView, self).get(*args, **kwargs)
开发者ID:soon404,项目名称:django-user-accounts,代码行数:21,代码来源:views.py

示例13: invite

 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,代码行数:23,代码来源:models.py


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