diff --git a/ZAbsences.py b/ZAbsences.py index 04987532..e9cd2f37 100644 --- a/ZAbsences.py +++ b/ZAbsences.py @@ -67,6 +67,7 @@ from sco_permissions import ScoAbsAddBillet, ScoAbsChange, ScoView from sco_exceptions import ScoValueError, ScoInvalidDateError from TrivialFormulator import TrivialFormulator, TF from gen_tables import GenTable +import html_sco_header import scolars import sco_formsemestre import sco_moduleimpl @@ -78,6 +79,8 @@ import sco_compute_moy import sco_abs from sco_abs import ddmmyyyy +CSSSTYLES = html_sco_header.BOOTSTRAP_MULTISELECT_CSS + def _toboolean(x): "convert a value to boolean (ensure backward compat with OLD intranet code)" @@ -343,11 +346,17 @@ class ZAbsences( ) cnx.commit() - security.declareProtected(ScoView, "CountAbs") + def ListAbsInRange( + self, etudid, debut, fin, matin=None, moduleimpl_id=None, cursor=None + ): + """Liste des absences entre deux dates. - def CountAbs(self, etudid, debut, fin, matin=None, moduleimpl_id=None): - """CountAbs - matin= 1 ou 0. + Args: + etudid + debut string iso date ("2020-03-12") + end string iso date ("2020-03-12") + matin None, True, False + moduleimpl_id """ if matin != None: matin = _toboolean(matin) @@ -358,10 +367,11 @@ class ZAbsences( modul = " AND A.MODULEIMPL_ID = %(moduleimpl_id)s " else: modul = "" - cnx = self.GetDBConnexion() - cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor) + if not cursor: + cnx = self.GetDBConnexion() + cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor) cursor.execute( - """SELECT COUNT(*) AS NbAbs FROM ( + """ SELECT DISTINCT A.JOUR, A.MATIN FROM ABSENCES A WHERE A.ETUDID = %(etudid)s @@ -370,13 +380,27 @@ class ZAbsences( + modul + """ AND A.JOUR BETWEEN %(debut)s AND %(fin)s - ) AS tmp """, vars(), ) - res = cursor.fetchone()[0] + res = cursor.dictfetchall() return res + security.declareProtected(ScoView, "CountAbs") + + def CountAbs(self, etudid, debut, fin, matin=None, moduleimpl_id=None): + """CountAbs + matin= 1 ou 0. + + Returns: + An integer. + """ + return len( + self.ListAbsInRange( + etudid, debut, fin, matin=matin, moduleimpl_id=moduleimpl_id + ) + ) + security.declareProtected(ScoView, "CountAbsJust") def CountAbsJust(self, etudid, debut, fin, matin=None, moduleimpl_id=None): @@ -743,27 +767,48 @@ class ZAbsences( else: p = "du groupe" gr_tit = ( - p + '' + groups_infos.groups_titles + "" + p + ' ' + groups_infos.groups_titles + "" ) H = [ self.sco_header( page_title="Saisie hebdomadaire des absences", init_qtip=True, - javascripts=["js/etud_info.js", "js/abs_ajax.js"], + javascripts=html_sco_header.BOOTSTRAP_MULTISELECT_JS + + [ + "js/etud_info.js", + "js/abs_ajax.js", + "js/groups_view.js", + ], + cssstyles=CSSSTYLES, no_side_bar=1, REQUEST=REQUEST, ), """
- Saisie des absences %s %s, - semaine du lundi %s- - - -- |