From: Guillaume Pellerin Date: Thu, 22 Sep 2016 15:26:21 +0000 (+0200) Subject: Add department to ProjectDetailView context X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=51ef15b8c0b6aaa6bb2fdb888e039459fd096341;p=mezzo.git Add department to ProjectDetailView context --- diff --git a/app/organization/projects/views.py b/app/organization/projects/views.py index d779decf..717b457e 100644 --- a/app/organization/projects/views.py +++ b/app/organization/projects/views.py @@ -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 diff --git a/app/templates/pages/projectopicpage.html b/app/templates/pages/projectopicpage.html index 05e232af..3a47e02a 100644 --- a/app/templates/pages/projectopicpage.html +++ b/app/templates/pages/projectopicpage.html @@ -55,5 +55,5 @@ {{ project }} {% enfor %} {% endfor %} - + {% endblock %} diff --git a/app/templates/projects/project_detail.html b/app/templates/projects/project_detail.html index 91a76c83..babb3f02 100644 --- a/app/templates/projects/project_detail.html +++ b/app/templates/projects/project_detail.html @@ -54,7 +54,7 @@
{% trans "Project details" %}
- + {% if project.program %} {% trans "Program" %} {{ project.program }}
{% endif %}