membershipworks: Indicate in admin events with meeting times not matching event start/end
This commit is contained in:
parent
59d2ff4cb7
commit
69defab388
@ -171,6 +171,7 @@ class EventAdmin(DjangoObjectActions, admin.ModelAdmin):
|
|||||||
"count",
|
"count",
|
||||||
"cap",
|
"cap",
|
||||||
"category",
|
"category",
|
||||||
|
"meeting_times_match_event",
|
||||||
]
|
]
|
||||||
list_filter = [
|
list_filter = [
|
||||||
"category",
|
"category",
|
||||||
@ -198,6 +199,7 @@ class EventAdmin(DjangoObjectActions, admin.ModelAdmin):
|
|||||||
"instructor_flat_rate",
|
"instructor_flat_rate",
|
||||||
("should_survey", "survey_email_sent"),
|
("should_survey", "survey_email_sent"),
|
||||||
"links",
|
"links",
|
||||||
|
"meeting_times_match_event",
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -243,6 +245,9 @@ class EventAdmin(DjangoObjectActions, admin.ModelAdmin):
|
|||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def get_queryset(self, request):
|
||||||
|
return EventExt.objects.with_meeting_times_match_event()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def refresh_membershipworks_data(self):
|
def refresh_membershipworks_data(self):
|
||||||
return run_task_action(self, "Refresh Data", scrape_events)
|
return run_task_action(self, "Refresh Data", scrape_events)
|
||||||
@ -260,6 +265,7 @@ class EventAdmin(DjangoObjectActions, admin.ModelAdmin):
|
|||||||
"details_timestamp",
|
"details_timestamp",
|
||||||
"details",
|
"details",
|
||||||
"registrations",
|
"registrations",
|
||||||
|
"meeting_times_match_event",
|
||||||
]
|
]
|
||||||
return fields
|
return fields
|
||||||
|
|
||||||
@ -271,6 +277,14 @@ class EventAdmin(DjangoObjectActions, admin.ModelAdmin):
|
|||||||
def duration(self, obj):
|
def duration(self, obj):
|
||||||
return obj.duration
|
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:
|
||||||
|
return obj.meeting_times_match_event
|
||||||
|
|
||||||
@admin.display(description="MembershipWorks links")
|
@admin.display(description="MembershipWorks links")
|
||||||
def links(self, obj):
|
def links(self, obj):
|
||||||
return format_html(
|
return format_html(
|
||||||
|
@ -503,6 +503,28 @@ class EventExtQuerySet(models.QuerySet["EventExtAnnotated"]):
|
|||||||
net_revenue=F("gross_revenue") - F("total_due_to_instructor"),
|
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):
|
class EventExtManager(models.Manager):
|
||||||
def get_queryset(self) -> EventExtQuerySet:
|
def get_queryset(self) -> EventExtQuerySet:
|
||||||
|
Loading…
Reference in New Issue
Block a user