membershipworks: Add generated field to check if an event occured

This commit is contained in:
Adam Goldsmith 2024-01-19 15:22:05 -05:00
parent 4561e317b8
commit cbe8d24fe4
3 changed files with 34 additions and 1 deletions

View File

@ -0,0 +1,27 @@
# Generated by Django 5.0.1 on 2024-01-19 20:21
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("membershipworks", "0007_eventmeetingtime_duration"),
]
operations = [
migrations.AddField(
model_name="event",
name="occurred",
field=models.GeneratedField(
db_persist=False,
expression=models.Q(
("cap", 0),
("count", 0),
("calendar", 0),
_connector="OR",
_negated=True,
),
output_field=models.BooleanField(),
),
),
]

View File

@ -10,6 +10,7 @@ from django.db.models import (
ExpressionWrapper,
F,
OuterRef,
Q,
Subquery,
Sum,
)
@ -384,6 +385,11 @@ class Event(BaseModel):
category = models.ForeignKey(EventCategory, on_delete=models.PROTECT)
calendar = models.IntegerField(choices=EventCalendar)
venue = models.TextField(null=True, blank=True)
occurred = models.GeneratedField(
expression=~(Q(cap=0) | Q(count=0) | Q(calendar=EventCalendar.HIDDEN)),
output_field=models.BooleanField(),
db_persist=False,
)
# TODO:
# "lgo": {
# "l": "https://d1tif55lvfk8gc.cloudfront.net/656e3842ae3975908b05e304.jpg?1673405126",

View File

@ -26,7 +26,7 @@
</thead>
<tbody>
{% for event in object_list %}
<tr>
<tr {% if not event.occurred %}class="text-decoration-line-through table-danger"{% endif %}>
<td>
<a href="https://membershipworks.com/admin/#!event/admin/{{ event.url }}">{{ event.title }}</a>
</td>