first_boot: Allow accessing help during first boot

This commit is contained in:
Sunil Mohan Adapa 2015-10-17 14:10:07 +05:30 committed by James Valleroy
parent 8fb6e31e9a
commit 8228440319

View File

@ -37,13 +37,18 @@ class FirstBootMiddleware(object):
def process_request(request):
"""Handle a request as Django middleware request handler."""
state = kvstore.get_default('firstboot_state', 0)
firstboot_index_url = reverse('first_boot:index')
user_requests_firstboot = request.path.startswith(firstboot_index_url)
help_index_url = reverse('help:index')
user_requests_help = request.path.startswith(help_index_url)
# Setup is complete: Forbid accessing firstboot
if state >= 10 and user_requests_firstboot:
return HttpResponseRedirect(reverse('index'))
# Setup is not complete: Forbid accessing anything but firstboot
if state < 10 and not user_requests_firstboot:
# Setup is not complete: Forbid accessing anything but firstboot or help
if state < 10 and not user_requests_firstboot and \
not user_requests_help:
return HttpResponseRedirect(reverse('first_boot:state%d' % state))