diff --git a/machines/views.py b/machines/views.py index 059d938b..9883f011 100644 --- a/machines/views.py +++ b/machines/views.py @@ -90,7 +90,7 @@ def new_machine(request, userid): machine = NewMachineForm(request.POST or None) interface = AddInterfaceForm(request.POST or None, infra=request.user.has_perms(('infra',))) nb_machine = Interface.objects.filter(machine__user=userid).count() - domain = DomainForm(request.POST or None, name_user=user.surname, nb_machine=nb_machine) + domain = DomainForm(request.POST or None, name_user=user.pseudo.replace('_','-'), nb_machine=nb_machine) if machine.is_valid() and interface.is_valid(): new_machine = machine.save(commit=False) new_machine.user = user diff --git a/users/models.py b/users/models.py index 472e02ba..41eb969a 100644 --- a/users/models.py +++ b/users/models.py @@ -58,7 +58,7 @@ def remove_user_room(room): def linux_user_check(login): """ Validation du pseudo pour respecter les contraintes unix""" - UNIX_LOGIN_PATTERN = re.compile("^[a-zA-Z0-9_-]*[$]?$") + UNIX_LOGIN_PATTERN = re.compile("^[a-zA-Z0-9-]*[$]?$") return UNIX_LOGIN_PATTERN.match(login) @@ -111,7 +111,7 @@ class UserManager(BaseUserManager): raise ValueError('Users must have an username') if not linux_user_check(pseudo): - raise ValueError('Username shall only contain [a-z0-9_-]') + raise ValueError('Username shall only contain [a-z0-9-]') user = self.model( pseudo=pseudo,