Skip to content

Commit

Permalink
Ensure invite links available to FE (#471)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-treebeard authored Jun 11, 2021
1 parent 9bc3eaf commit a9c9ea3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/human_lambdas/user_handler/invitation.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ def get_queryset(self):

def get(self, request, *args, **kwargs):
invited_users = [
{"email": invitation.email, "pending": True, "is_admin": invitation.admin}
{
"email": invitation.email,
"pending": True,
"is_admin": invitation.admin,
"link": invitation.invite_link,
}
for invitation in self.get_queryset()
]
return Response(
Expand All @@ -49,7 +54,7 @@ def post(self, request, *args, **kwargs):
organization = Organization.objects.get(pk=kwargs["org_id"])
template_data = []
emails = []

links = {}
for email in email_set:
if is_invalid_email(email):
invalid_email_list.append(email)
Expand Down Expand Up @@ -94,6 +99,7 @@ def post(self, request, *args, **kwargs):
+ timezone.timedelta(days=settings.INVITATION_EXPIRATION_WINDOW_DAYS),
).save()

links[email] = invite_link
emails.append(email)

if settings.INVITATION_TEMPLATE is None or settings.ACCOUNT_ASM_GROUPID is None:
Expand All @@ -112,6 +118,7 @@ def post(self, request, *args, **kwargs):
{
"status_code": 200,
"message": "all emails were successfully added!",
"links": links,
},
status=200,
)
Expand All @@ -124,6 +131,7 @@ def post(self, request, *args, **kwargs):
{
"status_code": 400,
"errors": [{"message": response_text}],
"links": links,
},
status=400,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def setUp(self):
invited_by=self.user,
token=self.token,
expires_at=aware_expiry_date,
invite_link="llll",
)
existing_invite.save()

Expand Down Expand Up @@ -173,6 +174,7 @@ def test_invitation_post_deletes_invites_after_new_user(self):
invited_by=self.user,
token=token,
expires_at=make_aware(datetime.datetime.now() + datetime.timedelta(30)),
invite_link="lkjhlkjh",
)
new_user_invite.save()

Expand Down

0 comments on commit a9c9ea3

Please sign in to comment.