diff --git a/sco_abs_views.py b/sco_abs_views.py index aabab46f41..70ada694ff 100644 --- a/sco_abs_views.py +++ b/sco_abs_views.py @@ -56,10 +56,21 @@ def doSignaleAbsence( demijournee=2, estjust=False, description=None, + etudid=False, REQUEST=None, ): # etudid implied - """Signalement d'une absence""" - etud = context.getEtudInfo(filled=1, REQUEST=REQUEST)[0] + """Signalement d'une absence. + + Args: + datedebut: dd/mm/yyyy + datefin: dd/mm/yyyy (non incluse) + moduleimpl_id: module auquel imputer les absences + demijournee: 2 si journée complète, 1 matin, 0 après-midi + estjust: absence justifiée + description: str + etudid: etudiant concerné. Si non spécifié, cherche dans REQUEST.form + """ + etud = context.getEtudInfo(filled=1, etudid=etudid, REQUEST=REQUEST)[0] etudid = etud["etudid"] description_abs = description @@ -247,10 +258,25 @@ Raison: (optionnel) def doJustifAbsence( - context, datedebut, datefin, demijournee, description=None, REQUEST=None + context, + datedebut, + datefin, + demijournee, + description=None, + etudid=False, + REQUEST=None, ): # etudid implied - """Justification d'une absence""" - etud = context.getEtudInfo(filled=1, REQUEST=REQUEST)[0] + """Justification d'une absence + + Args: + datedebut: dd/mm/yyyy + datefin: dd/mm/yyyy (non incluse) + demijournee: 2 si journée complète, 1 matin, 0 après-midi + estjust: absence justifiée + description: str + etudid: etudiant concerné. Si non spécifié, cherche dans REQUEST.form + """ + etud = context.getEtudInfo(filled=1, etudid=etudid, REQUEST=REQUEST)[0] etudid = etud["etudid"] description_abs = description dates = sco_abs.DateRangeISO(context, datedebut, datefin) @@ -370,10 +396,10 @@ Raison: (optionnel) def doAnnuleAbsence( - context, datedebut, datefin, demijournee, REQUEST=None + context, datedebut, datefin, demijournee, etudid=False, REQUEST=None ): # etudid implied """Annulation des absences pour une demi journée""" - etud = context.getEtudInfo(filled=1, REQUEST=REQUEST)[0] + etud = context.getEtudInfo(filled=1, etudid=etudid, REQUEST=REQUEST)[0] etudid = etud["etudid"] dates = sco_abs.DateRangeISO(context, datedebut, datefin) diff --git a/scotests/test_basic.py b/scotests/test_basic.py index fe1a9ad1f5..c98cb32176 100644 --- a/scotests/test_basic.py +++ b/scotests/test_basic.py @@ -13,6 +13,8 @@ import random import scotests.sco_fake_gen as sco_fake_gen # pylint: disable=import-error import sco_utils +import sco_abs +import sco_abs_views G = sco_fake_gen.ScoFake(context.Notes) # pylint: disable=undefined-variable G.verbose = False @@ -64,3 +66,28 @@ for etud in etuds: nb_changed, nb_suppress, existing_decisions = G.create_note( evaluation=e, etud=etud, note=float(random.randint(0, 20)) ) + +# --- Saisie absences +etudid = etuds[0]["etudid"] + +_ = sco_abs_views.doSignaleAbsence( + context.Absences, + "15/01/2020", + "18/01/2020", + demijournee=2, + etudid=etudid, + REQUEST=REQUEST, +) + +_ = sco_abs_views.doJustifAbsence( + context.Absences, + "17/01/2020", + "18/01/2020", + demijournee=2, + etudid=etudid, + REQUEST=REQUEST, +) + +a = sco_abs.getAbsSemEtud(context.Absences, sem, etudid) +assert a.CountAbs() == 3 +assert a.CountAbsJust() == 1