membershipworks: Indicate in admin events with meeting times not matching event start/end
This commit is contained in:
parent
2cc6f9d2e0
commit
5d98e300ea
@ -169,6 +169,7 @@ class EventAdmin(DjangoObjectActions, admin.ModelAdmin):
|
||||
"count",
|
||||
"cap",
|
||||
"category",
|
||||
"meeting_times_match_event",
|
||||
]
|
||||
list_filter = [
|
||||
"category",
|
||||
@ -196,6 +197,7 @@ class EventAdmin(DjangoObjectActions, admin.ModelAdmin):
|
||||
"instructor_flat_rate",
|
||||
("should_survey", "survey_email_sent"),
|
||||
"links",
|
||||
"meeting_times_match_event",
|
||||
]
|
||||
},
|
||||
),
|
||||
@ -234,6 +236,9 @@ class EventAdmin(DjangoObjectActions, admin.ModelAdmin):
|
||||
)
|
||||
]
|
||||
|
||||
def get_queryset(self, request):
|
||||
return EventExt.objects.with_meeting_times_match_event()
|
||||
|
||||
@property
|
||||
def refresh_membershipworks_data(self):
|
||||
return run_task_action(self, "Refresh Data", scrape_events)
|
||||
@ -251,6 +256,7 @@ class EventAdmin(DjangoObjectActions, admin.ModelAdmin):
|
||||
"details_timestamp",
|
||||
"details",
|
||||
"registrations",
|
||||
"meeting_times_match_event",
|
||||
]
|
||||
return fields
|
||||
|
||||
@ -262,6 +268,15 @@ class EventAdmin(DjangoObjectActions, admin.ModelAdmin):
|
||||
def duration(self, obj):
|
||||
return obj.duration
|
||||
|
||||
@admin.display(
|
||||
boolean=True,
|
||||
description="Meeting times match event start/end",
|
||||
ordering="meeting_times_match_event",
|
||||
)
|
||||
def meeting_times_match_event(self, obj) -> bool:
|
||||
print(obj.meeting_times_match_event)
|
||||
return obj.meeting_times_match_event
|
||||
|
||||
@admin.display(description="MembershipWorks links")
|
||||
def links(self, obj):
|
||||
return format_html(
|
||||
|
@ -503,6 +503,28 @@ class EventExtQuerySet(models.QuerySet["EventExtAnnotated"]):
|
||||
net_revenue=F("gross_revenue") - F("total_due_to_instructor"),
|
||||
)
|
||||
|
||||
def with_meeting_times_match_event(self):
|
||||
return self.annotate(
|
||||
meeting_times_match_event=(
|
||||
Q(
|
||||
start=Subquery(
|
||||
EventMeetingTime.objects.filter(event=OuterRef("pk"))
|
||||
.order_by("start")
|
||||
.values("start")[:1],
|
||||
output_field=models.DateTimeField(),
|
||||
)
|
||||
)
|
||||
& Q(
|
||||
end=Subquery(
|
||||
EventMeetingTime.objects.filter(event=OuterRef("pk"))
|
||||
.order_by("-end")
|
||||
.values("end")[:1],
|
||||
output_field=models.DateTimeField(),
|
||||
)
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class EventExtManager(models.Manager):
|
||||
def get_queryset(self) -> EventExtQuerySet:
|
||||
|
Loading…
Reference in New Issue
Block a user