mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
moved firstboot handling to a firstboot middleware
This commit is contained in:
1 parent
cf03ee160a
commit
19f36f67d9
3 files changed
+32
-20
No files matched your search
@@ -0,0 +1,25 @@
|
||||
import logging
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.http.response import HttpResponseRedirect
|
||||
|
||||
from withsqlite.withsqlite import sqlite_db
|
||||
import cfg
|
||||
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class FirstBootMiddleware:
|
||||
""" Forward to firstboot page if firstboot isn't finished yet """
|
||||
def process_request(self, request):
|
||||
with sqlite_db(cfg.store_file, table='firstboot') as database:
|
||||
if not 'state' in database:
|
||||
# Permanent redirect causes the browser to cache the redirect,
|
||||
# preventing the user from navigating to /plinth until the
|
||||
# browser is restarted.
|
||||
return HttpResponseRedirect(reverse('first_boot:index'))
|
||||
|
||||
if database['state'] < 5:
|
||||
LOGGER.info('First boot state - %d', database['state'])
|
||||
return HttpResponseRedirect(reverse('first_boot:state%d' %
|
||||
database['state']))
|
||||
Reference in new issue
Block a user