当前位置: 首页>>代码示例>>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;未经允许,请勿转载。