mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-21 07:51:13 -05:00
Merge pull request #936 from GSA/notify-admin-1447
Add debug statements for why we can't add user to a service on staging
This commit is contained in:
@@ -102,7 +102,7 @@ from app.service.service_senders_schema import (
|
|||||||
)
|
)
|
||||||
from app.service.utils import get_guest_list_objects
|
from app.service.utils import get_guest_list_objects
|
||||||
from app.user.users_schema import post_set_permissions_schema
|
from app.user.users_schema import post_set_permissions_schema
|
||||||
from app.utils import get_prev_next_pagination_links
|
from app.utils import get_prev_next_pagination_links, hilite
|
||||||
|
|
||||||
service_blueprint = Blueprint("service", __name__)
|
service_blueprint = Blueprint("service", __name__)
|
||||||
|
|
||||||
@@ -314,7 +314,9 @@ def get_users_for_service(service_id):
|
|||||||
def add_user_to_service(service_id, user_id):
|
def add_user_to_service(service_id, user_id):
|
||||||
service = dao_fetch_service_by_id(service_id)
|
service = dao_fetch_service_by_id(service_id)
|
||||||
user = get_user_by_id(user_id=user_id)
|
user = get_user_by_id(user_id=user_id)
|
||||||
|
# TODO REMOVE DEBUG
|
||||||
|
print(hilite(f"GOING TO ADD {user.name} to service {service.name}"))
|
||||||
|
# END DEBUG
|
||||||
if user in service.users:
|
if user in service.users:
|
||||||
error = "User id: {} already part of service id: {}".format(user_id, service_id)
|
error = "User id: {} already part of service id: {}".format(user_id, service_id)
|
||||||
raise InvalidRequest(error, status_code=400)
|
raise InvalidRequest(error, status_code=400)
|
||||||
@@ -329,6 +331,10 @@ def add_user_to_service(service_id, user_id):
|
|||||||
folder_permissions = data.get("folder_permissions", [])
|
folder_permissions = data.get("folder_permissions", [])
|
||||||
|
|
||||||
dao_add_user_to_service(service, user, permissions, folder_permissions)
|
dao_add_user_to_service(service, user, permissions, folder_permissions)
|
||||||
|
# TODO REMOVE DEBUG
|
||||||
|
print(hilite(f"ADDED {user.name} to service {service.name}"))
|
||||||
|
# END DEBUG
|
||||||
|
|
||||||
data = service_schema.dump(service)
|
data = service_schema.dump(service)
|
||||||
return jsonify(data=data), 201
|
return jsonify(data=data), 201
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ from app.notifications.process_notifications import (
|
|||||||
send_notification_to_queue,
|
send_notification_to_queue,
|
||||||
)
|
)
|
||||||
from app.schemas import invited_user_schema
|
from app.schemas import invited_user_schema
|
||||||
|
from app.utils import hilite
|
||||||
|
|
||||||
service_invite = Blueprint("service_invite", __name__)
|
service_invite = Blueprint("service_invite", __name__)
|
||||||
|
|
||||||
@@ -32,6 +33,10 @@ register_errors(service_invite)
|
|||||||
|
|
||||||
|
|
||||||
def _create_service_invite(invited_user, invite_link_host):
|
def _create_service_invite(invited_user, invite_link_host):
|
||||||
|
# TODO REMOVE DEBUG
|
||||||
|
print(hilite("ENTER _create_service_invite"))
|
||||||
|
# END DEBUG
|
||||||
|
|
||||||
template_id = current_app.config["INVITATION_EMAIL_TEMPLATE_ID"]
|
template_id = current_app.config["INVITATION_EMAIL_TEMPLATE_ID"]
|
||||||
|
|
||||||
template = dao_get_template_by_id(template_id)
|
template = dao_get_template_by_id(template_id)
|
||||||
@@ -85,11 +90,15 @@ def _create_service_invite(invited_user, invite_link_host):
|
|||||||
|
|
||||||
# This is for the login.gov service invite on the
|
# This is for the login.gov service invite on the
|
||||||
# "Set Up Your Profile" path.
|
# "Set Up Your Profile" path.
|
||||||
|
redis_key = f"service-invite-{invited_user.email_address}"
|
||||||
redis_store.set(
|
redis_store.set(
|
||||||
f"service-invite-{invited_user.email_address}",
|
redis_key,
|
||||||
json.dumps(data),
|
json.dumps(data),
|
||||||
ex=3600 * 24,
|
ex=3600 * 24,
|
||||||
)
|
)
|
||||||
|
# TODO REMOVE DEBUG
|
||||||
|
print(hilite(f"Save this data {data} with this redis_key {redis_key}"))
|
||||||
|
# END DEBUG
|
||||||
send_notification_to_queue(saved_notification, queue=QueueNames.NOTIFY)
|
send_notification_to_queue(saved_notification, queue=QueueNames.NOTIFY)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user