diff --git a/aleksis/apps/alsijil/models.py b/aleksis/apps/alsijil/models.py index ee3b88386bc7a2f61f9752ea97699b8b1b58e91d..f5ac8659030daaa78a29e7bb678aa99ffea31c5d 100644 --- a/aleksis/apps/alsijil/models.py +++ b/aleksis/apps/alsijil/models.py @@ -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", ) diff --git a/aleksis/apps/alsijil/util/predicates.py b/aleksis/apps/alsijil/util/predicates.py index 377779d30e9c01de09f48f8befd9921326dcb010..8ba62985253388ba74f872a8568dc74112699eff 100644 --- a/aleksis/apps/alsijil/util/predicates.py +++ b/aleksis/apps/alsijil/util/predicates.py @@ -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(