Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor redirect URL on deletion of Federal Awards Audit Findings #4386

Merged
merged 5 commits into from
Oct 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions backend/report_submission/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,14 +577,16 @@

def post(self, request, *args, **kwargs):
report_id = kwargs["report_id"]
path_name = request.path.split("/")[2]
section = self.additional_context[path_name]
redirect_uri = f"/report_submission/{section['view_id']}/{report_id}"
try:
sac = SingleAuditChecklist.objects.get(report_id=report_id)
accesses = Access.objects.filter(sac=sac, user=request.user)

if not accesses:
messages.error(request, "You do not have access to this audit.")
return redirect(request.path)
path_name = request.path.split("/")[2]
section = self.additional_context[path_name]
return redirect(redirect_uri)
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Show resolved Hide resolved

try:
excel_files = ExcelFile.objects.filter(
Expand All @@ -597,7 +599,7 @@
sac.save()
except ExcelFile.DoesNotExist:
messages.error(request, "File not found.")
return redirect(request.path)
return redirect(redirect_uri)
Fixed Show fixed Hide fixed

SubmissionEvent.objects.create(
sac_id=sac.id,
Expand All @@ -611,9 +613,9 @@
except SingleAuditChecklist.DoesNotExist:
logger.error(f"Audit: {report_id} not found")
messages.error(request, "Audit not found.")
return redirect(request.path)
return redirect(redirect_uri)
Fixed Show fixed Hide fixed

except Exception as e:
logger.error(f"Unexpected error in DeleteFileView post: {str(e)}")
messages.error(request, "An unexpected error occurred.")
return redirect(request.path)
return redirect(redirect_uri)
Fixed Show fixed Hide fixed
Loading