Disallow profile updating if user is checked in

It gives a flash and pops the user back to dashboard.
This commit is contained in:
Sachi King 2018-01-21 11:21:56 +11:00 committed by James Polley
parent 971cb5d12d
commit 5beafb2c6b

View file

@ -36,6 +36,7 @@ from django.http import Http404, HttpResponse
from django.shortcuts import redirect from django.shortcuts import redirect
from django.shortcuts import render from django.shortcuts import render
from django.template import Context, Template, loader from django.template import Context, Template, loader
from django.urls import reverse
import waffle import waffle
from lxml import etree from lxml import etree
@ -373,6 +374,13 @@ def edit_profile(request):
''' '''
if hasattr(request.user, "checkin"):
if request.user.checkin.checked_in_bool:
messages.add_message(
request, messages.ERROR,
'Profile cannot be edited as you have been checked in')
return redirect(reverse('dashboard'))
form, handled = _handle_profile(request, "profile") form, handled = _handle_profile(request, "profile")
if handled and not form.errors: if handled and not form.errors: