first_boot: Don't ask for a new hostname

- Setting a new hostname is not one of the most buring issues to be take
  care of during the setup process.

- Also, most likely the user will access the FreedomBox machine using
  mDNS hostname such as freedombox.local.  Changing the hostname mid
  setup might have consequences that need to thought about properly.
This commit is contained in:
Sunil Mohan Adapa 2015-10-13 21:26:14 +05:30 committed by James Valleroy
parent 125cb88336
commit 62185a5960
2 changed files with 8 additions and 22 deletions

View File

@ -15,9 +15,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
Forms for first boot module.
"""
from django import forms
from django.contrib import auth, messages
from django.core import validators
from gettext import gettext as _
from plinth import actions
@ -27,25 +30,14 @@ from plinth.modules.users.forms import GROUP_CHOICES
class State0Form(forms.ModelForm):
"""Firstboot state 0: Set hostname and create a new user"""
hostname = forms.CharField(
label=_('Name of your FreedomBox'),
help_text=_('For convenience, your FreedomBox needs a name. It \
should be something short that does not contain spaces or punctuation. \
"Willard" would be a good name while "Freestyle McFreedomBox!!!" would \
not. It must be alphanumeric, start with an alphabet and must not be greater \
than 63 characters in length.'),
validators=[
validators.RegexValidator(r'^[a-zA-Z][a-zA-Z0-9]{,62}$',
_('Invalid hostname'))])
"""Firstboot state 0: create a new user."""
def __init__(self, *args, **kwargs):
self.request = kwargs.pop('request')
super(State0Form, self).__init__(*args, **kwargs)
class Meta:
model = auth.models.User
fields = ('hostname', 'username', 'password')
fields = ('username', 'password')
widgets = {
'password': forms.PasswordInput,
}
@ -58,8 +50,7 @@ than 63 characters in length.'),
}
def save(self, commit=True):
"""Set hostname, create and login the user"""
config.set_hostname(self.cleaned_data['hostname'])
"""Create and log the user in."""
user = super(State0Form, self).save(commit=False)
user.set_password(self.cleaned_data['password'])
if commit:

View File

@ -28,16 +28,11 @@ from .forms import State0Form
class State0View(CreateView):
"""Setup hostname and create user account"""
"""Create user account and log the user in."""
template_name = 'firstboot_state0.html'
form_class = State0Form
success_url = reverse_lazy('first_boot:state10')
def get_initial(self):
initial = super(State0View, self).get_initial()
initial['hostname'] = config.get_hostname()
return initial
def get_form_kwargs(self):
"""Make request available to the form (to insert messages)"""
kwargs = super(State0View, self).get_form_kwargs()