From f3a0c70d23df0136989be4310970d0d2d81ac7e4 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Wed, 14 Oct 2015 00:13:20 +0530 Subject: [PATCH] first_boot: Add separate greeting page --- plinth/modules/first_boot/forms.py | 8 +-- .../templates/firstboot_state0.html | 55 +++++++++++-------- .../templates/firstboot_state1.html | 49 +++++++++++++++++ plinth/modules/first_boot/urls.py | 3 +- plinth/modules/first_boot/views.py | 18 +++--- plinth/templates/base.html | 48 ++++++++-------- 6 files changed, 122 insertions(+), 59 deletions(-) create mode 100644 plinth/modules/first_boot/templates/firstboot_state1.html diff --git a/plinth/modules/first_boot/forms.py b/plinth/modules/first_boot/forms.py index 9a9542141..9f000dd23 100644 --- a/plinth/modules/first_boot/forms.py +++ b/plinth/modules/first_boot/forms.py @@ -28,15 +28,15 @@ from plinth.errors import ActionError from plinth.modules.users.forms import GROUP_CHOICES -class State0Form(auth.forms.UserCreationForm): - """Firstboot state 0: create a new user.""" +class State1Form(auth.forms.UserCreationForm): + """Firstboot state 1: create a new user.""" def __init__(self, *args, **kwargs): self.request = kwargs.pop('request') - super(State0Form, self).__init__(*args, **kwargs) + super(State1Form, self).__init__(*args, **kwargs) def save(self, commit=True): """Create and log the user in.""" - user = super(State0Form, self).save(commit=commit) + user = super(State1Form, self).save(commit=commit) if commit: try: actions.superuser_run( diff --git a/plinth/modules/first_boot/templates/firstboot_state0.html b/plinth/modules/first_boot/templates/firstboot_state0.html index 8d76ca2f8..44a11ba48 100644 --- a/plinth/modules/first_boot/templates/firstboot_state0.html +++ b/plinth/modules/first_boot/templates/firstboot_state0.html @@ -21,32 +21,39 @@ {% load static %} {% load bootstrap %} -{% block content %} - -

Welcome to Your FreedomBox!

- -

It looks like this {{ cfg.box_name }} isn't set up yet. Provide basic - data to get started.

- -

Choose a username and password to access this web interface. The - password can be changed and other users can be added later. An - LDAP user with administrative privileges (sudo) is also created.

- -
- {% csrf_token %} - {{ form|bootstrap }} - - -
- +{% block page_head %} + {% endblock %} -{% block sidebar %} - {% include "firstboot_sidebar.html" %} +{% block add_nav_and_login %} + {% endblock %} -{% block page_js %} - +{% block content_row %} +

+ FreedomBox +

+ +

+ Congratulations! Your FreedomBox is up and running! +

+ +

Please provide the following basic + information to complete the setup process.

+ +

+ Next +

{% endblock %} diff --git a/plinth/modules/first_boot/templates/firstboot_state1.html b/plinth/modules/first_boot/templates/firstboot_state1.html new file mode 100644 index 000000000..54fa1898b --- /dev/null +++ b/plinth/modules/first_boot/templates/firstboot_state1.html @@ -0,0 +1,49 @@ +{% extends "base.html" %} +{% comment %} +# +# This file is part of Plinth. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +{% endcomment %} + +{% load static %} +{% load bootstrap %} + +{% block content %} + +

Administrator Account

+ +

Choose a username and password to access this web interface. The + password can be changed and other users can be added later. An + LDAP user with administrative privileges (sudo) is also created.

+ +
+ {% csrf_token %} + {{ form|bootstrap }} + + +
+ +{% endblock %} + +{% block sidebar %} + {% include "firstboot_sidebar.html" %} +{% endblock %} + +{% block page_js %} + +{% endblock %} diff --git a/plinth/modules/first_boot/urls.py b/plinth/modules/first_boot/urls.py index 44448d721..88a41e6f3 100644 --- a/plinth/modules/first_boot/urls.py +++ b/plinth/modules/first_boot/urls.py @@ -22,7 +22,7 @@ URLs for the First Boot module from django.conf.urls import patterns, url from stronghold.decorators import public -from .views import State0View +from .views import State0View, State1View urlpatterns = patterns( # pylint: disable-msg=C0103 @@ -30,5 +30,6 @@ urlpatterns = patterns( # pylint: disable-msg=C0103 # Take care of the firstboot middleware when changing URLs url(r'^firstboot/$', public(State0View.as_view()), name='index'), url(r'^firstboot/state0/$', public(State0View.as_view()), name='state0'), + url(r'^firstboot/state1/$', public(State1View.as_view()), name='state1'), url(r'^firstboot/state10/$', 'state10', name='state10'), ) diff --git a/plinth/modules/first_boot/views.py b/plinth/modules/first_boot/views.py index ccdcac732..a59efef16 100644 --- a/plinth/modules/first_boot/views.py +++ b/plinth/modules/first_boot/views.py @@ -19,23 +19,27 @@ from django.contrib.auth.models import User from django.core.urlresolvers import reverse_lazy from django.shortcuts import render_to_response from django.template import RequestContext -from django.views.generic.edit import CreateView +from django.views.generic import CreateView, TemplateView from gettext import gettext as _ from plinth import kvstore -from plinth.modules.config import config -from .forms import State0Form +from .forms import State1Form -class State0View(CreateView): - """Create user account and log the user in.""" +class State0View(TemplateView): + """Show the welcome screen.""" template_name = 'firstboot_state0.html' - form_class = State0Form + + +class State1View(CreateView): + """Create user account and log the user in.""" + template_name = 'firstboot_state1.html' + form_class = State1Form success_url = reverse_lazy('first_boot:state10') def get_form_kwargs(self): """Make request available to the form (to insert messages)""" - kwargs = super(State0View, self).get_form_kwargs() + kwargs = super(State1View, self).get_form_kwargs() kwargs['request'] = self.request return kwargs diff --git a/plinth/templates/base.html b/plinth/templates/base.html index 747d7718a..abab8e792 100644 --- a/plinth/templates/base.html +++ b/plinth/templates/base.html @@ -144,33 +144,35 @@
-
- {% block submenu %} - {% if submenu %} - - {% endif %} - {% endblock %} + {% block content_row %} +
+ {% block submenu %} + {% if submenu %} + + {% endif %} + {% endblock %} - {% block sidebar %} - {# this sidebar should contain help texts but no menus #} - {% endblock %} -
+ {% block sidebar %} + {# this sidebar should contain help texts but no menus #} + {% endblock %} +
-
- {% block subsubmenu %} - {% if subsubmenu %} - {% show_subsubmenu subsubmenu %} - {% endif %} - {% endblock %} +
+ {% block subsubmenu %} + {% if subsubmenu %} + {% show_subsubmenu subsubmenu %} + {% endif %} + {% endblock %} - {% include 'messages.html' %} + {% include 'messages.html' %} - {% block content %} - {# main content goes here #} - {% endblock %} -
+ {% block content %} + {# main content goes here #} + {% endblock %} +
+ {% endblock %}