mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-04-29 10:10:19 +00:00
firstboot: Rename views/urls to be non-numeric
This commit is contained in:
parent
c37aa0fbd5
commit
56686b7148
@ -25,13 +25,13 @@ is_essential = True
|
|||||||
|
|
||||||
first_boot_steps = [
|
first_boot_steps = [
|
||||||
{
|
{
|
||||||
'id': 'firstboot_state0',
|
'id': 'firstboot_welcome',
|
||||||
'url': 'first_boot:state0',
|
'url': 'first_boot:welcome',
|
||||||
'order': 0
|
'order': 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'id': 'firstboot_state10',
|
'id': 'firstboot_complete',
|
||||||
'url': 'first_boot:state10',
|
'url': 'first_boot:complete',
|
||||||
'order': 10
|
'order': 10
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@ -22,12 +22,13 @@ URLs for the First Boot module
|
|||||||
from django.conf.urls import url
|
from django.conf.urls import url
|
||||||
from stronghold.decorators import public
|
from stronghold.decorators import public
|
||||||
|
|
||||||
from .views import State0View, state10
|
from .views import WelcomeView, complete
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
# Take care of the firstboot middleware when changing URLs
|
# Take care of the firstboot middleware when changing URLs
|
||||||
url(r'^firstboot/$', public(State0View.as_view()), name='index'),
|
url(r'^firstboot/$', public(WelcomeView.as_view()), name='index'),
|
||||||
url(r'^firstboot/state0/$', public(State0View.as_view()), name='state0'),
|
url(r'^firstboot/welcome/$', public(WelcomeView.as_view()),
|
||||||
url(r'^firstboot/state10/$', state10, name='state10'),
|
name='welcome'),
|
||||||
|
url(r'^firstboot/complete/$', complete, name='complete'),
|
||||||
]
|
]
|
||||||
|
|||||||
@ -23,30 +23,30 @@ from plinth import network
|
|||||||
from .middleware import mark_step_done, next_step
|
from .middleware import mark_step_done, next_step
|
||||||
|
|
||||||
|
|
||||||
class State0View(TemplateView):
|
class WelcomeView(TemplateView):
|
||||||
"""Show the welcome screen."""
|
"""Show the welcome screen."""
|
||||||
|
|
||||||
template_name = 'firstboot_state0.html'
|
template_name = 'firstboot_welcome.html'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
"""Returns the context data for the template."""
|
"""Returns the context data for the template."""
|
||||||
context = super(State0View, self).get_context_data(**kwargs)
|
context = super(WelcomeView, self).get_context_data(**kwargs)
|
||||||
mark_step_done('firstboot_state0')
|
mark_step_done('firstboot_welcome')
|
||||||
context['next_url'] = next_step()
|
context['next_url'] = next_step()
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
def state10(request):
|
def complete(request):
|
||||||
"""State 10 is when all firstboot setup is done.
|
"""Show summary after all firstboot setup is done.
|
||||||
|
|
||||||
After viewing this page the firstboot module can't be accessed anymore.
|
After viewing this page the firstboot module can't be accessed anymore.
|
||||||
"""
|
"""
|
||||||
# Make sure that a user exists before finishing firstboot
|
# Make sure that a user exists before finishing firstboot
|
||||||
if User.objects.all():
|
if User.objects.all():
|
||||||
mark_step_done('firstboot_state10')
|
mark_step_done('firstboot_complete')
|
||||||
|
|
||||||
connections = network.get_connection_list()
|
connections = network.get_connection_list()
|
||||||
|
|
||||||
return render(request, 'firstboot_state10.html',
|
return render(request, 'firstboot_complete.html',
|
||||||
{'title': _('Setup Complete'),
|
{'title': _('Setup Complete'),
|
||||||
'connections': connections})
|
'connections': connections})
|
||||||
|
|||||||
@ -263,7 +263,7 @@ class AddCustomServiceForm(BaseCustomServiceForm):
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
class State5Form(forms.Form):
|
class FirstBootForm(forms.Form):
|
||||||
"""Set up freedombox.me pagekite subdomain"""
|
"""Set up freedombox.me pagekite subdomain"""
|
||||||
DOMAIN_APPENDIX = '.freedombox.me'
|
DOMAIN_APPENDIX = '.freedombox.me'
|
||||||
# Webservice url for domain validation and registration
|
# Webservice url for domain validation and registration
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
<h2>{% trans "Setup a freedombox.me subdomain with your voucher" %}</h2>
|
<h2>{% trans "Setup a freedombox.me subdomain with your voucher" %}</h2>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
{% url 'first_boot:state10' as finish_firstboot_url %}
|
{% url 'first_boot:complete' as finish_firstboot_url %}
|
||||||
{% blocktrans trimmed %}
|
{% blocktrans trimmed %}
|
||||||
<a href="{{ finish_firstboot_url }}">Skip this step</a> if you
|
<a href="{{ finish_firstboot_url }}">Skip this step</a> if you
|
||||||
do not have a voucher or want to configure PageKite later with a
|
do not have a voucher or want to configure PageKite later with a
|
||||||
@ -54,7 +54,7 @@
|
|||||||
<button type="submit" class="btn btn-primary">
|
<button type="submit" class="btn btn-primary">
|
||||||
{% trans "Register" %}
|
{% trans "Register" %}
|
||||||
</button>
|
</button>
|
||||||
<a href="{% url 'first_boot:state10' %}" class="btn btn-default"
|
<a href="{% url 'first_boot:complete' %}" class="btn btn-default"
|
||||||
role="button">
|
role="button">
|
||||||
{% trans "Skip Registration" %}
|
{% trans "Skip Registration" %}
|
||||||
</a>
|
</a>
|
||||||
@ -22,7 +22,7 @@ URLs for the PageKite module
|
|||||||
from django.conf.urls import url
|
from django.conf.urls import url
|
||||||
|
|
||||||
from .views import StandardServiceView, CustomServiceView, ConfigurationView, \
|
from .views import StandardServiceView, CustomServiceView, ConfigurationView, \
|
||||||
DeleteServiceView, index, State5View
|
DeleteServiceView, index, FirstBootView
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^sys/pagekite/$', index, name='index'),
|
url(r'^sys/pagekite/$', index, name='index'),
|
||||||
@ -34,5 +34,6 @@ urlpatterns = [
|
|||||||
name='custom-services'),
|
name='custom-services'),
|
||||||
url(r'^sys/pagekite/services/custom/delete$', DeleteServiceView.as_view(),
|
url(r'^sys/pagekite/services/custom/delete$', DeleteServiceView.as_view(),
|
||||||
name='delete-custom-service'),
|
name='delete-custom-service'),
|
||||||
url(r'^sys/pagekite/firstboot/$', State5View.as_view(), name='firstboot'),
|
url(r'^sys/pagekite/firstboot/$', FirstBootView.as_view(),
|
||||||
|
name='firstboot'),
|
||||||
]
|
]
|
||||||
|
|||||||
@ -25,7 +25,7 @@ from django.views.generic.edit import FormView
|
|||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
from .forms import ConfigurationForm, StandardServiceForm, \
|
from .forms import ConfigurationForm, StandardServiceForm, \
|
||||||
AddCustomServiceForm, DeleteCustomServiceForm, State5Form
|
AddCustomServiceForm, DeleteCustomServiceForm, FirstBootForm
|
||||||
from plinth.errors import DomainRegistrationError
|
from plinth.errors import DomainRegistrationError
|
||||||
from plinth.modules import pagekite
|
from plinth.modules import pagekite
|
||||||
from plinth.modules.first_boot.middleware import mark_step_done
|
from plinth.modules.first_boot.middleware import mark_step_done
|
||||||
@ -134,15 +134,15 @@ class ConfigurationView(ContextMixin, FormView):
|
|||||||
return super(ConfigurationView, self).form_valid(form)
|
return super(ConfigurationView, self).form_valid(form)
|
||||||
|
|
||||||
|
|
||||||
class State5View(FormView):
|
class FirstBootView(FormView):
|
||||||
"""State 5 is the (optional) setup of the Pagekite subdomain."""
|
"""First boot (optional) setup of the Pagekite subdomain."""
|
||||||
template_name = 'firstboot_state5.html'
|
template_name = 'pagekite_firstboot.html'
|
||||||
form_class = State5Form
|
form_class = FirstBootForm
|
||||||
|
|
||||||
def get(self, *args, **kwargs):
|
def get(self, *args, **kwargs):
|
||||||
"""Respond to GET request."""
|
"""Respond to GET request."""
|
||||||
mark_step_done('pagekite_firstboot')
|
mark_step_done('pagekite_firstboot')
|
||||||
return super(State5View, self).get(*args, **kwargs)
|
return super(FirstBootView, self).get(*args, **kwargs)
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
"""Act on valid form submission."""
|
"""Act on valid form submission."""
|
||||||
@ -156,4 +156,4 @@ class State5View(FormView):
|
|||||||
message = _('Pagekite setup finished. The HTTP and HTTPS services '
|
message = _('Pagekite setup finished. The HTTP and HTTPS services '
|
||||||
'are activated now.')
|
'are activated now.')
|
||||||
messages.success(self.request, message)
|
messages.success(self.request, message)
|
||||||
return super(State5View, self).form_valid(form)
|
return super(FirstBootView, self).form_valid(form)
|
||||||
|
|||||||
@ -245,8 +245,8 @@ class UserChangePasswordForm(SetPasswordForm):
|
|||||||
return user
|
return user
|
||||||
|
|
||||||
|
|
||||||
class State1Form(ValidNewUsernameCheckMixin, auth.forms.UserCreationForm):
|
class FirstBootForm(ValidNewUsernameCheckMixin, auth.forms.UserCreationForm):
|
||||||
"""Firstboot state 1: create a new user."""
|
"""User module first boot step: create a new admin user."""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self.request = kwargs.pop('request')
|
self.request = kwargs.pop('request')
|
||||||
|
|||||||
@ -41,5 +41,6 @@ urlpatterns = [
|
|||||||
{'template_name': 'login.html'}, name='login'),
|
{'template_name': 'login.html'}, name='login'),
|
||||||
url(r'^accounts/logout/$', auth_views.logout,
|
url(r'^accounts/logout/$', auth_views.logout,
|
||||||
{'next_page': reverse_lazy('index')}, name='logout'),
|
{'next_page': reverse_lazy('index')}, name='logout'),
|
||||||
url(r'^users/firstboot/$', public(views.State1View.as_view()), name='firstboot'),
|
url(r'^users/firstboot/$', public(views.FirstBootView.as_view()),
|
||||||
|
name='firstboot'),
|
||||||
]
|
]
|
||||||
|
|||||||
@ -26,7 +26,7 @@ import django.views.generic
|
|||||||
from django.utils.translation import ugettext as _, ugettext_lazy
|
from django.utils.translation import ugettext as _, ugettext_lazy
|
||||||
|
|
||||||
from .forms import CreateUserForm, UserChangePasswordForm, UserUpdateForm, \
|
from .forms import CreateUserForm, UserChangePasswordForm, UserUpdateForm, \
|
||||||
State1Form
|
FirstBootForm
|
||||||
from plinth import actions
|
from plinth import actions
|
||||||
from plinth import cfg
|
from plinth import cfg
|
||||||
from plinth.errors import ActionError
|
from plinth.errors import ActionError
|
||||||
@ -168,10 +168,10 @@ class UserChangePassword(ContextMixin, SuccessMessageMixin, FormView):
|
|||||||
return super(UserChangePassword, self).form_valid(form)
|
return super(UserChangePassword, self).form_valid(form)
|
||||||
|
|
||||||
|
|
||||||
class State1View(django.views.generic.CreateView):
|
class FirstBootView(django.views.generic.CreateView):
|
||||||
"""Create user account and log the user in."""
|
"""Create user account and log the user in."""
|
||||||
template_name = 'firstboot_state1.html'
|
template_name = 'users_firstboot.html'
|
||||||
form_class = State1Form
|
form_class = FirstBootForm
|
||||||
success_url = ''
|
success_url = ''
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
@ -181,10 +181,10 @@ class State1View(django.views.generic.CreateView):
|
|||||||
|
|
||||||
mark_step_done('users_firstboot')
|
mark_step_done('users_firstboot')
|
||||||
self.success_url = next_step()
|
self.success_url = next_step()
|
||||||
return super(State1View, self).__init__(*args, **kwargs)
|
return super(FirstBootView, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
def get_form_kwargs(self):
|
def get_form_kwargs(self):
|
||||||
"""Make request available to the form (to insert messages)"""
|
"""Make request available to the form (to insert messages)"""
|
||||||
kwargs = super(State1View, self).get_form_kwargs()
|
kwargs = super(FirstBootView, self).get_form_kwargs()
|
||||||
kwargs['request'] = self.request
|
kwargs['request'] = self.request
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user