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


Python Invitation.by_domain方法代码示例

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


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

示例1: resend_pending_invitations

# 需要导入模块: from corehq.apps.users.models import Invitation [as 别名]
# 或者: from corehq.apps.users.models.Invitation import by_domain [as 别名]
def resend_pending_invitations():
    from corehq.apps.users.models import Invitation
    days_to_resend = (15, 29)
    days_to_expire = 30
    domains = Domain.get_all()
    for domain in domains:
        invitations = Invitation.by_domain(domain.name)
        for invitation in invitations:
            days = (datetime.utcnow() - invitation.invited_on).days
            if days in days_to_resend:
                invitation.send_activation_email(days_to_expire - days)
开发者ID:bazuzi,项目名称:commcare-hq,代码行数:13,代码来源:tasks.py

示例2: invite_web_user_form

# 需要导入模块: from corehq.apps.users.models import Invitation [as 别名]
# 或者: from corehq.apps.users.models.Invitation import by_domain [as 别名]
    def invite_web_user_form(self):
        role_choices = UserRole.role_choices(self.domain)
        loc = None
        domain_request = DomainRequest.objects.get(id=self.request_id) if self.request_id else None
        initial = {"email": domain_request.email if domain_request else None}
        if "location_id" in self.request.GET:
            from corehq.apps.locations.models import SQLLocation

            loc = SQLLocation.objects.get(location_id=self.request.GET.get("location_id"))
        if self.request.method == "POST":
            current_users = [user.username for user in WebUser.by_domain(self.domain)]
            pending_invites = [di.email for di in Invitation.by_domain(self.domain)]
            return AdminInvitesUserForm(
                self.request.POST,
                excluded_emails=current_users + pending_invites,
                role_choices=role_choices,
                domain=self.domain,
            )
        return AdminInvitesUserForm(initial=initial, role_choices=role_choices, domain=self.domain, location=loc)
开发者ID:philipkaare,项目名称:commcare-hq,代码行数:21,代码来源:__init__.py

示例3: invite_web_user_form

# 需要导入模块: from corehq.apps.users.models import Invitation [as 别名]
# 或者: from corehq.apps.users.models.Invitation import by_domain [as 别名]
 def invite_web_user_form(self):
     role_choices = _get_editable_role_choices(self.domain, self.request.couch_user, allow_admin_role=True)
     loc = None
     domain_request = DomainRequest.objects.get(id=self.request_id) if self.request_id else None
     initial = {
         'email': domain_request.email if domain_request else None,
     }
     if 'location_id' in self.request.GET:
         from corehq.apps.locations.models import SQLLocation
         loc = SQLLocation.objects.get(location_id=self.request.GET.get('location_id'))
     if self.request.method == 'POST':
         current_users = [user.username for user in WebUser.by_domain(self.domain)]
         pending_invites = [di.email for di in Invitation.by_domain(self.domain)]
         return AdminInvitesUserForm(
             self.request.POST,
             excluded_emails=current_users + pending_invites,
             role_choices=role_choices,
             domain=self.domain
         )
     return AdminInvitesUserForm(initial=initial, role_choices=role_choices, domain=self.domain, location=loc)
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:22,代码来源:__init__.py

示例4: test_by_domain

# 需要导入模块: from corehq.apps.users.models import Invitation [as 别名]
# 或者: from corehq.apps.users.models.Invitation import by_domain [as 别名]
 def test_by_domain(self):
     self.assertEqual(len(Invitation.by_domain('domain_1')), 1)
     self.assertEqual(len(Invitation.by_domain('domain_2')), 1)
     self.assertEqual(len(Invitation.by_domain('domain_3')), 0)
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:6,代码来源:test_models.py


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