當前位置: 首頁>>代碼示例>>Python>>正文


Python Invitation.by_email方法代碼示例

本文整理匯總了Python中corehq.apps.users.models.Invitation.by_email方法的典型用法代碼示例。如果您正苦於以下問題:Python Invitation.by_email方法的具體用法?Python Invitation.by_email怎麽用?Python Invitation.by_email使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在corehq.apps.users.models.Invitation的用法示例。


在下文中一共展示了Invitation.by_email方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: select

# 需要導入模塊: from corehq.apps.users.models import Invitation [as 別名]
# 或者: from corehq.apps.users.models.Invitation import by_email [as 別名]
def select(request, domain_select_template='domain/select.html', do_not_redirect=False):
    domains_for_user = Domain.active_for_user(request.user)
    if not domains_for_user:
        from corehq.apps.registration.views import track_domainless_new_user
        track_domainless_new_user(request)
        return redirect('registration_domain')

    email = request.couch_user.get_email()
    open_invitations = [e for e in Invitation.by_email(email) if not e.is_expired]

    additional_context = {
        'domains_for_user': domains_for_user,
        'open_invitations': open_invitations,
        'current_page': {'page_name': _('Select A Project')},
    }

    last_visited_domain = request.session.get('last_visited_domain')
    if open_invitations \
       or do_not_redirect \
       or not last_visited_domain:
        return render(request, domain_select_template, additional_context)
    else:
        domain_obj = Domain.get_by_name(last_visited_domain)
        if domain_obj and domain_obj.is_active:
            # mirrors logic in login_and_domain_required
            if (
                request.couch_user.is_member_of(domain_obj)
                or (request.user.is_superuser and not domain_obj.restrict_superusers)
                or domain_obj.is_snapshot
            ):
                try:
                    from corehq.apps.dashboard.views import dashboard_default
                    return dashboard_default(request, last_visited_domain)
                except Http404:
                    pass

        del request.session['last_visited_domain']
        return render(request, domain_select_template, additional_context)
開發者ID:dimagi,項目名稱:commcare-hq,代碼行數:40,代碼來源:base.py

示例2: test_by_email

# 需要導入模塊: from corehq.apps.users.models import Invitation [as 別名]
# 或者: from corehq.apps.users.models.Invitation import by_email [as 別名]
 def test_by_email(self):
     self.assertEqual(len(Invitation.by_email('[email protected]')), 1)
     self.assertEqual(len(Invitation.by_email('[email protected]')), 1)
     self.assertEqual(len(Invitation.by_email('[email protected]')), 0)
開發者ID:ansarbek,項目名稱:commcare-hq,代碼行數:6,代碼來源:test_models.py


注:本文中的corehq.apps.users.models.Invitation.by_email方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。