first_boot: Add separate greeting page

This commit is contained in:
Sunil Mohan Adapa 2015-10-14 00:13:20 +05:30 committed by James Valleroy
parent 23eb40fce8
commit f3a0c70d23
6 changed files with 122 additions and 59 deletions

View File

@ -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(

View File

@ -21,32 +21,39 @@
{% load static %}
{% load bootstrap %}
{% block content %}
<h2>Welcome to Your FreedomBox!</h2>
<p>It looks like this {{ cfg.box_name }} isn't set up yet. Provide basic
data to get started.</p>
<p>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.</p>
<form class="form" method="post">
{% csrf_token %}
{{ form|bootstrap }}
<input type="submit" class="btn btn-primary" value="Box it up!"/>
</form>
{% block page_head %}
<style type="text/css">
.navbar-brand {
display: none;
}
</style>
{% endblock %}
{% block sidebar %}
{% include "firstboot_sidebar.html" %}
{% block add_nav_and_login %}
<ul class="nav navbar-nav navbar-right">
<li>
<a href="{% url 'help:index' %}">
<span class="glyphicon-question-sign glyphicon nav-icon"></span>
</a>
</li>
</ul>
{% endblock %}
{% block page_js %}
<script>
$('#id_hostname').focus();
</script>
{% block content_row %}
<p class="text-center">
<img src="{% static 'theme/img/FreedomBox-logo-standard.png' %}"
alt="FreedomBox" width="640"/>
</p>
<h3 class="text-center">
Congratulations! Your FreedomBox is up and running!
</h3>
<p class="text-center">Please provide the following basic
information to complete the setup process.</p>
<p class="text-center">
<a href="{% url 'first_boot:state1' %}"
class="btn btn-primary btn-large">Next</a>
</p>
{% endblock %}

View File

@ -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 <http://www.gnu.org/licenses/>.
#
{% endcomment %}
{% load static %}
{% load bootstrap %}
{% block content %}
<h2>Administrator Account</h2>
<p>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.</p>
<form class="form" method="post">
{% csrf_token %}
{{ form|bootstrap }}
<input type="submit" class="btn btn-primary" value="Box it up!"/>
</form>
{% endblock %}
{% block sidebar %}
{% include "firstboot_sidebar.html" %}
{% endblock %}
{% block page_js %}
<script>
$('#id_hostname').focus();
</script>
{% endblock %}

View File

@ -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'),
)

View File

@ -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

View File

@ -144,33 +144,35 @@
<div class="container-fluid">
<div class="row">
<div class="col-md-3">
{% block submenu %}
{% if submenu %}
<div class="sidebar">
{% include "submenu.html" with menu=submenu %}
</div><!--/.sidebar -->
{% endif %}
{% endblock %}
{% block content_row %}
<div class="col-md-3">
{% block submenu %}
{% if submenu %}
<div class="sidebar">
{% include "submenu.html" with menu=submenu %}
</div><!--/.sidebar -->
{% endif %}
{% endblock %}
{% block sidebar %}
{# this sidebar should contain help texts but no menus #}
{% endblock %}
</div>
{% block sidebar %}
{# this sidebar should contain help texts but no menus #}
{% endblock %}
</div>
<div class="col-md-9">
{% block subsubmenu %}
{% if subsubmenu %}
{% show_subsubmenu subsubmenu %}
{% endif %}
{% endblock %}
<div class="col-md-9">
{% block subsubmenu %}
{% if subsubmenu %}
{% show_subsubmenu subsubmenu %}
{% endif %}
{% endblock %}
{% include 'messages.html' %}
{% include 'messages.html' %}
{% block content %}
{# main content goes here #}
{% endblock %}
</div><!--/col-->
{% block content %}
{# main content goes here #}
{% endblock %}
</div><!--/col-->
{% endblock %}
</div><!--/row-->
<hr>