Skip to content

Commit

Permalink
Context for 500s, Resolve Pre-cert Report 500s (#3333)
Browse files Browse the repository at this point in the history
* 500 errors should have (some limited) context.

* Pre-cert reports should not append bonus fields.

* Pre-cert reports should not append bonus fields.
  • Loading branch information
jperson1 authored Feb 1, 2024
1 parent 9d8aa16 commit 8c5624c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
8 changes: 8 additions & 0 deletions backend/config/error_handlers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.shortcuts import render


def handler500(request, template_name="500.html"):
"""
Custom handler for 500s. Ensures the 500 template loads with proper context (environment, login info, OMB values).
"""
return render(request, template_name, {})
2 changes: 2 additions & 0 deletions backend/config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
renderer_classes=[JSONOpenAPIRenderer],
)

handler500 = "config.error_handlers.handler500"

urlpatterns = [
path("api/schema.json", schema_view),
path(
Expand Down
11 changes: 6 additions & 5 deletions backend/dissemination/summary_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,11 +424,12 @@ def gather_report_data_pre_certification(i2d_data):
for obj in dissemination_data[model_name]:
row = []
for field_name in field_names:
value = getattr(obj, field_name)
# Wipe tzinfo
if isinstance(value, datetime):
value = value.replace(tzinfo=None)
row.append(value)
if not field_name.startswith("_"):
value = getattr(obj, field_name)
# Wipe tzinfo
if isinstance(value, datetime):
value = value.replace(tzinfo=None)
row.append(value)
data[model_name]["entries"].append(row)

return data
Expand Down

0 comments on commit 8c5624c

Please sign in to comment.