1
1
import logging
2
- import threading
3
2
4
- from django .conf import settings
5
3
from django .http import HttpResponse
6
4
from django .shortcuts import redirect , render
7
5
from django .utils .translation import gettext as _
8
6
9
- from .forms import FeedbackForm , ReportIssueForm
7
+ from .forms import FeedbackForm , IssueForm
10
8
from .service import send_notifications
11
9
12
10
log = logging .getLogger (__name__ )
@@ -43,19 +41,16 @@ def thank_you_view(request) -> HttpResponse:
43
41
44
42
def report_issue_view (request ) -> HttpResponse :
45
43
if request .method == "POST" :
46
- form = ReportIssueForm (request .POST )
44
+ form = IssueForm (request .POST )
47
45
if form .is_valid ():
48
46
issue = form .save (commit = False )
49
47
issue .entity_name = request .session .get ("entity_name" )
50
48
issue .entity_url = request .session .get ("entity_url" )
51
49
issue .data_owner_email = request .session .get ("data_owner_email" )
52
50
issue .save ()
53
51
54
- if settings .NOTIFY_ENABLED :
55
- # Spawn a thread to process the sending of notifcations and avoid potential delays
56
- # returning a response to the user.
57
- t = threading .Thread (target = send_notifications , args = (issue ,))
58
- t .start ()
52
+ # Call the send notifications service
53
+ send_notifications (issue = issue )
59
54
60
55
return redirect ("feedback:thanks" )
61
56
@@ -65,7 +60,9 @@ def report_issue_view(request) -> HttpResponse:
65
60
request ,
66
61
"report_issue.html" ,
67
62
{
68
- "h1_value" : _ ("Report an issue on Find MOJ data" ),
63
+ "h1_value" : _ (
64
+ f"Report an issue with { request .session .get ('entity_name' )} "
65
+ ),
69
66
"form" : form ,
70
67
},
71
68
)
@@ -77,13 +74,13 @@ def report_issue_view(request) -> HttpResponse:
77
74
request .session ["entity_url" ] = entity_url
78
75
request .session ["data_owner_email" ] = _ (request .GET .get ("data_owner_email" , "" ))
79
76
80
- form = ReportIssueForm ()
77
+ form = IssueForm ()
81
78
82
79
return render (
83
80
request ,
84
81
"report_issue.html" ,
85
82
{
86
- "h1_value" : _ ("Report an issue on Find MOJ data " ),
83
+ "h1_value" : _ (f "Report an issue with { entity_name } " ),
87
84
"form" : form ,
88
85
"entity_name" : entity_name ,
89
86
"entity_url" : entity_url ,
0 commit comments