本文整理匯總了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)
示例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)
示例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)
示例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)