Revision 304acb60 snf-astakos-app/astakos/im/models.py

b/snf-astakos-app/astakos/im/models.py
42 42
from urlparse import urlparse, urlunparse
43 43
from random import randint
44 44
from collections import defaultdict
45
from south.signals import post_migrate
45 46

  
46 47
from django.db import models, IntegrityError
47 48
from django.contrib.auth.models import User, UserManager, Group
......
51 52
from django.core.mail import send_mail
52 53
from django.db import transaction
53 54
from django.db.models.signals import post_save, post_syncdb
54
from django.db.models import Q
55
from django.db.models import Q, Count
55 56

  
56 57
from astakos.im.settings import DEFAULT_USER_LEVEL, INVITATIONS_PER_LEVEL, \
57 58
    AUTH_TOKEN_DURATION, BILLING_FIELDS, QUEUE_CONNECTION, SITENAME, \
......
236 237
        super(AstakosUser, self).__init__(*args, **kwargs)
237 238
        self.__has_signed_terms = self.has_signed_terms
238 239
        if self.id:
239
            self.__groupnames = [g.name for g in self.groups.all()]
240
            self.__groupnames = [g.name for g in self.astakos_groups.all()]
240 241
        else:
241 242
            self.is_active = False
242 243
    
......
305 306
        groupname = 'shibboleth' if self.provider == 'shibboleth' else 'default'
306 307
        if groupname not in self.__groupnames:
307 308
            try:
308
                group = Group.objects.get(name = groupname)
309
                self.groups.add(group)
310
            except Group.DoesNotExist, e:
309
                group = AstakosGroup.objects.get(name = groupname)
310
                Membership(group=group, person=self, date_joined=datetime.now()).save()
311
            except AstakosGroup.DoesNotExist, e:
311 312
                logger.exception(e)
312 313
    
313 314
    def renew_token(self):

Also available in: Unified diff