Fixed errors with systemuser form and serializer
This commit is contained in:
parent
a0b531ed68
commit
fd6c7975a0
|
@ -75,20 +75,18 @@ class SystemUser(models.Model):
|
|||
super(SystemUser, self).save(*args, **kwargs)
|
||||
|
||||
def clean(self):
|
||||
# TODO do it right
|
||||
if self.has_shell and self.directory:
|
||||
if self.directory:
|
||||
directory_error = None
|
||||
if self.has_shell:
|
||||
directory_error = _("Directory with shell users can not be specified.")
|
||||
elif self.pk and self.is_main:
|
||||
directory_error = _("Directory with main system users can not be specified.")
|
||||
elif self.home == self.get_base_home():
|
||||
directory_error = _("Directory on the user's base home is not allowed.")
|
||||
if directory_error:
|
||||
raise ValidationError({
|
||||
'directory': _("Directory with shell users can not be specified.")
|
||||
'directory': directory_error,
|
||||
})
|
||||
if self.pk and self.is_main and self.directory:
|
||||
raise ValidationError({
|
||||
'directory': _("Directory with main system users can not be specified.")
|
||||
})
|
||||
if self.home == self.get_base_home() and self.directory:
|
||||
raise ValidationError({
|
||||
'directory': _("Directory on the user's base home is not allowed.")
|
||||
})
|
||||
# TODO valid home exists
|
||||
|
||||
def set_password(self, raw_password):
|
||||
self.password = make_password(raw_password)
|
||||
|
|
Loading…
Reference in a new issue