mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
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:
parent
125cb88336
commit
62185a5960
@ -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:
|
||||
|
||||
@ -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()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user