Repository: liqd/a4-meinberlin

Issue:
missing topic in Steckbrief of plans

![missing topic](https://user-images.githubusercontent.com/35491681/52210099-4cc1aa80-2886-11e9-9e70-f27221036fb6.jpg)



Discussion:
We added that on Friday. Seems like I have to recheck.
Well ok, we added the labels. Will add it to the Steckbrief as well. @szukowski Should it stay in both places (as label and in the Steckbrief)?
as discussed with @szukowski: leave out the topic label and only have topic in Steckbrief.

Resolving patch:
diff --git a/meinberlin/apps/plans/serializers.py b/meinberlin/apps/plans/serializers.py
--- a/meinberlin/apps/plans/serializers.py
+++ b/meinberlin/apps/plans/serializers.py
@@ -67,23 +67,31 @@ class Meta:
                   'published_projects_count', 'created_or_modified']
 
     def _get_participation_status_project(self, instance):
-        project_phases = instance.phases
-
-        if project_phases.active_phases():
-            return _('running'), True
-
-        if project_phases.future_phases():
-            try:
-                return (_('starts at {}').format
-                        (project_phases.future_phases().first().
-                         start_date.date().strftime('%d.%m.%Y')),
-                        True)
-            except AttributeError as e:
-                print(e)
-                return (_('starts in the future'),
-                        True)
+        if hasattr(instance, 'projectcontainer') and instance.projectcontainer:
+            if instance.projectcontainer.active_project_count > 0:
+                return _('running'), True
+            elif instance.projectcontainer.future_project_count > 0:
+                return _('starts in the future'), True
+            else:
+                return _('done'), False
         else:
-            return _('done'), False
+            project_phases = instance.phases
+
+            if project_phases.active_phases():
+                return _('running'), True
+
+            if project_phases.future_phases():
+                try:
+                    return (_('starts at {}').format
+                            (project_phases.future_phases().first().
+                             start_date.date().strftime('%d.%m.%Y')),
+                            True)
+                except AttributeError as e:
+                    print(e)
+                    return (_('starts in the future'),
+                            True)
+            else:
+                return _('done'), False
 
     def get_type(self, instance):
         return 'project'
@@ -167,7 +175,7 @@ def get_plan_title(self, instance):
 
     def get_published_projects_count(self, instance):
         if hasattr(instance, 'projectcontainer') and instance.projectcontainer:
-            return instance.projectcontainer.active_project_count
+            return instance.projectcontainer.total_project_count
 
     def get_point_label(self, instance):
         return ''
diff --git a/meinberlin/apps/plans/views.py b/meinberlin/apps/plans/views.py
--- a/meinberlin/apps/plans/views.py
+++ b/meinberlin/apps/plans/views.py
@@ -35,11 +35,6 @@ class PlanDetailView(rules_mixins.PermissionRequiredMixin,
     template_name = 'meinberlin_plans/plan_detail.html'
     permission_required = 'meinberlin_plans.view_plan'
 
-    def get_context_data(self, **kwargs):
-        context = super().get_context_data(**kwargs)
-        context['berlin_polygon'] = settings.BERLIN_POLYGON
-        return context
-
 
 class PlanListView(rules_mixins.PermissionRequiredMixin,
                    generic.ListView):
diff --git a/meinberlin/apps/projectcontainers/models.py b/meinberlin/apps/projectcontainers/models.py
--- a/meinberlin/apps/projectcontainers/models.py
+++ b/meinberlin/apps/projectcontainers/models.py
@@ -33,6 +33,20 @@ def active_project_count(self):
             .distinct()\
             .count()
 
+    @property
+    def future_project_count(self):
+        """Return the number of future projects within the container.
+
+        If a container is public (default) only public projects are counted.
+        For future private containers all projects should be counted.
+        """
+        now = timezone.now()
+        return self.projects\
+            .filter(is_public=True, is_draft=False, is_archived=False)\
+            .filter(module__phase__end_date__lte=now)\
+            .distinct()\
+            .count()
+
     @property
     def total_project_count(self):
         """Return the number of total projects within the container.


Test patch: