From 93556ca3724baeed10d297716211225069e9682b Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Wed, 13 Apr 2022 13:53:53 +0200 Subject: [PATCH] =?UTF-8?q?Filtre=20nouvelles=20par=20d=C3=A9partement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/events.py | 10 ++++++++-- app/scodoc/sco_edit_ue.py | 2 +- sco_version.py | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/models/events.py b/app/models/events.py index ccb6396e..9725f3c8 100644 --- a/app/models/events.py +++ b/app/models/events.py @@ -102,9 +102,15 @@ class ScolarNews(db.Model): } @classmethod - def last_news(cls, n=1) -> list: + def last_news(cls, n=1, dept_id=None, filter_dept=True) -> list: "The most recent n news. Returns list of ScolarNews instances." - return cls.query.order_by(cls.date.desc()).limit(n).all() + query = cls.query + if filter_dept: + if dept_id is None: + dept_id = g.scodoc_dept_id + query = query.filter_by(dept_id=dept_id) + + return query.order_by(cls.date.desc()).limit(n).all() @classmethod def add(cls, typ, obj=None, text="", url=None, max_frequency=0): diff --git a/app/scodoc/sco_edit_ue.py b/app/scodoc/sco_edit_ue.py index be2523bb..c6811d45 100644 --- a/app/scodoc/sco_edit_ue.py +++ b/app/scodoc/sco_edit_ue.py @@ -222,7 +222,7 @@ def do_ue_delete(ue_id, delete_validations=False, force=False): ScolarNews.add( typ=ScolarNews.NEWS_FORM, obj=ue.formation_id, - text="Modification de la formation %(acronyme)s" % F, + text=f"Modification de la formation {F['acronyme']}", max_frequency=10 * 60, ) # diff --git a/sco_version.py b/sco_version.py index 0f7ec6c5..4380a1fa 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.2.1" +SCOVERSION = "9.2.2" SCONAME = "ScoDoc"