diff --git a/membershipworks/dashboard.py b/membershipworks/dashboard.py index 6e38302..d754de6 100644 --- a/membershipworks/dashboard.py +++ b/membershipworks/dashboard.py @@ -17,6 +17,11 @@ class MembershipworksDashboardFragment(dashboard.LinksCardDashboardFragment): reverse("membershipworks:upcoming-events-wordpress"), permission="membershipworks.view_event", ), + Link( + "Current and Upcoming Events", + reverse("membershipworks:current-and-upcoming-events"), + permission="membershipworks.view_event", + ), Link( "Event Report", reverse("membershipworks:event-index-report"), diff --git a/membershipworks/models.py b/membershipworks/models.py index 5b53127..80f56d1 100644 --- a/membershipworks/models.py +++ b/membershipworks/models.py @@ -509,6 +509,13 @@ class EventExtManager(models.Manager): .values("d")[:1], 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( EventMeetingTime.objects.filter(event=OuterRef("pk")) .values("event__pk") diff --git a/membershipworks/tables.py b/membershipworks/tables.py index 97bc9e2..ad65dc7 100644 --- a/membershipworks/tables.py +++ b/membershipworks/tables.py @@ -116,6 +116,26 @@ class UserEventTable(EventTable): 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): def render(self, value): return f"${super().render(value):.2f}" diff --git a/membershipworks/templates/membershipworks/current_and_upcoming_events.dj.html b/membershipworks/templates/membershipworks/current_and_upcoming_events.dj.html new file mode 100644 index 0000000..3c9578b --- /dev/null +++ b/membershipworks/templates/membershipworks/current_and_upcoming_events.dj.html @@ -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 %} +