Minor styling changes in first boot module

This commit is contained in:
Sunil Mohan Adapa 2014-10-20 00:05:15 +05:30
parent 4637bba3eb
commit 0bb2dd51d8
6 changed files with 22 additions and 16 deletions

View File

@ -142,9 +142,12 @@ def get_modules_to_load():
modules = [] modules = []
module_directory = os.path.join(cfg.config_dir, 'modules-enabled') module_directory = os.path.join(cfg.config_dir, 'modules-enabled')
# omit hidden files
file_names = [f for f in os.listdir(module_directory) if not # Omit hidden files
f.startswith(".")] file_names = [file
for file in os.listdir(module_directory)
if not file.startswith('.')]
for file_name in file_names: for file_name in file_names:
full_file_name = os.path.join(module_directory, file_name) full_file_name = os.path.join(module_directory, file_name)
with open(full_file_name, 'r') as file: with open(full_file_name, 'r') as file:

View File

@ -25,29 +25,29 @@ than 63 characters in length.'),
class Meta: class Meta:
model = auth.models.User model = auth.models.User
fields = ("hostname", "username", "password") fields = ('hostname', 'username', 'password')
widgets = { widgets = {
'password': forms.PasswordInput, 'password': forms.PasswordInput,
} }
help_texts = { help_texts = {
'username': 'Choose a username and password to access this web\ 'username': _('Choose a username and password to access this web\
interface. The password can be changed and other users can\ interface. The password can be changed and other users can be added later.'),
be added later.',
} }
def save(self, commit=True): def save(self, commit=True):
"""Set hostname, create and login the user""" """Set hostname, create and login the user"""
config.set_hostname(self.cleaned_data['hostname']) config.set_hostname(self.cleaned_data['hostname'])
user = super(State0Form, self).save(commit=False) user = super(State0Form, self).save(commit=False)
user.set_password(self.cleaned_data["password"]) user.set_password(self.cleaned_data['password'])
user.is_expert = True user.is_expert = True
if commit: if commit:
user.save() user.save()
self.login_user() self.login_user()
return user return user
def login_user(self): def login_user(self):
"""Try to login the user with the credentials he provided""" """Try to login the user with the credentials provided"""
try: try:
user = auth.authenticate(username=self.request.POST['username'], user = auth.authenticate(username=self.request.POST['username'],
password=self.request.POST['password']) password=self.request.POST['password'])
@ -55,5 +55,5 @@ than 63 characters in length.'),
except Exception: except Exception:
pass pass
else: else:
msg = _('User account created, you are now logged in') message = _('User account created, you are now logged in')
messages.success(self.request, msg) messages.success(self.request, message)

View File

@ -35,6 +35,7 @@ class FirstBootMiddleware(object):
@staticmethod @staticmethod
def process_request(request): def process_request(request):
"""Handle a request as Django middleware request handler."""
state = kvstore.get_default('firstboot_state', 0) state = kvstore.get_default('firstboot_state', 0)
firstboot_index_url = reverse('first_boot:index') firstboot_index_url = reverse('first_boot:index')
user_requests_firstboot = request.path.startswith(firstboot_index_url) user_requests_firstboot = request.path.startswith(firstboot_index_url)

View File

@ -1,11 +1,13 @@
/* TODO: remove this when we stop putting everything in a hero unit */
form .control-label { form .control-label {
font-size: large; font-size: large;
} }
form .help-block { form .help-block {
font-size: small; font-size: small;
} }
/* TODO: remove this customization once we use bootstrap3 */ /* TODO: remove this customization once we use bootstrap3 */
.has-error span.help-block { .has-error span.help-block {
background-color: red; color: red;
} }

View File

@ -29,8 +29,8 @@
<h2>Welcome to Your FreedomBox!</h2> <h2>Welcome to Your FreedomBox!</h2>
<p>It looks like this FreedomBox isn't set up yet. We <p>It looks like this {{ cfg.box_name }} isn't set up yet. Provide basic
need to ask you a few questions to get started.</p> data to get started.</p>
<br> <br>
<form class="form" method="post"> <form class="form" method="post">

View File

@ -23,7 +23,7 @@
{% block main_block %} {% block main_block %}
{% if user.is_authenticated %} {% if user.is_authenticated %}
<p>Have fun with your freedombox!</p> <p>Have fun with your {{ cfg.box_name }}!</p>
{% else %} {% else %}
<p>Proceed to <a href="{% url 'lib:login' %}">login</a>.</p> <p>Proceed to <a href="{% url 'lib:login' %}">login</a>.</p>
{% endif %} {% endif %}