Revision aa4109d4 snf-astakos-app/astakos/im/management/commands/user_add.py

b/snf-astakos-app/astakos/im/management/commands/user_add.py
37 37
from random import choice
38 38
from string import digits, lowercase, uppercase
39 39
from uuid import uuid4
40
from datetime import datetime
40 41

  
41 42
from django.core.management.base import BaseCommand, CommandError
42 43
from django.core.validators import validate_email
43 44
from django.core.exceptions import ValidationError
44 45

  
45
from astakos.im.models import AstakosUser, AstakosGroup
46
from astakos.im.models import AstakosUser, AstakosGroup, Membership
46 47
from astakos.im.util import reserved_email
47 48

  
48 49
from ._common import add_user_permission
......
121 122
            if groupname is not None:
122 123
                try:
123 124
                    group = AstakosGroup.objects.get(name=groupname)
124
                    user.astakos_groups.add(group)
125
                    Membership(group=group, person=user, date_joined=datetime.now()).save()
125 126
                    self.stdout.write('Group: %s added successfully\n' % groupname)
126 127
                except AstakosGroup.DoesNotExist, e:
127 128
                    self.stdout.write('Group named %s does not exist\n' % groupname)

Also available in: Unified diff