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

Handle non-existant deparment on registration check #544

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
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
10 changes: 8 additions & 2 deletions firecares/firecares_core/ext/registration/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.contrib.humanize.templatetags import humanize
from django.core.mail import EmailMultiAlternatives
from django.http import JsonResponse
from django.http.response import HttpResponseBadRequest, HttpResponseNotFound
from django.http.response import HttpResponseBadRequest, HttpResponseNotFound, Http404
from django.shortcuts import redirect
from django.template import loader
from django.views.generic import TemplateView
Expand All @@ -29,12 +29,18 @@ class RegistrationPreregisterView(FormView):

def get(self, request):
if 'department' in request.GET:
fd = FireDepartment.objects.get(id=request.GET['department'])
try:
fd = FireDepartment.objects.get(id=request.GET['department'])
except FireDepartment.DoesNotExist:
raise Http404()

admins = fd.get_department_admins()

if not admins:
request.session['message'] = 'We\'re sorry, a IAFC Official or Local Officer needs to enable FireCARES on this department before your account can be approved by the department.'
request.session['message_title'] = 'FireCARES not enabled for {}'.format(fd.name)
return redirect('show_message')

return super(RegistrationPreregisterView, self).get(request)


Expand Down