-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4ed36d1
commit 761d430
Showing
2 changed files
with
39 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from allauth.utils import build_absolute_uri | ||
from django.conf import settings | ||
from django.core.mail import send_mail | ||
from django.urls import reverse | ||
|
||
from commcare_connect.organization.models import UserOrganizationMembership | ||
from commcare_connect.users.models import User | ||
from config import celery_app | ||
|
||
|
||
@celery_app.task() | ||
def send_org_invite(membership_id, host_user_id): | ||
membership = UserOrganizationMembership.objects.get(pk=membership_id) | ||
host_user = User.objects.get(pk=host_user_id) | ||
if not membership.user.email: | ||
return | ||
location = reverse("organization:accept_invite", args=(membership.organization.slug, membership.invite_id)) | ||
invite_url = build_absolute_uri(None, location) | ||
message = f"""Hi, | ||
You have been invited to join {membership.organization.name} on Commcare Connect by {host_user.name}. | ||
The invite can be accepted by visiting the link. | ||
{invite_url} | ||
Thank You, | ||
Commcare Connect""" | ||
send_mail( | ||
subject=f"{host_user.name} has invite you to join {membership.organization.name}", | ||
message=message, | ||
recipient_list=[membership.user.email], | ||
from_email=settings.DEFAULT_FROM_EMAIL, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters