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

Refactor filter_active to not use ids/pks

parent 1f78b050
No related branches found
No related tags found
No related merge requests found
...@@ -85,12 +85,14 @@ class ShowFilterSet(StaticFilterHelpTextMixin, filters.FilterSet): ...@@ -85,12 +85,14 @@ class ShowFilterSet(StaticFilterHelpTextMixin, filters.FilterSet):
# Add limit for future? # Add limit for future?
show_ids = ( show_ids = (
models.Schedule.objects.filter( models.Schedule.objects.filter(
# not "once" schedules with first_date in the past and last_date in the future
Q( Q(
rrule_id__gt=1, rrule__freq__gt=0,
first_date__lte=timezone.now(), first_date__lte=timezone.now(),
last_date__gte=timezone.now(), last_date__gte=timezone.now(),
) )
| Q(rrule_id=1, first_date__gte=timezone.now()) # "once" schedules with first_date in the future
| Q(rrule__freq=0, first_date__gte=timezone.now())
) )
.distinct() .distinct()
.values_list("show_id", flat=True) .values_list("show_id", flat=True)
......
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