diff --git a/src/agenda_culturel/calendar.py b/src/agenda_culturel/calendar.py index c3dfe80..a62e9ac 100644 --- a/src/agenda_culturel/calendar.py +++ b/src/agenda_culturel/calendar.py @@ -238,6 +238,7 @@ class CalendarList: | Q(recurrence_dtend__lt=startdatetime) ) ) + | (Q(start_day__lte=self.c_firstdate) & (Q(end_day__isnull=True) | Q(end_day__gte=self.c_firstdate))) ).filter( Q(other_versions__isnull=True) | Q(other_versions__representative=F('pk')) | diff --git a/src/agenda_culturel/migrations/0116_event_agenda_cult_start_d_68ab5f_idx.py b/src/agenda_culturel/migrations/0116_event_agenda_cult_start_d_68ab5f_idx.py new file mode 100644 index 0000000..59ec17b --- /dev/null +++ b/src/agenda_culturel/migrations/0116_event_agenda_cult_start_d_68ab5f_idx.py @@ -0,0 +1,17 @@ +# Generated by Django 4.2.9 on 2024-11-23 09:58 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('agenda_culturel', '0115_alter_organisation_options_alter_event_organisers'), + ] + + operations = [ + migrations.AddIndex( + model_name='event', + index=models.Index(fields=['start_day', 'start_time'], name='agenda_cult_start_d_68ab5f_idx'), + ), + ] diff --git a/src/agenda_culturel/migrations/0117_event_start_time_title.py b/src/agenda_culturel/migrations/0117_event_start_time_title.py new file mode 100644 index 0000000..c8c7ffd --- /dev/null +++ b/src/agenda_culturel/migrations/0117_event_start_time_title.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.9 on 2024-11-23 10:11 + +from django.db import migrations, models +import django.db.models.functions.text + + +class Migration(migrations.Migration): + + dependencies = [ + ('agenda_culturel', '0116_event_agenda_cult_start_d_68ab5f_idx'), + ] + + operations = [ + migrations.AddIndex( + model_name='event', + index=models.Index(models.F('start_time'), django.db.models.functions.text.Lower('title'), name='start_time title'), + ), + ] diff --git a/src/agenda_culturel/migrations/0118_alter_tag_options_and_more.py b/src/agenda_culturel/migrations/0118_alter_tag_options_and_more.py new file mode 100644 index 0000000..3801ba4 --- /dev/null +++ b/src/agenda_culturel/migrations/0118_alter_tag_options_and_more.py @@ -0,0 +1,33 @@ +# Generated by Django 4.2.9 on 2024-11-23 10:16 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('agenda_culturel', '0117_event_start_time_title'), + ] + + operations = [ + migrations.AlterModelOptions( + name='tag', + options={'verbose_name': 'Étiquette', 'verbose_name_plural': 'Étiquettes'}, + ), + migrations.AddIndex( + model_name='category', + index=models.Index(fields=['name'], name='agenda_cult_name_28aa03_idx'), + ), + migrations.AddIndex( + model_name='referencelocation', + index=models.Index(fields=['name'], name='agenda_cult_name_76f079_idx'), + ), + migrations.AddIndex( + model_name='staticcontent', + index=models.Index(fields=['name'], name='agenda_cult_name_fe4995_idx'), + ), + migrations.AddIndex( + model_name='tag', + index=models.Index(fields=['name'], name='agenda_cult_name_9c9c74_idx'), + ), + ] diff --git a/src/agenda_culturel/models.py b/src/agenda_culturel/models.py index fb343c4..2a9516a 100644 --- a/src/agenda_culturel/models.py +++ b/src/agenda_culturel/models.py @@ -18,6 +18,7 @@ from django.core.files import File from django.utils import timezone from django.contrib.postgres.search import TrigramSimilarity from django.db.models import Q, Count, F, Subquery, OuterRef, Func +from django.db.models.functions import Lower import recurrence.fields import recurrence import copy @@ -68,6 +69,9 @@ class StaticContent(models.Model): class Meta: verbose_name = _("Static content") verbose_name_plural = _("Static contents") + indexes = [ + models.Index(fields=['name']), + ] def __str__(self): return self.name @@ -169,6 +173,9 @@ class Category(models.Model): class Meta: verbose_name = _("Category") verbose_name_plural = _("Categories") + indexes = [ + models.Index(fields=['name']), + ] class Tag(models.Model): @@ -203,6 +210,13 @@ class Tag(models.Model): default=False, ) + class Meta: + verbose_name = _("Étiquette") + verbose_name_plural = _("Étiquettes") + indexes = [ + models.Index(fields=['name']), + ] + def get_absolute_url(self): return reverse("view_tag", kwargs={"t": self.name}) @@ -394,11 +408,16 @@ class ReferenceLocation(models.Model): class Meta: verbose_name = _("Reference location") verbose_name_plural = _("Reference locations") + indexes = [ + models.Index(fields=['name']), + ] def __str__(self): return self.name + + class Place(models.Model): name = models.CharField(verbose_name=_("Name"), help_text=_("Name of the place")) address = models.CharField( @@ -735,6 +754,10 @@ class Event(models.Model): verbose_name = _("Event") verbose_name_plural = _("Events") permissions = [("set_duplicated_event", "Can set an event as duplicated")] + indexes = [ + models.Index(fields=["start_day", "start_time"]), + models.Index("start_time", Lower("title"), name="start_time title") + ] def sorted_tags(self): if self.tags is None: