add customer field to osusers.models.User
- allow association of os users to Django users (customers) - adapt admin forms - add migration
This commit is contained in:
parent
39fd326ac2
commit
18e47d73b4
4 changed files with 31 additions and 4 deletions
|
@ -104,7 +104,9 @@ class UserManager(models.Manager):
|
|||
return nextuser
|
||||
|
||||
@transaction.atomic
|
||||
def create_user(self, username=None, password=None, commit=False):
|
||||
def create_user(
|
||||
self, customer, username=None, password=None, commit=False
|
||||
):
|
||||
uid = self.get_next_uid()
|
||||
gid = Group.objects.get_next_gid()
|
||||
if username is None:
|
||||
|
@ -114,7 +116,7 @@ class UserManager(models.Manager):
|
|||
homedir = os.path.join(settings.OSUSER_HOME_BASEPATH, username)
|
||||
group = Group.objects.create(groupname=username, gid=gid)
|
||||
user = self.create(username=username, group=group, uid=uid,
|
||||
homedir=homedir,
|
||||
homedir=homedir, customer=customer,
|
||||
shell=settings.OSUSER_DEFAULT_SHELL)
|
||||
user.set_password(password)
|
||||
if commit:
|
||||
|
@ -132,6 +134,7 @@ class User(TimeStampedModel, models.Model):
|
|||
gecos = models.CharField(_('Gecos field'), max_length=128, blank=True)
|
||||
homedir = models.CharField(_('Home directory'), max_length=256)
|
||||
shell = models.CharField(_('Login shell'), max_length=64)
|
||||
customer = models.ForeignKey(settings.AUTH_USER_MODEL)
|
||||
|
||||
objects = UserManager()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue