Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[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
authored September 12, 2006

Showing 1 changed file with 9 additions and 6 deletions. Show diff stats Hide diff stats

  1. 15  django/contrib/auth/models.py
15  django/contrib/auth/models.py
@@ -80,12 +80,15 @@ def get_model_list(self,user, model, perm):
80 80
                                           owner_id=user.id, permission=perm.id, 
81 81
                                           model_ct=model_ct
82 82
                                           ).values('model_id')   
83  
-        user_group_list = [g['id'] for g in user.groups.select_related().values('id')]
84  
-        group_model_ids = RowLevelPermission.objects.filter(owner_ct=ContentType.objects.get_for_model(Group).id,
85  
-                                          owner_id__in=user_group_list,
86  
-                                          model_ct = model_ct
87  
-                                          ).values('model_id')
88  
-        id_list = [o['model_id'] for o in user_model_ids] + [o['model_id'] for o in group_model_ids]
  83
+        id_list = [o['model_id'] for o in user_model_ids]        
  84
+        
  85
+        user_group_list = [g['id'] for g in user.groups.select_related().values('id')]        
  86
+        if user_group_list:
  87
+            group_model_ids = RowLevelPermission.objects.filter(owner_ct=ContentType.objects.get_for_model(Group).id,
  88
+                                                  owner_id__in=user_group_list,
  89
+                                                  model_ct = model_ct
  90
+                                                  ).values('model_id')
  91
+            id_list.append([o['model_id'] for o in group_model_ids])
89 92
         return id_list
90 93
 
91 94
 class RowLevelPermission(models.Model):

0 notes on commit 43260cf

Please sign in to comment.
Something went wrong with that request. Please try again.