From a95c663ac9d0121f0d26a1db50cf5d8a9a324b02 Mon Sep 17 00:00:00 2001 From: fuzzylogic2000 Date: Mon, 28 Sep 2020 12:16:50 +0200 Subject: [PATCH] apps/projects: make sure serializers only take phases of published modules into account --- meinberlin/apps/projects/filters.py | 9 ++++++--- meinberlin/apps/projects/serializers.py | 12 +++++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/meinberlin/apps/projects/filters.py b/meinberlin/apps/projects/filters.py index 906a2afd99..1e43f0256e 100644 --- a/meinberlin/apps/projects/filters.py +++ b/meinberlin/apps/projects/filters.py @@ -12,11 +12,13 @@ def filter_queryset(self, request, queryset, view): active_projects = queryset \ .filter( module__phase__start_date__lte=now, - module__phase__end_date__gt=now) \ + module__phase__end_date__gt=now, + module__is_draft=False) \ .distinct() future_projects = queryset.filter( - module__phase__start_date__gt=now + module__phase__start_date__gt=now, + module__is_draft=False ).distinct().exclude( id__in=active_projects.values('id')) @@ -28,7 +30,8 @@ def filter_queryset(self, request, queryset, view): if statustype == 'pastParticipation': past_projects = queryset.filter( - module__phase__end_date__lt=now + module__phase__end_date__lt=now, + module__is_draft=False ).distinct() \ .exclude( id__in=active_projects.values('id')) \ diff --git a/meinberlin/apps/projects/serializers.py b/meinberlin/apps/projects/serializers.py index 471084f06f..ad57d9c8b7 100644 --- a/meinberlin/apps/projects/serializers.py +++ b/meinberlin/apps/projects/serializers.py @@ -226,9 +226,9 @@ def seconds_in_units(self, seconds): return unit_totals def get_active_phase(self, instance): - progress = instance.active_phase_progress - time_left = instance.time_left - end_date = str(instance.active_phase_ends_next.end_date) + progress = instance.module_running_progress + time_left = instance.module_running_time_left + end_date = str(instance.running_module_ends_next.module_end) return [progress, time_left, end_date] def get_status(self, instance): @@ -252,7 +252,8 @@ class FutureProjectSerializer(ProjectSerializer): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._future_phases = Phase.objects\ - .filter(start_date__gt=self.now)\ + .filter(start_date__gt=self.now, + module__is_draft=False)\ .order_by('start_date') def get_active_phase(self, instance): @@ -282,7 +283,8 @@ class PastProjectSerializer(ProjectSerializer): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._past_phases = Phase.objects\ - .filter(end_date__lt=timezone.now())\ + .filter(end_date__lt=timezone.now(), + module__is_draft=False)\ .order_by('start_date') def get_active_phase(self, instance):