Skip to content

Commit a37f5e1

Browse files
authoredMar 10, 2025
Fixed permission checking bug
Variable name reuse caused the permission check for one forum to influence the one after it.
1 parent 2a14383 commit a37f5e1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed
 

‎machina/apps/forum_permission/checker.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def get_perms_for_forumlist(self, forums, perm_codenames=None):
184184
# - not set to non-granted on global-user level
185185
# - and not set to non-granted on forum-group level
186186
# - and not set to non-granted on forum-user level
187-
globally_granted_group_perms = list(
187+
forum_globally_granted_group_perms = list(
188188
filter(lambda p: p.has_perm and p.forum_id is None and
189189
p.permission_id not in
190190
[q.permission_id for q in globally_nongranted_user_perms] and
@@ -195,14 +195,14 @@ def get_perms_for_forumlist(self, forums, perm_codenames=None):
195195
globally_granted_group_perms)
196196
)
197197
globally_granted_group_permcodes = [
198-
p.permission.codename for p in globally_granted_group_perms
198+
p.permission.codename for p in forum_globally_granted_group_perms
199199
]
200200

201201
# Filter the globally non granted group perms to those that were:
202202
# - not set to granted on global- user level
203203
# - and not set to granted on forum-group level
204204
# - and not set to granted on forum-user level
205-
globally_nongranted_group_perms = list(
205+
forum_globally_nongranted_group_perms = list(
206206
filter(lambda p: not p.has_perm and p.forum_id is None and
207207
p.permission_id not in
208208
[q.permission_id for q in globally_granted_user_perms] and
@@ -251,7 +251,7 @@ def get_perms_for_forumlist(self, forums, perm_codenames=None):
251251
# - and not set to non-granted on global-group level
252252
# - and not set to non-granted on forum-group level
253253
# - and not set to non-granted on forum-user level
254-
globally_granted_all_users_perms = list(
254+
forum_globally_granted_all_users_perms = list(
255255
filter(lambda p: p.has_perm and p.forum_id is None and
256256
p.permission_id not in
257257
[y.permission_id for y in per_forum_nongranted_all_users_perms] and
@@ -266,7 +266,7 @@ def get_perms_for_forumlist(self, forums, perm_codenames=None):
266266
globally_granted_all_users_perms)
267267
)
268268
globally_granted_all_users_permcodes = [
269-
p.permission.codename for p in globally_granted_all_users_perms
269+
p.permission.codename for p in forum_globally_granted_all_users_perms
270270
]
271271
granted_all_users_permcodes = set(globally_granted_all_users_permcodes +
272272
per_forum_granted_all_users_permcodes)

0 commit comments

Comments
 (0)