Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[per-object-permissions] Fixes MySQL error caused by when a user is n…

…ot a member of a group

git-svn-id: http://code.djangoproject.com/svn/django/branches/per-object-permissions@3753 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 43260cfbf2d9f42f66ad60110152fc9cece27908 1 parent 00972e6
Christopher Long authored
Showing with 9 additions and 6 deletions.
  1. +9 −6 django/contrib/auth/models.py
View
15 django/contrib/auth/models.py
@@ -80,12 +80,15 @@ def get_model_list(self,user, model, perm):
owner_id=user.id, permission=perm.id,
model_ct=model_ct
).values('model_id')
- user_group_list = [g['id'] for g in user.groups.select_related().values('id')]
- group_model_ids = RowLevelPermission.objects.filter(owner_ct=ContentType.objects.get_for_model(Group).id,
- owner_id__in=user_group_list,
- model_ct = model_ct
- ).values('model_id')
- id_list = [o['model_id'] for o in user_model_ids] + [o['model_id'] for o in group_model_ids]
+ id_list = [o['model_id'] for o in user_model_ids]
+
+ user_group_list = [g['id'] for g in user.groups.select_related().values('id')]
+ if user_group_list:
+ group_model_ids = RowLevelPermission.objects.filter(owner_ct=ContentType.objects.get_for_model(Group).id,
+ owner_id__in=user_group_list,
+ model_ct = model_ct
+ ).values('model_id')
+ id_list.append([o['model_id'] for o in group_model_ids])
return id_list
class RowLevelPermission(models.Model):
Please sign in to comment.
Something went wrong with that request. Please try again.