當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。