From 8a539ab107c686cb1088ab8eef06864eac04de70 Mon Sep 17 00:00:00 2001 From: Jake Rosenberg Date: Tue, 13 Feb 2024 10:32:20 -0600 Subject: [PATCH] Add new users to project via TRAM --- designsafe/apps/auth/tasks.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/designsafe/apps/auth/tasks.py b/designsafe/apps/auth/tasks.py index 10aad8d2f7..99f07e4738 100644 --- a/designsafe/apps/auth/tasks.py +++ b/designsafe/apps/auth/tasks.py @@ -1,4 +1,5 @@ from datetime import datetime, timedelta +import requests from django.conf import settings from django.core.mail import send_mail from agavepy.agave import Agave, AgaveException @@ -96,6 +97,15 @@ def new_user_alert(username): 'Name: ' + user.first_name + ' ' + user.last_name + '\n' + 'Id: ' + str(user.id) + '\n', settings.DEFAULT_FROM_EMAIL, settings.NEW_ACCOUNT_ALERT_EMAILS.split(','),) + + tram_headers = {"tram-services-key": settings.TRAM_SERVICES_KEY} + tram_body = {"project_id": settings.TRAM_PROJECT_ID, + "email": user.email} + tram_resp = requests.post(f"{settings.TRAM_SERVICES_URL}/project_invitations/create", + headers=tram_headers, + json=tram_body, + timeout=15) + tram_resp.raise_for_status() @shared_task()