mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-03-18 09:10:49 +00:00
Removed redirection for login and help urls
Changed the redirection in state0 template
This commit is contained in:
parent
0332d4489e
commit
0290f68ae6
@ -26,7 +26,7 @@ first_boot_steps = [{'id': 'firstboot_state0',
|
||||
'url': 'first_boot:state0',
|
||||
'order': 0
|
||||
},
|
||||
{'id': 'firstboot_state10',
|
||||
{'id': 'firstboot_state10',
|
||||
'url': 'first_boot:state10',
|
||||
'order': 10
|
||||
}
|
||||
|
||||
@ -22,6 +22,7 @@ yet.
|
||||
|
||||
from django.http.response import HttpResponseRedirect
|
||||
from django.urls import reverse
|
||||
from django.conf import settings
|
||||
import logging
|
||||
from operator import itemgetter
|
||||
from plinth import kvstore, module_loader
|
||||
@ -38,11 +39,15 @@ class FirstBootMiddleware(object):
|
||||
"""Handle a request as Django middleware request handler."""
|
||||
state = kvstore.get_default('firstboot_state', 0)
|
||||
user_requests_firstboot = is_firstboot(request.path)
|
||||
if state == 1 and user_requests_firstboot:
|
||||
return HttpResponseRedirect(reverse('index'))
|
||||
elif state == 0 and not user_requests_firstboot:
|
||||
url = next_step()
|
||||
return HttpResponseRedirect(reverse(url))
|
||||
user_requests_login = request.path.startswith(reverse(settings.LOGIN_URL))
|
||||
help_index_url = reverse('help:index')
|
||||
user_requests_help = request.path.startswith(help_index_url)
|
||||
if not user_requests_login and not user_requests_help:
|
||||
if state == 1 and user_requests_firstboot:
|
||||
return HttpResponseRedirect(reverse('index'))
|
||||
elif state == 0 and not user_requests_firstboot:
|
||||
url = next_step()
|
||||
return HttpResponseRedirect(reverse(url))
|
||||
|
||||
|
||||
def is_firstboot(path):
|
||||
@ -59,6 +64,7 @@ def is_firstboot(path):
|
||||
|
||||
|
||||
def get_firstboot_steps():
|
||||
"""Returns all firstboot steps"""
|
||||
steps = []
|
||||
modules = module_loader.loaded_modules
|
||||
for (module_name, module_object) in modules.items():
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
</p>
|
||||
|
||||
<p class="text-center">
|
||||
<a href="{% url 'first_boot:state1' %}"
|
||||
<a href="{% url next_url %}"
|
||||
class="btn btn-primary btn-lg">{% trans "Start Setup" %}</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -28,14 +28,21 @@ from plinth import kvstore
|
||||
from plinth import network
|
||||
from plinth.errors import DomainRegistrationError
|
||||
from .forms import State1Form, State5Form
|
||||
from .middleware import mark_step_done
|
||||
from .middleware import mark_step_done, next_step
|
||||
|
||||
|
||||
class State0View(TemplateView):
|
||||
"""Show the welcome screen."""
|
||||
kvstore.set('firstboot_state0', 'done')
|
||||
|
||||
template_name = 'firstboot_state0.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
"""Returns the context data"""
|
||||
context = super(State0View, self).get_context_data(**kwargs)
|
||||
mark_step_done('firstboot_state0')
|
||||
context['next_url'] = next_step()
|
||||
return context
|
||||
|
||||
|
||||
def state10(request):
|
||||
"""State 10 is when all firstboot setup is done.
|
||||
|
||||
@ -31,7 +31,7 @@ from .forms import CreateUserForm, UserChangePasswordForm, UserUpdateForm, State
|
||||
|
||||
from plinth import actions
|
||||
from plinth.errors import ActionError
|
||||
from plinth.modules.first_boot.middleware import mark_step_done
|
||||
from plinth.modules.first_boot.middleware import mark_step_done, next_step
|
||||
|
||||
subsubmenu = [{'url': reverse_lazy('users:index'),
|
||||
'text': ugettext_lazy('Users')},
|
||||
@ -173,12 +173,14 @@ class State1View(CreateView):
|
||||
"""Create user account and log the user in."""
|
||||
template_name = 'firstboot_state1.html'
|
||||
form_class = State1Form
|
||||
success_url = ''
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""Initialize the view object."""
|
||||
if not cfg.danube_edition:
|
||||
mark_step_done('pagekite_firstboot')
|
||||
mark_step_done('users_firstboot')
|
||||
self.success_url = next_step()
|
||||
return super(State1View, self).__init__(*args, **kwargs)
|
||||
|
||||
def get_form_kwargs(self):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user