Filtre nouvelles par département

This commit is contained in:
Emmanuel Viennet 2022-04-13 13:53:53 +02:00
parent 68723f63ee
commit 93556ca372
3 changed files with 10 additions and 4 deletions

View File

@ -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):

View File

@ -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,
)
#

View File

@ -1,7 +1,7 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
SCOVERSION = "9.2.1"
SCOVERSION = "9.2.2"
SCONAME = "ScoDoc"