We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Contact modal broken in Firefox
The contact modal does not work in Firefox, because `event` is undefined. Chrome provides this in global scope, that's why it's working there (see https://stackoverflow.com/questions/18274383/ajax-post-working-in-chrome-but-not-in-firefox).

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `evap/evaluation/views.py`
Content:
```
1 import logging
2 
3 from django.conf import settings
4 from django.contrib import messages, auth
5 from django.contrib.auth.decorators import login_required
6 from django.core.mail import EmailMessage
7 from django.http import HttpResponse
8 from django.shortcuts import redirect, render
9 from django.utils.translation import ugettext as _
10 from django.views.decorators.http import require_POST
11 from django.views.decorators.debug import sensitive_post_parameters
12 from django.views.i18n import set_language
13 
14 from evap.evaluation.forms import NewKeyForm, LoginUsernameForm
15 from evap.evaluation.models import UserProfile, FaqSection, EmailTemplate, Semester
16 
17 logger = logging.getLogger(__name__)
18 
19 
20 @sensitive_post_parameters("password")
21 def index(request):
22     """Main entry page into EvaP providing all the login options available. The username/password
23        login is thought to be used for internal users, e.g. by connecting to a LDAP directory.
24        The login key mechanism is meant to be used to include external participants, e.g. visiting
25        students or visiting contributors.
26     """
27 
28     # parse the form data into the respective form
29     submit_type = request.POST.get("submit_type", "no_submit")
30     new_key_form = NewKeyForm(request.POST if submit_type == "new_key" else None)
31     login_username_form = LoginUsernameForm(request, request.POST if submit_type == "login_username" else None)
32 
33     # process form data
34     if request.method == 'POST':
35         if new_key_form.is_valid():
36             # user wants a new login key
37             profile = new_key_form.get_user()
38             profile.ensure_valid_login_key()
39             profile.save()
40 
41             EmailTemplate.send_login_url_to_user(new_key_form.get_user())
42 
43             messages.success(request, _("We sent you an email with a one-time login URL. Please check your inbox."))
44             return redirect('evaluation:index')
45         elif login_username_form.is_valid():
46             # user would like to login with username and password and passed password test
47             auth.login(request, login_username_form.get_user())
48 
49             # clean up our test cookie
50             if request.session.test_cookie_worked():
51                 request.session.delete_test_cookie()
52 
53     # if not logged in by now, render form
54     if not request.user.is_authenticated:
55         # set test cookie to verify whether they work in the next step
56         request.session.set_test_cookie()
57 
58         template_data = dict(new_key_form=new_key_form, login_username_form=login_username_form)
59         return render(request, "index.html", template_data)
60     else:
61         user, __ = UserProfile.objects.get_or_create(username=request.user.username)
62 
63         # check for redirect variable
64         redirect_to = request.GET.get("next", None)
65         if redirect_to is not None:
66             return redirect(redirect_to)
67 
68         # redirect user to appropriate start page
69         if request.user.is_reviewer:
70             return redirect('staff:semester_view', Semester.active_semester().id)
71         if request.user.is_staff:
72             return redirect('staff:index')
73         elif request.user.is_grade_publisher:
74             return redirect('grades:semester_view', Semester.active_semester().id)
75         elif user.is_student:
76             return redirect('student:index')
77         elif user.is_contributor_or_delegate:
78             return redirect('contributor:index')
79         else:
80             return redirect('results:index')
81 
82 
83 def faq(request):
84     return render(request, "faq.html", dict(sections=FaqSection.objects.all()))
85 
86 
87 def legal_notice(request):
88     return render(request, "legal_notice.html", dict())
89 
90 
91 @require_POST
92 @login_required
93 def contact(request):
94     message = request.POST.get("message")
95     title = request.POST.get("title")
96     subject = "[EvaP] Message from {}".format(request.user.username)
97 
98     if message:
99         mail = EmailMessage(
100             subject=subject,
101             body="{}\n{} ({})\n\n{}".format(title, request.user.username, request.user.email, message),
102             to=[settings.CONTACT_EMAIL])
103         try:
104             mail.send()
105             logger.info('Sent contact email: \n{}\n'.format(mail.message()))
106         except Exception:
107             logger.exception('An exception occurred when sending the following contact email:\n{}\n'.format(mail.message()))
108             raise
109 
110     return HttpResponse()
111 
112 
113 @require_POST
114 def set_lang(request):
115     if request.user.is_authenticated:
116         user = request.user
117         user.language = request.POST['language']
118         user.save()
119 
120     return set_language(request)
121
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/evap/evaluation/views.py b/evap/evaluation/views.py
--- a/evap/evaluation/views.py
+++ b/evap/evaluation/views.py
@@ -4,7 +4,7 @@
 from django.contrib import messages, auth
 from django.contrib.auth.decorators import login_required
 from django.core.mail import EmailMessage
-from django.http import HttpResponse
+from django.http import HttpResponse, HttpResponseBadRequest
 from django.shortcuts import redirect, render
 from django.utils.translation import ugettext as _
 from django.views.decorators.http import require_POST
@@ -103,11 +103,12 @@
         try:
             mail.send()
             logger.info('Sent contact email: \n{}\n'.format(mail.message()))
+            return HttpResponse()
         except Exception:
             logger.exception('An exception occurred when sending the following contact email:\n{}\n'.format(mail.message()))
             raise
 
-    return HttpResponse()
+    return HttpResponseBadRequest()
 
 
 @require_POST

{"golden_diff": "diff --git a/evap/evaluation/views.py b/evap/evaluation/views.py\n--- a/evap/evaluation/views.py\n+++ b/evap/evaluation/views.py\n@@ -4,7 +4,7 @@\n from django.contrib import messages, auth\n from django.contrib.auth.decorators import login_required\n from django.core.mail import EmailMessage\n-from django.http import HttpResponse\n+from django.http import HttpResponse, HttpResponseBadRequest\n from django.shortcuts import redirect, render\n from django.utils.translation import ugettext as _\n from django.views.decorators.http import require_POST\n@@ -103,11 +103,12 @@\n         try:\n             mail.send()\n             logger.info('Sent contact email: \\n{}\\n'.format(mail.message()))\n+            return HttpResponse()\n         except Exception:\n             logger.exception('An exception occurred when sending the following contact email:\\n{}\\n'.format(mail.message()))\n             raise\n \n-    return HttpResponse()\n+    return HttpResponseBadRequest()\n \n \n @require_POST\n", "issue": "Contact modal broken in Firefox\nThe contact modal does not work in Firefox, because `event` is undefined. Chrome provides this in global scope, that's why it's working there (see https://stackoverflow.com/questions/18274383/ajax-post-working-in-chrome-but-not-in-firefox).\n", "before_files": [{"content": "import logging\n\nfrom django.conf import settings\nfrom django.contrib import messages, auth\nfrom django.contrib.auth.decorators import login_required\nfrom django.core.mail import EmailMessage\nfrom django.http import HttpResponse\nfrom django.shortcuts import redirect, render\nfrom django.utils.translation import ugettext as _\nfrom django.views.decorators.http import require_POST\nfrom django.views.decorators.debug import sensitive_post_parameters\nfrom django.views.i18n import set_language\n\nfrom evap.evaluation.forms import NewKeyForm, LoginUsernameForm\nfrom evap.evaluation.models import UserProfile, FaqSection, EmailTemplate, Semester\n\nlogger = logging.getLogger(__name__)\n\n\n@sensitive_post_parameters(\"password\")\ndef index(request):\n    \"\"\"Main entry page into EvaP providing all the login options available. The username/password\n       login is thought to be used for internal users, e.g. by connecting to a LDAP directory.\n       The login key mechanism is meant to be used to include external participants, e.g. visiting\n       students or visiting contributors.\n    \"\"\"\n\n    # parse the form data into the respective form\n    submit_type = request.POST.get(\"submit_type\", \"no_submit\")\n    new_key_form = NewKeyForm(request.POST if submit_type == \"new_key\" else None)\n    login_username_form = LoginUsernameForm(request, request.POST if submit_type == \"login_username\" else None)\n\n    # process form data\n    if request.method == 'POST':\n        if new_key_form.is_valid():\n            # user wants a new login key\n            profile = new_key_form.get_user()\n            profile.ensure_valid_login_key()\n            profile.save()\n\n            EmailTemplate.send_login_url_to_user(new_key_form.get_user())\n\n            messages.success(request, _(\"We sent you an email with a one-time login URL. Please check your inbox.\"))\n            return redirect('evaluation:index')\n        elif login_username_form.is_valid():\n            # user would like to login with username and password and passed password test\n            auth.login(request, login_username_form.get_user())\n\n            # clean up our test cookie\n            if request.session.test_cookie_worked():\n                request.session.delete_test_cookie()\n\n    # if not logged in by now, render form\n    if not request.user.is_authenticated:\n        # set test cookie to verify whether they work in the next step\n        request.session.set_test_cookie()\n\n        template_data = dict(new_key_form=new_key_form, login_username_form=login_username_form)\n        return render(request, \"index.html\", template_data)\n    else:\n        user, __ = UserProfile.objects.get_or_create(username=request.user.username)\n\n        # check for redirect variable\n        redirect_to = request.GET.get(\"next\", None)\n        if redirect_to is not None:\n            return redirect(redirect_to)\n\n        # redirect user to appropriate start page\n        if request.user.is_reviewer:\n            return redirect('staff:semester_view', Semester.active_semester().id)\n        if request.user.is_staff:\n            return redirect('staff:index')\n        elif request.user.is_grade_publisher:\n            return redirect('grades:semester_view', Semester.active_semester().id)\n        elif user.is_student:\n            return redirect('student:index')\n        elif user.is_contributor_or_delegate:\n            return redirect('contributor:index')\n        else:\n            return redirect('results:index')\n\n\ndef faq(request):\n    return render(request, \"faq.html\", dict(sections=FaqSection.objects.all()))\n\n\ndef legal_notice(request):\n    return render(request, \"legal_notice.html\", dict())\n\n\n@require_POST\n@login_required\ndef contact(request):\n    message = request.POST.get(\"message\")\n    title = request.POST.get(\"title\")\n    subject = \"[EvaP] Message from {}\".format(request.user.username)\n\n    if message:\n        mail = EmailMessage(\n            subject=subject,\n            body=\"{}\\n{} ({})\\n\\n{}\".format(title, request.user.username, request.user.email, message),\n            to=[settings.CONTACT_EMAIL])\n        try:\n            mail.send()\n            logger.info('Sent contact email: \\n{}\\n'.format(mail.message()))\n        except Exception:\n            logger.exception('An exception occurred when sending the following contact email:\\n{}\\n'.format(mail.message()))\n            raise\n\n    return HttpResponse()\n\n\n@require_POST\ndef set_lang(request):\n    if request.user.is_authenticated:\n        user = request.user\n        user.language = request.POST['language']\n        user.save()\n\n    return set_language(request)\n", "path": "evap/evaluation/views.py"}], "after_files": [{"content": "import logging\n\nfrom django.conf import settings\nfrom django.contrib import messages, auth\nfrom django.contrib.auth.decorators import login_required\nfrom django.core.mail import EmailMessage\nfrom django.http import HttpResponse, HttpResponseBadRequest\nfrom django.shortcuts import redirect, render\nfrom django.utils.translation import ugettext as _\nfrom django.views.decorators.http import require_POST\nfrom django.views.decorators.debug import sensitive_post_parameters\nfrom django.views.i18n import set_language\n\nfrom evap.evaluation.forms import NewKeyForm, LoginUsernameForm\nfrom evap.evaluation.models import UserProfile, FaqSection, EmailTemplate, Semester\n\nlogger = logging.getLogger(__name__)\n\n\n@sensitive_post_parameters(\"password\")\ndef index(request):\n    \"\"\"Main entry page into EvaP providing all the login options available. The username/password\n       login is thought to be used for internal users, e.g. by connecting to a LDAP directory.\n       The login key mechanism is meant to be used to include external participants, e.g. visiting\n       students or visiting contributors.\n    \"\"\"\n\n    # parse the form data into the respective form\n    submit_type = request.POST.get(\"submit_type\", \"no_submit\")\n    new_key_form = NewKeyForm(request.POST if submit_type == \"new_key\" else None)\n    login_username_form = LoginUsernameForm(request, request.POST if submit_type == \"login_username\" else None)\n\n    # process form data\n    if request.method == 'POST':\n        if new_key_form.is_valid():\n            # user wants a new login key\n            profile = new_key_form.get_user()\n            profile.ensure_valid_login_key()\n            profile.save()\n\n            EmailTemplate.send_login_url_to_user(new_key_form.get_user())\n\n            messages.success(request, _(\"We sent you an email with a one-time login URL. Please check your inbox.\"))\n            return redirect('evaluation:index')\n        elif login_username_form.is_valid():\n            # user would like to login with username and password and passed password test\n            auth.login(request, login_username_form.get_user())\n\n            # clean up our test cookie\n            if request.session.test_cookie_worked():\n                request.session.delete_test_cookie()\n\n    # if not logged in by now, render form\n    if not request.user.is_authenticated:\n        # set test cookie to verify whether they work in the next step\n        request.session.set_test_cookie()\n\n        template_data = dict(new_key_form=new_key_form, login_username_form=login_username_form)\n        return render(request, \"index.html\", template_data)\n    else:\n        user, __ = UserProfile.objects.get_or_create(username=request.user.username)\n\n        # check for redirect variable\n        redirect_to = request.GET.get(\"next\", None)\n        if redirect_to is not None:\n            return redirect(redirect_to)\n\n        # redirect user to appropriate start page\n        if request.user.is_reviewer:\n            return redirect('staff:semester_view', Semester.active_semester().id)\n        if request.user.is_staff:\n            return redirect('staff:index')\n        elif request.user.is_grade_publisher:\n            return redirect('grades:semester_view', Semester.active_semester().id)\n        elif user.is_student:\n            return redirect('student:index')\n        elif user.is_contributor_or_delegate:\n            return redirect('contributor:index')\n        else:\n            return redirect('results:index')\n\n\ndef faq(request):\n    return render(request, \"faq.html\", dict(sections=FaqSection.objects.all()))\n\n\ndef legal_notice(request):\n    return render(request, \"legal_notice.html\", dict())\n\n\n@require_POST\n@login_required\ndef contact(request):\n    message = request.POST.get(\"message\")\n    title = request.POST.get(\"title\")\n    subject = \"[EvaP] Message from {}\".format(request.user.username)\n\n    if message:\n        mail = EmailMessage(\n            subject=subject,\n            body=\"{}\\n{} ({})\\n\\n{}\".format(title, request.user.username, request.user.email, message),\n            to=[settings.CONTACT_EMAIL])\n        try:\n            mail.send()\n            logger.info('Sent contact email: \\n{}\\n'.format(mail.message()))\n            return HttpResponse()\n        except Exception:\n            logger.exception('An exception occurred when sending the following contact email:\\n{}\\n'.format(mail.message()))\n            raise\n\n    return HttpResponseBadRequest()\n\n\n@require_POST\ndef set_lang(request):\n    if request.user.is_authenticated:\n        user = request.user\n        user.language = request.POST['language']\n        user.save()\n\n    return set_language(request)\n", "path": "evap/evaluation/views.py"}]}