membershipworks: Expose EventExtQuerySet methods on EventExtManager
This commit is contained in:
parent
0eab482893
commit
21fe7f66cd
@ -448,32 +448,37 @@ class EventExtQuerySet(models.QuerySet["EventExt"]):
|
|||||||
|
|
||||||
class EventExtManager(models.Manager["EventExt"]):
|
class EventExtManager(models.Manager["EventExt"]):
|
||||||
def get_queryset(self) -> models.QuerySet["EventExt"]:
|
def get_queryset(self) -> models.QuerySet["EventExt"]:
|
||||||
return EventExtQuerySet(self.model, using=self._db).annotate(
|
return (
|
||||||
meeting_times__count=Subquery(
|
super()
|
||||||
EventMeetingTime.objects.filter(event=OuterRef("pk"))
|
.get_queryset()
|
||||||
.values("event__pk")
|
.annotate(
|
||||||
.annotate(d=Count("pk"))
|
meeting_times__count=Subquery(
|
||||||
.values("d")[:1],
|
EventMeetingTime.objects.filter(event=OuterRef("pk"))
|
||||||
output_field=models.IntegerField(),
|
.values("event__pk")
|
||||||
),
|
.annotate(d=Count("pk"))
|
||||||
duration=Subquery(
|
.values("d")[:1],
|
||||||
EventMeetingTime.objects.filter(event=OuterRef("pk"))
|
output_field=models.IntegerField(),
|
||||||
.values("event__pk")
|
),
|
||||||
.annotate(d=Sum("duration"))
|
duration=Subquery(
|
||||||
.values("d")[:1],
|
EventMeetingTime.objects.filter(event=OuterRef("pk"))
|
||||||
output_field=models.DurationField(),
|
.values("event__pk")
|
||||||
),
|
.annotate(d=Sum("duration"))
|
||||||
person_hours=ExpressionWrapper(
|
.values("d")[:1],
|
||||||
ExpressionWrapper(F("duration"), models.IntegerField()) * F("count"),
|
output_field=models.DurationField(),
|
||||||
models.DurationField(),
|
),
|
||||||
),
|
person_hours=ExpressionWrapper(
|
||||||
|
ExpressionWrapper(F("duration"), models.IntegerField())
|
||||||
|
* F("count"),
|
||||||
|
models.DurationField(),
|
||||||
|
),
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class EventExt(Event):
|
class EventExt(Event):
|
||||||
"""Extension of `Event` to capture some fields not supported in MembershipWorks"""
|
"""Extension of `Event` to capture some fields not supported in MembershipWorks"""
|
||||||
|
|
||||||
objects = EventExtManager()
|
objects = EventExtManager.from_queryset(EventExtQuerySet)()
|
||||||
|
|
||||||
instructor = models.ForeignKey(
|
instructor = models.ForeignKey(
|
||||||
EventInstructor, on_delete=models.PROTECT, null=True, blank=True
|
EventInstructor, on_delete=models.PROTECT, null=True, blank=True
|
||||||
|
Loading…
Reference in New Issue
Block a user