Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix team permissions backend not pulling out manager_permissions #142

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions symposion/teams/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,27 @@ def get_team_permissions(self, user_obj, obj=None):
if user_obj.is_anonymous() or obj is not None:
return set()
if not hasattr(user_obj, "_team_perm_cache"):
# Member permissions
memberships = Team.objects.filter(
Q(memberships__user=user_obj),
Q(memberships__state="manager") | Q(memberships__state="member"),
Q(memberships__state="member"),
)
perms = memberships.values_list(
"permissions__content_type__app_label",
"permissions__codename"
).order_by()
user_obj._team_perm_cache = set(["%s.%s" % (ct, name) for ct, name in perms])
permissions = ["%s.%s" % (ct, name) for ct, name in perms]
# Manager permissions
memberships = Team.objects.filter(
Q(memberships__user=user_obj),
Q(memberships__state="manager"),
)
perms = memberships.values_list(
"manager_permissions__content_type__app_label",
"manager_permissions__codename"
).order_by()
permissions += ["%s.%s" % (ct, name) for ct, name in perms]
user_obj._team_perm_cache = set(permissions)
return user_obj._team_perm_cache

def has_perm(self, user_obj, perm, obj=None):
Expand Down