mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-25 02:24:07 +02:00
Merge branch 'main' into za/2402-design-review
This commit is contained in:
commit
ef12c5e93e
11 changed files with 565 additions and 400 deletions
|
@ -1,10 +1,10 @@
|
|||
import logging
|
||||
from django.http import JsonResponse
|
||||
from django.forms.models import model_to_dict
|
||||
from registrar.models import FederalAgency, SeniorOfficial
|
||||
from registrar.models import FederalAgency, SeniorOfficial, DomainRequest
|
||||
from django.contrib.admin.views.decorators import staff_member_required
|
||||
from django.contrib.auth.decorators import login_required
|
||||
|
||||
from registrar.utility.admin_helpers import get_all_action_needed_reason_emails
|
||||
from registrar.models.portfolio import Portfolio
|
||||
from registrar.utility.constants import BranchChoices
|
||||
|
||||
|
@ -66,3 +66,27 @@ def get_federal_and_portfolio_types_from_federal_agency_json(request):
|
|||
}
|
||||
|
||||
return JsonResponse(response_data)
|
||||
|
||||
|
||||
@login_required
|
||||
@staff_member_required
|
||||
def get_action_needed_email_for_user_json(request):
|
||||
"""Returns a default action needed email for a given user"""
|
||||
|
||||
# This API is only accessible to admins and analysts
|
||||
superuser_perm = request.user.has_perm("registrar.full_access_permission")
|
||||
analyst_perm = request.user.has_perm("registrar.analyst_access_permission")
|
||||
if not request.user.is_authenticated or not any([analyst_perm, superuser_perm]):
|
||||
return JsonResponse({"error": "You do not have access to this resource"}, status=403)
|
||||
|
||||
reason = request.GET.get("reason")
|
||||
domain_request_id = request.GET.get("domain_request_id")
|
||||
if not reason:
|
||||
return JsonResponse({"error": "No reason specified"}, status=404)
|
||||
|
||||
if not domain_request_id:
|
||||
return JsonResponse({"error": "No domain_request_id specified"}, status=404)
|
||||
|
||||
domain_request = DomainRequest.objects.filter(id=domain_request_id).first()
|
||||
emails = get_all_action_needed_reason_emails(request, domain_request)
|
||||
return JsonResponse({"action_needed_email": emails.get(reason)}, status=200)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue