本文整理汇总了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)