Skip to content
This repository has been archived by the owner on Nov 12, 2022. It is now read-only.

Commit

Permalink
[carpentries#2051] Remove "during membership" constraint on membershi…
Browse files Browse the repository at this point in the history
…p calculate methods

Instead, only the link to specific membership is used.
  • Loading branch information
pbanaszkiewicz committed Sep 21, 2021
1 parent 1d9ae05 commit 93aa61f
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions amy/workshops/models.py
Expand Up @@ -314,13 +314,9 @@ def get_absolute_url(self):
def _workshops_without_admin_fee_queryset(self):
"""Provide universal queryset for looking up centrally-organised workshops for
this membership."""
during_membership = Q(
start__gte=self.agreement_start, start__lt=self.agreement_end
)
cancelled = Q(tags__name="cancelled") | Q(tags__name="stalled")
return (
Event.objects.filter(during_membership)
.filter(membership=self)
Event.objects.filter(membership=self)
.filter(administrator__in=Organization.objects.administrators())
.exclude(administrator__domain="self-organized")
.exclude(cancelled)
Expand Down Expand Up @@ -365,7 +361,7 @@ def workshops_without_admin_fee_available(self) -> int:

@cached_property
def workshops_without_admin_fee_completed(self) -> int:
"""Count centrally-organised workshops already hosted during the agreement.
"""Count centrally-organised workshops already hosted by this membership.
This value must not be higher than "contracted" (or available for counting)
no-fee workshops.
Expand All @@ -378,7 +374,7 @@ def workshops_without_admin_fee_completed(self) -> int:

@cached_property
def workshops_without_admin_fee_planned(self) -> int:
"""Count centrally-organised workshops hosted in future during the agreement.
"""Count centrally-organised workshops hosted in future by this membership.
This value must not be higher than "contracted" (or available for counting)
no-fee workshops reduced by already completed no-fee workshops.
Expand Down Expand Up @@ -423,16 +419,12 @@ def workshops_discounted_planned(self) -> int:
def _self_organized_workshops_queryset(self):
"""Provide universal queryset for looking up self-organised events for this
membership."""
during_membership = Q(
start__gte=self.agreement_start, start__lt=self.agreement_end
)
cancelled = Q(tags__name="cancelled") | Q(tags__name="stalled")
self_organized = Q(administrator=None) | Q(
administrator__domain="self-organized"
)
return (
Event.objects.filter(during_membership)
.filter(membership=self)
Event.objects.filter(membership=self)
.filter(self_organized)
.exclude(cancelled)
.distinct()
Expand Down

0 comments on commit 93aa61f

Please sign in to comment.