]> git.parisson.com Git - mezzo.git/commitdiff
Add department to ProjectDetailView context
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 22 Sep 2016 15:26:21 +0000 (17:26 +0200)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 22 Sep 2016 15:26:21 +0000 (17:26 +0200)
app/organization/projects/views.py
app/templates/pages/projectopicpage.html
app/templates/projects/project_detail.html

index d779decfa8d17264e388e96a833a40c127b1b35d..717b457efaee00afed82460af9084c898a6820a4 100644 (file)
@@ -15,3 +15,20 @@ class ProjectDetailView(SlugMixin, DetailView):
     model = Project
     template_name='projects/project_detail.html'
     context_object_name = 'project'
+
+    def get_context_data(self, **kwargs):
+        context = super(ProjectDetailView, self).get_context_data(**kwargs)
+        project = self.get_object()
+        department = None
+
+        if project.lead_team:
+            if project.lead_team.department:
+                department = project.lead_team.department
+        else:
+            for team in project.teams.all():
+                if team.department:
+                    department = team.department
+                    break
+
+        context['department'] = department
+        return context
index 05e232afd760d462549ab429c80a6eb88ef68a0a..3a47e02a02ecea9bcdb078883094fb27c2a23c7b 100644 (file)
@@ -55,5 +55,5 @@
             {{ project }}
           {% enfor %}
       {% endfor %}
-      
+
 {% endblock %}
index 91a76c832bc9f7ccf63e845e0776b1f6cfac1efe..babb3f023d32a6d81d140e7f91a2f96af6ac16e5 100644 (file)
@@ -54,7 +54,7 @@
 <div>
   <div>
     {% trans "Project details" %}<br>
-
+    
     {% if project.program %}
       {% trans "Program" %} {{ project.program }}<br>
     {% endif %}