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

feat: add ShowManager to annotate a show with its max (last) timeslot

parent aa8ea7fc
No related branches found
No related tags found
1 merge request!29Use docker main tag
......@@ -23,7 +23,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
from django.db.models import Max, Q
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from steering.settings import THUMBNAIL_SIZES
......@@ -204,6 +204,13 @@ class HostLink(Link):
host = models.ForeignKey(Host, on_delete=models.CASCADE, related_name="links")
class ShowManager(models.Manager):
def with_max_timeslot_start(self):
return (
super().get_queryset().annotate(max_timeslot_start=Max("schedules__timeslots__start"))
)
class Show(models.Model):
category = models.ManyToManyField(Category, blank=True, related_name="shows")
cba_series_id = models.IntegerField(blank=True, null=True)
......@@ -240,6 +247,8 @@ class Show(models.Model):
updated_at = models.DateTimeField(auto_now=True, blank=True, null=True)
updated_by = models.CharField(blank=True, default="", max_length=150)
objects = ShowManager()
class Meta:
ordering = ("slug",)
......
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