mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
Firstboot: minor variable renaming and cleanup
This commit is contained in:
parent
bf6bcfcf38
commit
3af82ab14e
@ -106,7 +106,7 @@ def mark_step_done(id):
|
|||||||
|
|
||||||
kvstore.set(id, 1)
|
kvstore.set(id, 1)
|
||||||
if not next_step_or_none():
|
if not next_step_or_none():
|
||||||
kvstore.set('setup_state', 1)
|
set_completed()
|
||||||
|
|
||||||
|
|
||||||
def is_completed():
|
def is_completed():
|
||||||
@ -115,9 +115,12 @@ def is_completed():
|
|||||||
|
|
||||||
global _is_completed
|
global _is_completed
|
||||||
if _is_completed is None:
|
if _is_completed is None:
|
||||||
|
# TODO
|
||||||
|
# Rename setup_state to 'firstboot_completed',
|
||||||
|
# taking care of the existing kvstore variable name.
|
||||||
_is_completed = kvstore.get_default('setup_state', 0)
|
_is_completed = kvstore.get_default('setup_state', 0)
|
||||||
|
|
||||||
return _is_completed
|
return bool(_is_completed)
|
||||||
|
|
||||||
|
|
||||||
def set_completed():
|
def set_completed():
|
||||||
|
|||||||
@ -48,20 +48,20 @@ class FirstBootMiddleware(object):
|
|||||||
if user_requests_help:
|
if user_requests_help:
|
||||||
return
|
return
|
||||||
|
|
||||||
state = first_boot.is_completed()
|
firstboot_completed = first_boot.is_completed()
|
||||||
|
|
||||||
# Migrate from old settings variable
|
# Migrate from old settings variable
|
||||||
if state == 0:
|
if not firstboot_completed:
|
||||||
old_state = kvstore.get_default('firstboot_state', 0)
|
old_state = kvstore.get_default('firstboot_state', 0)
|
||||||
if old_state == 10:
|
if old_state == 10:
|
||||||
state = 1
|
firstboot_completed = True
|
||||||
first_boot.set_completed()
|
first_boot.set_completed()
|
||||||
|
|
||||||
user_requests_firstboot = first_boot.is_firstboot_url(request.path)
|
user_requests_firstboot = first_boot.is_firstboot_url(request.path)
|
||||||
|
|
||||||
# Redirect to first boot if requesting normal page and first
|
# Redirect to first boot if requesting normal page and first
|
||||||
# boot is not complete.
|
# boot is not complete.
|
||||||
if state == 0 and not user_requests_firstboot:
|
if not firstboot_completed and not user_requests_firstboot:
|
||||||
next_step = first_boot.next_step_or_none()
|
next_step = first_boot.next_step_or_none()
|
||||||
if next_step:
|
if next_step:
|
||||||
return HttpResponseRedirect(reverse(next_step))
|
return HttpResponseRedirect(reverse(next_step))
|
||||||
@ -71,5 +71,5 @@ class FirstBootMiddleware(object):
|
|||||||
|
|
||||||
# Redirect to index page if request firstboot after it is
|
# Redirect to index page if request firstboot after it is
|
||||||
# finished.
|
# finished.
|
||||||
if state == 1 and user_requests_firstboot:
|
if firstboot_completed and user_requests_firstboot:
|
||||||
return HttpResponseRedirect(reverse('index'))
|
return HttpResponseRedirect(reverse('index'))
|
||||||
|
|||||||
@ -21,13 +21,13 @@ Template tags for first boot module.
|
|||||||
|
|
||||||
from django import template
|
from django import template
|
||||||
|
|
||||||
|
from plinth.modules import first_boot
|
||||||
from plinth import kvstore
|
from plinth import kvstore
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag
|
@register.simple_tag
|
||||||
def firstboot_is_finished():
|
def firstboot_is_completed():
|
||||||
"""Return whether firstboot process is completed."""
|
"""Return whether firstboot process is completed."""
|
||||||
state = kvstore.get_default('setup_state', 0)
|
return first_boot.is_completed()
|
||||||
return state == 1
|
|
||||||
|
|||||||
@ -26,8 +26,8 @@
|
|||||||
{# Adapt mainmenu-links during firstboot #}
|
{# Adapt mainmenu-links during firstboot #}
|
||||||
{% block mainmenu_left %}
|
{% block mainmenu_left %}
|
||||||
|
|
||||||
{% firstboot_is_finished as firstboot_finished %}
|
{% firstboot_is_completed as firstboot_completed %}
|
||||||
{% if not firstboot_finished %}
|
{% if not firstboot_completed %}
|
||||||
|
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<img src="{% static 'theme/img/freedombox-logo-32px.png' %}"
|
<img src="{% static 'theme/img/freedombox-logo-32px.png' %}"
|
||||||
@ -46,8 +46,8 @@
|
|||||||
|
|
||||||
{% block mainmenu_right %}
|
{% block mainmenu_right %}
|
||||||
|
|
||||||
{% firstboot_is_finished as firstboot_finished %}
|
{% firstboot_is_completed as firstboot_completed %}
|
||||||
{% if not firstboot_finished %}
|
{% if not firstboot_completed %}
|
||||||
{% include "firstboot_navbar.html" %}
|
{% include "firstboot_navbar.html" %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user