Skip to content

Commit

Permalink
fix: don't allow access if block is content grouped and user is not
Browse files Browse the repository at this point in the history
  • Loading branch information
mariajgrimaldi committed Jan 23, 2024
1 parent 0f37a6e commit 4ee64b0
Showing 1 changed file with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ class TeamPartitionGroupsOutlineProcessor(OutlineProcessor):
"""
def __init__(self, course_key: CourseKey, user: types.User, at_time: datetime):
super().__init__(course_key, user, at_time)
self.team_groups: Dict[str, Group] = {}
self.user_group = None
self.user_groups: List[int] = []
self.current_user_groups: Dict[str, Group] = {}

def load_data(self, _) -> None:
"""
Expand All @@ -39,15 +37,12 @@ def load_data(self, _) -> None:
return

user_partitions = create_team_set_partition_with_course_id(self.course_key)
self.team_groups = get_user_partition_groups(
self.current_user_groups = get_user_partition_groups(
self.course_key,
user_partitions,
self.user,
partition_dict_key="id",
)
self.user_groups = []
for _, group in self.team_groups.items():
self.user_groups.append(group.id)

def _is_user_excluded_by_partition_group(self, user_partition_groups):
"""
Expand All @@ -63,13 +58,10 @@ def _is_user_excluded_by_partition_group(self, user_partition_groups):
if not user_partition_groups:
return False

if not self.user_groups:
return False

for partition_id, groups in user_partition_groups.items():
if partition_id not in self.team_groups:
if partition_id not in self.current_user_groups:
continue
if self.team_groups[partition_id].id in groups:
if self.current_user_groups[partition_id].id in groups:
return False

return True
Expand Down

0 comments on commit 4ee64b0

Please sign in to comment.