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)
|
super(SystemUser, self).save(*args, **kwargs)
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
# TODO do it right
|
if self.directory:
|
||||||
if self.has_shell and self.directory:
|
directory_error = None
|
||||||
raise ValidationError({
|
if self.has_shell:
|
||||||
'directory': _("Directory with shell users can not be specified.")
|
directory_error = _("Directory with shell users can not be specified.")
|
||||||
})
|
elif self.pk and self.is_main:
|
||||||
if self.pk and self.is_main and self.directory:
|
directory_error = _("Directory with main system users can not be specified.")
|
||||||
raise ValidationError({
|
elif self.home == self.get_base_home():
|
||||||
'directory': _("Directory with main system users can not be specified.")
|
directory_error = _("Directory on the user's base home is not allowed.")
|
||||||
})
|
if directory_error:
|
||||||
if self.home == self.get_base_home() and self.directory:
|
raise ValidationError({
|
||||||
raise ValidationError({
|
'directory': directory_error,
|
||||||
'directory': _("Directory on the user's base home is not allowed.")
|
})
|
||||||
})
|
|
||||||
# TODO valid home exists
|
|
||||||
|
|
||||||
def set_password(self, raw_password):
|
def set_password(self, raw_password):
|
||||||
self.password = make_password(raw_password)
|
self.password = make_password(raw_password)
|
||||||
|
|
Loading…
Reference in New Issue