Skip to content

Commit

Permalink
Bug #516 дублирование пользователей при выборке только внутренних/вне…
Browse files Browse the repository at this point in the history
…шних

То, что мы считали багом связки django ORM+MySQL, оказалось всего лишь особенностью выполнения такого типа запросов.
  • Loading branch information
Roman Petrichev committed Jul 5, 2012
1 parent 3b50250 commit 6a643df
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions exmo/exmo2010/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,19 +604,25 @@ class ExtUPManager(models.Manager):
Выдает только внешних пользователей.
"""
def get_query_set(self):
return super(ExtUPManager, self).get_query_set().exclude\
(user__is_superuser=True).exclude(user__is_staff=True).exclude\
(user__groups__name__in=UserProfile.expert_groups)
return super(ExtUPManager, self).\
get_query_set().\
exclude(user__is_superuser=True).\
exclude(user__is_staff=True).\
exclude(user__groups__name__in=UserProfile.expert_groups).\
distinct()


class IntUPManager(models.Manager):
"""
Выдает только внутренних пользователей.
"""
def get_query_set(self):
return super(IntUPManager, self).get_query_set().filter\
(Q(user__is_superuser=True) | Q(user__is_staff=True) | Q\
(user__groups__name__in=UserProfile.expert_groups))
return super(IntUPManager, self).\
get_query_set().\
filter(Q(user__is_superuser=True) |
Q(user__is_staff=True) |
Q(user__groups__name__in=UserProfile.expert_groups)).\
distinct()


class UserProfile(models.Model):
Expand Down

0 comments on commit 6a643df

Please sign in to comment.