Revision e6759494

b/snf-astakos-app/astakos/im/models.py
50 50
from django.core.mail import send_mail
51 51
from django.db import transaction
52 52
from django.db.models.signals import post_save, post_syncdb
53
from django.db.models import Q
53 54

  
54 55
from astakos.im.settings import DEFAULT_USER_LEVEL, INVITATIONS_PER_LEVEL, \
55 56
    AUTH_TOKEN_DURATION, BILLING_FIELDS, QUEUE_CONNECTION, SITENAME, \
......
190 191
        """
191 192
        Implements a unique_together constraint for email and is_active fields.
192 193
        """
193
        q = AstakosUser.objects.exclude(username = self.username)
194
        q = AstakosUser.objects.all()
194 195
        q = q.filter(email = self.email)
195 196
        q = q.filter(is_active = self.is_active)
197
        if self.id:
198
            q = q.filter(~Q(id = self.id))
196 199
        if q.count() != 0:
197 200
            raise ValidationError({'__all__':[_('Another account with the same email & is_active combination found.')]})
198 201
    

Also available in: Unified diff