From 588412501585a4b33f62192d011d74f797ba7987 Mon Sep 17 00:00:00 2001 From: artus40 Date: Thu, 29 Dec 2016 14:53:58 +0100 Subject: [PATCH] =?UTF-8?q?ajout=20de=20la=20liste=20des=20derniers=20suje?= =?UTF-8?q?ts=20rencontr=C3=A9s=20dans=20'suivi'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- maraudes/models.py | 1 + suivi/templates/suivi/index.html | 7 ++++--- suivi/views.py | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/maraudes/models.py b/maraudes/models.py index 167e2c8..269015f 100644 --- a/maraudes/models.py +++ b/maraudes/models.py @@ -188,6 +188,7 @@ class Rencontre(models.Model): else: return "Aucun" + # Should be a read only property def get_sujets(self): """ Renvoie la liste des sujets rencontrés """ return [o.sujet for o in self.observations.all()] diff --git a/suivi/templates/suivi/index.html b/suivi/templates/suivi/index.html index 72b1b75..23b12c9 100644 --- a/suivi/templates/suivi/index.html +++ b/suivi/templates/suivi/index.html @@ -1,9 +1,10 @@ -
+

Ces derniers temps

+

Nous avons rencontré {{ derniers_sujets }}.

Vigilance

-
-
+ +

Créer une note :

{% include "suivi/appel_form.html" with form=appel_form %} diff --git a/suivi/views.py b/suivi/views.py index 67b11c0..ebc753a 100644 --- a/suivi/views.py +++ b/suivi/views.py @@ -17,7 +17,18 @@ suivi = website.app_config( ajax=False, ) +from maraudes.compte_rendu import CompteRendu +def derniers_sujets_rencontres(): + """ Renvoie le 'set' des sujets rencontrés dans les deux dernières maraudes """ + sujets = set() + + # Issue: Récupère des comptes-rendus, même s'il n'ont pas été rédigé. Ne devrait pas + # être un souci si on reste à jour, mais sinon... + for cr in list(CompteRendu.objects.all())[-2:]: + for obs in cr.get_observations(): + sujets.add(obs.sujet) + return sujets @suivi class IndexView(NoteFormMixin, generic.TemplateView): @@ -38,6 +49,11 @@ class IndexView(NoteFormMixin, generic.TemplateView): #TemplateView template_name = "suivi/index.html" + def get_context_data(self, *args, **kwargs): + context = super().get_context_data(*args, **kwargs) + context['derniers_sujets'] = ", ".join(map(str, derniers_sujets_rencontres())) + return context + @suivi class SujetListView(generic.ListView): class PageInfo: