Skip to content
Snippets Groups Projects
Verified Commit ffdd7459 authored by Ernesto Rico Schmidt's avatar Ernesto Rico Schmidt
Browse files

Merge branch 'main' into develop

parents 5a9923d9 28ef3bfc
No related branches found
No related tags found
1 merge request!29Use docker main tag
Pipeline #7038 passed
......@@ -26,6 +26,7 @@ from versatileimagefield.fields import PPOIField, VersatileImageField
from django.contrib.auth.models import User
from django.db import models
from django.db.models import Q, QuerySet
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from program.utils import parse_datetime
from steering.settings import THUMBNAIL_SIZES
......@@ -248,6 +249,20 @@ class Show(models.Model):
def __str__(self):
return self.name
def save(self, *args, **kwargs):
now = timezone.datetime.now()
today = now.date()
if self.pk and self.is_active is False:
# deactivating a show means:
# - **delete all* the timeslots that belong to a schedule of this show the after now
# - **update all** the schedules of this show have today as `last_date`
TimeSlot.objects.filter(schedule__show=self, start__gt=now).delete()
self.schedules.filter(Q(last_date__gt=today) | Q(last_date=None)).update(
last_date=today
)
super().save(*args, **kwargs)
class ShowLink(Link):
show = models.ForeignKey(Show, on_delete=models.CASCADE, related_name="links")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment