Skip to content

Commit 37c477a

Browse files
authored
Merge pull request #30 from renderbox/update_perm_query
Update group permissions query
2 parents 8c9fdf0 + b85d0cc commit 37c477a

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

permafrost/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = "0.2.10"
1+
VERSION = "0.2.11"

permafrost/backends.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@
55

66
class GroupSiteModelBackendMixin():
77

8-
def _get_group_permissions(self, user_obj):
8+
def _get_group_permissions(self, user_obj, obj=None, site=None):
99
'''
1010
Adds the SiteID for filtering Groups
1111
'''
12-
current_site = Site.objects.get_current()
12+
if site:
13+
current_site = site
14+
else:
15+
current_site = Site.objects.get_current()
16+
1317
user_groups_field = get_user_model()._meta.get_field('groups')
1418
user_groups_query = 'group__%s' % user_groups_field.related_query_name()
1519

16-
return Permission.objects.filter(**{user_groups_query: user_obj}).filter(group__permafrost_role__site=current_site) # TODO: Should it return Groups that do not have a Permafrost Role also?
20+
return Permission.objects.filter(**{user_groups_query: user_obj}, group__permafrost_role__site=current_site) # TODO: Should it return Groups that do not have a Permafrost Role also?
1721

1822

1923
class PermafrostModelBackend(GroupSiteModelBackendMixin, ModelBackend):

0 commit comments

Comments
 (0)