membershipworks: Add generated field to check if an event occured
This commit is contained in:
parent
4561e317b8
commit
cbe8d24fe4
27
membershipworks/migrations/0008_event_occurred.py
Normal file
27
membershipworks/migrations/0008_event_occurred.py
Normal 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(),
|
||||
),
|
||||
),
|
||||
]
|
@ -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",
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user