-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Filtrer så deltagere ikke vises (dvs hvis man har tilmeldt sig efter modtaget invitation).
- Loading branch information
Showing
3 changed files
with
32 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from django.utils import timezone | ||
from django.db.models import OuterRef, Exists | ||
|
||
from members.models.activityinvite import ActivityInvite | ||
from members.models.activityparticipant import ActivityParticipant | ||
|
||
|
||
def get_unaccepted_invitations_for_family(family_id): | ||
participant_subquery = ActivityParticipant.objects.filter( | ||
person__family_id=family_id, | ||
person_id=OuterRef("person_id"), | ||
activity_id=OuterRef("activity_id"), | ||
) | ||
|
||
# Get invitations where the participant record does not exist | ||
unaccepted_invitations = ( | ||
ActivityInvite.objects.filter( | ||
person__family_id=family_id, | ||
expire_dtm__gte=timezone.now(), | ||
rejected_at=None, | ||
) | ||
.annotate(is_participant=Exists(participant_subquery)) | ||
.filter(is_participant=False) | ||
) | ||
|
||
return unaccepted_invitations |