Skip to content
Snippets Groups Projects
Verified Commit e2a9ac59 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Adjust permissions for instructions

parent 282a206f
No related branches found
No related tags found
1 merge request!215Draft: Resolve "Instructions can be linked to a document as remarks by the group"
......@@ -531,7 +531,8 @@ class Instruction(SchoolTermRelatedExtensibleModel):
null=True,
verbose_name=_("Groups"),
help_text=_(
"The instruction will be shown for the members and owners of the selected groups."
"The instruction will be shown for the members and owners of the selected groups. "
"Leave empty to show for all groups."
),
related_name="instructions",
)
......
......@@ -288,13 +288,15 @@ def is_owner_of_any_group(user: User, obj):
def has_any_instruction(user: User, obj):
"""Predicate which checks if the user has any instruction."""
return Instruction.objects.filter(
Q(groups__members=user.person) | Q(groups__owners=user.person)
Q(groups__members=user.person) | Q(groups__owners=user.person) | Q(groups__isnull=False)
).exists()
@predicate
def is_instruction_for_person(user: User, obj: Instruction):
"""Predicate which checks if the instruction is for the person."""
if not obj.groups.all():
return True
return (
user
in Person.objects.filter(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment