membershipworks: Add "Current and Upcoming Events" view
This commit is contained in:
parent
4dc4cd8f34
commit
e4c3b7cca2
@ -17,6 +17,11 @@ class MembershipworksDashboardFragment(dashboard.LinksCardDashboardFragment):
|
|||||||
reverse("membershipworks:upcoming-events-wordpress"),
|
reverse("membershipworks:upcoming-events-wordpress"),
|
||||||
permission="membershipworks.view_event",
|
permission="membershipworks.view_event",
|
||||||
),
|
),
|
||||||
|
Link(
|
||||||
|
"Current and Upcoming Events",
|
||||||
|
reverse("membershipworks:current-and-upcoming-events"),
|
||||||
|
permission="membershipworks.view_event",
|
||||||
|
),
|
||||||
Link(
|
Link(
|
||||||
"Event Report",
|
"Event Report",
|
||||||
reverse("membershipworks:event-index-report"),
|
reverse("membershipworks:event-index-report"),
|
||||||
|
@ -509,6 +509,13 @@ class EventExtManager(models.Manager):
|
|||||||
.values("d")[:1],
|
.values("d")[:1],
|
||||||
output_field=models.IntegerField(),
|
output_field=models.IntegerField(),
|
||||||
),
|
),
|
||||||
|
next_meeting_start=Subquery(
|
||||||
|
EventMeetingTime.objects.filter(
|
||||||
|
event=OuterRef("pk"), end__gt=timezone.now()
|
||||||
|
)
|
||||||
|
.order_by("start")
|
||||||
|
.values("start")[:1]
|
||||||
|
),
|
||||||
duration=Subquery(
|
duration=Subquery(
|
||||||
EventMeetingTime.objects.filter(event=OuterRef("pk"))
|
EventMeetingTime.objects.filter(event=OuterRef("pk"))
|
||||||
.values("event__pk")
|
.values("event__pk")
|
||||||
|
@ -116,6 +116,26 @@ class UserEventTable(EventTable):
|
|||||||
net_revenue = None
|
net_revenue = None
|
||||||
|
|
||||||
|
|
||||||
|
class CurrentAndUpcomingEventTable(EventTable):
|
||||||
|
next_meeting = tables.DateTimeColumn("N d, Y H:i", accessor="next_meeting_start")
|
||||||
|
person_hours = None
|
||||||
|
total_due_to_instructor = None
|
||||||
|
invoice__date_submitted = None
|
||||||
|
invoice__date_paid = None
|
||||||
|
gross_revenue = None
|
||||||
|
net_revenue = None
|
||||||
|
|
||||||
|
class Meta(EventTable.Meta):
|
||||||
|
row_attrs = {
|
||||||
|
"class": lambda table, record: (
|
||||||
|
""
|
||||||
|
if record.cap is None or record.cap > 0
|
||||||
|
else "text-decoration-line-through table-danger"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
sequence = ("title", "start", "next_meeting")
|
||||||
|
|
||||||
|
|
||||||
class InvoiceMoneyColumn(tables.columns.Column):
|
class InvoiceMoneyColumn(tables.columns.Column):
|
||||||
def render(self, value):
|
def render(self, value):
|
||||||
return f"${super().render(value):.2f}"
|
return f"${super().render(value):.2f}"
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
{% extends "base.dj.html" %}
|
||||||
|
|
||||||
|
{% load render_table from django_tables2 %}
|
||||||
|
|
||||||
|
{% block title %}Current and Upcoming Events{% endblock %}
|
||||||
|
{% block admin_link %}
|
||||||
|
{% url 'admin:membershipworks_eventext_changelist' %}
|
||||||
|
{% endblock %}
|
||||||
|
{% block breadcrumbs %}
|
||||||
|
<li class="breadcrumb-item active" aria-current="page">Current and Upcoming Events</li>
|
||||||
|
{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
{% render_table table %}
|
||||||
|
{% endblock %}
|
@ -15,6 +15,11 @@ urlpatterns = [
|
|||||||
views.upcoming_events_wordpress,
|
views.upcoming_events_wordpress,
|
||||||
name="upcoming-events-wordpress",
|
name="upcoming-events-wordpress",
|
||||||
),
|
),
|
||||||
|
path(
|
||||||
|
"current-and-upcoming-events/",
|
||||||
|
views.CurrentAndUpcomingEventView.as_view(),
|
||||||
|
name="current-and-upcoming-events",
|
||||||
|
),
|
||||||
path(
|
path(
|
||||||
"event-report/",
|
"event-report/",
|
||||||
views.EventIndexReport.as_view(),
|
views.EventIndexReport.as_view(),
|
||||||
|
@ -46,6 +46,7 @@ from .forms import EventInvoiceForm
|
|||||||
from .invoice_email import make_invoice_emails
|
from .invoice_email import make_invoice_emails
|
||||||
from .models import EventAttendee, EventExt, EventInvoice, Member
|
from .models import EventAttendee, EventExt, EventInvoice, Member
|
||||||
from .tables import (
|
from .tables import (
|
||||||
|
CurrentAndUpcomingEventTable,
|
||||||
EventAttendeeTable,
|
EventAttendeeTable,
|
||||||
EventRegistrationsTable,
|
EventRegistrationsTable,
|
||||||
EventSummaryTable,
|
EventSummaryTable,
|
||||||
@ -242,6 +243,24 @@ class EventMonthReport(
|
|||||||
return f"mw_events_{self.get_year()}-{self.get_month():02}.{export_format}"
|
return f"mw_events_{self.get_year()}-{self.get_month():02}.{export_format}"
|
||||||
|
|
||||||
|
|
||||||
|
class CurrentAndUpcomingEventView(SingleTableMixin, PermissionRequiredMixin, ListView):
|
||||||
|
permission_required = "membershipworks.view_eventext"
|
||||||
|
queryset = EventExt.objects.all()
|
||||||
|
date_field = "start"
|
||||||
|
template_name = "membershipworks/current_and_upcoming_events.dj.html"
|
||||||
|
table_class = CurrentAndUpcomingEventTable
|
||||||
|
|
||||||
|
def get_table_data(self):
|
||||||
|
return (
|
||||||
|
super()
|
||||||
|
.get_table_data()
|
||||||
|
.order_by("next_meeting_start")
|
||||||
|
.filter(end__gt=timezone.now())
|
||||||
|
.select_related("category", "instructor", "instructor__member")
|
||||||
|
.with_financials()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class UserEventView(SingleTableMixin, ListView):
|
class UserEventView(SingleTableMixin, ListView):
|
||||||
model: type[EventExt] = EventExt
|
model: type[EventExt] = EventExt
|
||||||
table_class = UserEventTable
|
table_class = UserEventTable
|
||||||
|
Loading…
Reference in New Issue
Block a user