itre form saisie + pylint
This commit is contained in:
parent
7efe8cd194
commit
2b5a470516
170
ZAbsences.py
170
ZAbsences.py
@ -45,17 +45,19 @@ L'API de plus bas niveau est en gros:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import urllib
|
import urllib
|
||||||
|
import datetime
|
||||||
|
import jaxml
|
||||||
|
|
||||||
|
# ---------------
|
||||||
from sco_zope import *
|
from sco_zope import *
|
||||||
|
|
||||||
# ---------------
|
# ---------------
|
||||||
|
import sco_utils as scu
|
||||||
from notesdb import *
|
import notesdb
|
||||||
from notes_log import log
|
from notes_log import log
|
||||||
from scolog import logdb
|
from scolog import logdb
|
||||||
from sco_utils import *
|
from sco_permissions import ScoAbsAddBillet, ScoAbsChange, ScoView
|
||||||
|
from sco_exceptions import ScoValueError, ScoInvalidDateError
|
||||||
# import notes_users
|
|
||||||
from TrivialFormulator import TrivialFormulator, TF
|
from TrivialFormulator import TrivialFormulator, TF
|
||||||
from gen_tables import GenTable
|
from gen_tables import GenTable
|
||||||
import scolars
|
import scolars
|
||||||
@ -356,7 +358,7 @@ class ZAbsences(
|
|||||||
estjust = _toboolean(estjust)
|
estjust = _toboolean(estjust)
|
||||||
matin = _toboolean(matin)
|
matin = _toboolean(matin)
|
||||||
cnx = self.GetDBConnexion()
|
cnx = self.GetDBConnexion()
|
||||||
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
|
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"insert into absences (etudid,jour,estabs,estjust,matin,description, moduleimpl_id) values (%(etudid)s, %(jour)s, TRUE, %(estjust)s, %(matin)s, %(description)s, %(moduleimpl_id)s )",
|
"insert into absences (etudid,jour,estabs,estjust,matin,description, moduleimpl_id) values (%(etudid)s, %(jour)s, TRUE, %(estjust)s, %(matin)s, %(description)s, %(moduleimpl_id)s )",
|
||||||
vars(),
|
vars(),
|
||||||
@ -380,7 +382,7 @@ class ZAbsences(
|
|||||||
raise ScoValueError("date justificatif trop loin dans le futur !")
|
raise ScoValueError("date justificatif trop loin dans le futur !")
|
||||||
matin = _toboolean(matin)
|
matin = _toboolean(matin)
|
||||||
cnx = self.GetDBConnexion()
|
cnx = self.GetDBConnexion()
|
||||||
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
|
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"insert into absences (etudid,jour,estabs,estjust,matin, description) values (%(etudid)s,%(jour)s, FALSE, TRUE, %(matin)s, %(description)s )",
|
"insert into absences (etudid,jour,estabs,estjust,matin, description) values (%(etudid)s,%(jour)s, FALSE, TRUE, %(matin)s, %(description)s )",
|
||||||
vars(),
|
vars(),
|
||||||
@ -402,7 +404,7 @@ class ZAbsences(
|
|||||||
# unpublished
|
# unpublished
|
||||||
matin = _toboolean(matin)
|
matin = _toboolean(matin)
|
||||||
cnx = self.GetDBConnexion()
|
cnx = self.GetDBConnexion()
|
||||||
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
|
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
|
||||||
req = "delete from absences where jour=%(jour)s and matin=%(matin)s and etudid=%(etudid)s and estabs"
|
req = "delete from absences where jour=%(jour)s and matin=%(matin)s and etudid=%(etudid)s and estabs"
|
||||||
if moduleimpl_id:
|
if moduleimpl_id:
|
||||||
req += " and moduleimpl_id=%(moduleimpl_id)s"
|
req += " and moduleimpl_id=%(moduleimpl_id)s"
|
||||||
@ -423,7 +425,7 @@ class ZAbsences(
|
|||||||
# unpublished
|
# unpublished
|
||||||
matin = _toboolean(matin)
|
matin = _toboolean(matin)
|
||||||
cnx = self.GetDBConnexion()
|
cnx = self.GetDBConnexion()
|
||||||
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
|
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"delete from absences where jour=%(jour)s and matin=%(matin)s and etudid=%(etudid)s and ESTJUST AND NOT ESTABS",
|
"delete from absences where jour=%(jour)s and matin=%(matin)s and etudid=%(etudid)s and ESTJUST AND NOT ESTABS",
|
||||||
vars(),
|
vars(),
|
||||||
@ -450,7 +452,7 @@ class ZAbsences(
|
|||||||
# """
|
# """
|
||||||
# # unpublished
|
# # unpublished
|
||||||
# cnx = self.GetDBConnexion()
|
# cnx = self.GetDBConnexion()
|
||||||
# cursor = cnx.cursor(cursor_factory=ScoDocCursor)
|
# cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
|
||||||
# # supr les absences non justifiees
|
# # supr les absences non justifiees
|
||||||
# cursor.execute("delete from absences where etudid=%(etudid)s and (not estjust) and moduleimpl_id=(moduleimpl_id)s and jour BETWEEN %(datedebut)s AND %(datefin)s",
|
# cursor.execute("delete from absences where etudid=%(etudid)s and (not estjust) and moduleimpl_id=(moduleimpl_id)s and jour BETWEEN %(datedebut)s AND %(datefin)s",
|
||||||
# vars() )
|
# vars() )
|
||||||
@ -487,7 +489,7 @@ class ZAbsences(
|
|||||||
self._AnnuleAbsence(etudid, jour, matin, moduleimpl_id, REQUEST)
|
self._AnnuleAbsence(etudid, jour, matin, moduleimpl_id, REQUEST)
|
||||||
return
|
return
|
||||||
cnx = self.GetDBConnexion()
|
cnx = self.GetDBConnexion()
|
||||||
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
|
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
|
||||||
# supr les absences non justifiees
|
# supr les absences non justifiees
|
||||||
for date in dates:
|
for date in dates:
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
@ -534,7 +536,7 @@ class ZAbsences(
|
|||||||
else:
|
else:
|
||||||
modul = ""
|
modul = ""
|
||||||
cnx = self.GetDBConnexion()
|
cnx = self.GetDBConnexion()
|
||||||
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
|
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"""SELECT COUNT(*) AS NbAbs FROM (
|
"""SELECT COUNT(*) AS NbAbs FROM (
|
||||||
SELECT DISTINCT A.JOUR, A.MATIN
|
SELECT DISTINCT A.JOUR, A.MATIN
|
||||||
@ -565,7 +567,7 @@ class ZAbsences(
|
|||||||
else:
|
else:
|
||||||
modul = ""
|
modul = ""
|
||||||
cnx = self.GetDBConnexion()
|
cnx = self.GetDBConnexion()
|
||||||
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
|
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"""SELECT COUNT(*) AS NbAbsJust FROM (
|
"""SELECT COUNT(*) AS NbAbsJust FROM (
|
||||||
SELECT DISTINCT A.JOUR, A.MATIN
|
SELECT DISTINCT A.JOUR, A.MATIN
|
||||||
@ -588,7 +590,7 @@ class ZAbsences(
|
|||||||
def _ListeAbsDate(self, etudid, beg_date, end_date):
|
def _ListeAbsDate(self, etudid, beg_date, end_date):
|
||||||
# Liste des absences et justifs entre deux dates
|
# Liste des absences et justifs entre deux dates
|
||||||
cnx = self.GetDBConnexion()
|
cnx = self.GetDBConnexion()
|
||||||
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
|
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"""SELECT jour, matin, estabs, estjust, description FROM ABSENCES A
|
"""SELECT jour, matin, estabs, estjust, description FROM ABSENCES A
|
||||||
WHERE A.ETUDID = %(etudid)s
|
WHERE A.ETUDID = %(etudid)s
|
||||||
@ -598,7 +600,6 @@ class ZAbsences(
|
|||||||
vars(),
|
vars(),
|
||||||
)
|
)
|
||||||
Abs = cursor.dictfetchall()
|
Abs = cursor.dictfetchall()
|
||||||
# log('ListeAbsDate: abs=%s' % Abs)
|
|
||||||
# remove duplicates
|
# remove duplicates
|
||||||
A = {} # { (jour, matin) : abs }
|
A = {} # { (jour, matin) : abs }
|
||||||
for a in Abs:
|
for a in Abs:
|
||||||
@ -625,7 +626,6 @@ class ZAbsences(
|
|||||||
# sort
|
# sort
|
||||||
R = A.values()
|
R = A.values()
|
||||||
R.sort(key=lambda x: (x["begin"]))
|
R.sort(key=lambda x: (x["begin"]))
|
||||||
# log('R=%s' % R)
|
|
||||||
return R
|
return R
|
||||||
|
|
||||||
security.declareProtected(ScoView, "ListeAbsJust")
|
security.declareProtected(ScoView, "ListeAbsJust")
|
||||||
@ -633,7 +633,7 @@ class ZAbsences(
|
|||||||
def ListeAbsJust(self, etudid, datedebut):
|
def ListeAbsJust(self, etudid, datedebut):
|
||||||
"Liste des absences justifiees (par ordre chronologique)"
|
"Liste des absences justifiees (par ordre chronologique)"
|
||||||
cnx = self.GetDBConnexion()
|
cnx = self.GetDBConnexion()
|
||||||
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
|
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"""SELECT DISTINCT A.ETUDID, A.JOUR, A.MATIN FROM ABSENCES A, ABSENCES B
|
"""SELECT DISTINCT A.ETUDID, A.JOUR, A.MATIN FROM ABSENCES A, ABSENCES B
|
||||||
WHERE A.ETUDID = %(etudid)s
|
WHERE A.ETUDID = %(etudid)s
|
||||||
@ -654,7 +654,7 @@ class ZAbsences(
|
|||||||
def ListeAbsNonJust(self, etudid, datedebut):
|
def ListeAbsNonJust(self, etudid, datedebut):
|
||||||
"Liste des absences NON justifiees (par ordre chronologique)"
|
"Liste des absences NON justifiees (par ordre chronologique)"
|
||||||
cnx = self.GetDBConnexion()
|
cnx = self.GetDBConnexion()
|
||||||
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
|
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"""SELECT ETUDID, JOUR, MATIN FROM ABSENCES A
|
"""SELECT ETUDID, JOUR, MATIN FROM ABSENCES A
|
||||||
WHERE A.ETUDID = %(etudid)s
|
WHERE A.ETUDID = %(etudid)s
|
||||||
@ -680,7 +680,7 @@ class ZAbsences(
|
|||||||
Si only_no_abs: seulement les justificatifs correspondant aux jours sans absences relevées.
|
Si only_no_abs: seulement les justificatifs correspondant aux jours sans absences relevées.
|
||||||
"""
|
"""
|
||||||
cnx = self.GetDBConnexion()
|
cnx = self.GetDBConnexion()
|
||||||
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
|
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
|
||||||
req = """SELECT DISTINCT ETUDID, JOUR, MATIN FROM ABSENCES A
|
req = """SELECT DISTINCT ETUDID, JOUR, MATIN FROM ABSENCES A
|
||||||
WHERE A.ETUDID = %(etudid)s
|
WHERE A.ETUDID = %(etudid)s
|
||||||
AND A.ESTJUST
|
AND A.ESTJUST
|
||||||
@ -704,7 +704,7 @@ class ZAbsences(
|
|||||||
"Description associee a l'absence"
|
"Description associee a l'absence"
|
||||||
if not cursor:
|
if not cursor:
|
||||||
cnx = self.GetDBConnexion()
|
cnx = self.GetDBConnexion()
|
||||||
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
|
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
|
||||||
a = a.copy()
|
a = a.copy()
|
||||||
# a['jour'] = a['jour'].date()
|
# a['jour'] = a['jour'].date()
|
||||||
if a["matin"]: # devrait etre booleen... :-(
|
if a["matin"]: # devrait etre booleen... :-(
|
||||||
@ -732,7 +732,6 @@ class ZAbsences(
|
|||||||
|
|
||||||
if desc:
|
if desc:
|
||||||
return "(%s) %s" % (desc, module)
|
return "(%s) %s" % (desc, module)
|
||||||
return desc
|
|
||||||
if module:
|
if module:
|
||||||
return module
|
return module
|
||||||
return ""
|
return ""
|
||||||
@ -745,7 +744,7 @@ class ZAbsences(
|
|||||||
is_just: idem
|
is_just: idem
|
||||||
"""
|
"""
|
||||||
cnx = self.GetDBConnexion()
|
cnx = self.GetDBConnexion()
|
||||||
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
|
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
|
||||||
req = """SELECT DISTINCT etudid, jour, matin FROM ABSENCES A
|
req = """SELECT DISTINCT etudid, jour, matin FROM ABSENCES A
|
||||||
WHERE A.jour = %(date)s
|
WHERE A.jour = %(date)s
|
||||||
"""
|
"""
|
||||||
@ -769,7 +768,7 @@ class ZAbsences(
|
|||||||
def ListeAbsNonJustJour(self, date, am=True, pm=True):
|
def ListeAbsNonJustJour(self, date, am=True, pm=True):
|
||||||
"Liste des absences non justifiees ce jour"
|
"Liste des absences non justifiees ce jour"
|
||||||
cnx = self.GetDBConnexion()
|
cnx = self.GetDBConnexion()
|
||||||
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
|
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
|
||||||
reqa = ""
|
reqa = ""
|
||||||
if not am:
|
if not am:
|
||||||
reqa += " AND NOT matin "
|
reqa += " AND NOT matin "
|
||||||
@ -849,7 +848,7 @@ class ZAbsences(
|
|||||||
def CalSelectWeek(self, year=None, REQUEST=None):
|
def CalSelectWeek(self, year=None, REQUEST=None):
|
||||||
"display calendar allowing week selection"
|
"display calendar allowing week selection"
|
||||||
if not year:
|
if not year:
|
||||||
year = AnneeScolaire(REQUEST)
|
year = scu.AnneeScolaire(REQUEST)
|
||||||
sems = sco_formsemestre.do_formsemestre_list(self)
|
sems = sco_formsemestre.do_formsemestre_list(self)
|
||||||
if not sems:
|
if not sems:
|
||||||
js = ""
|
js = ""
|
||||||
@ -886,10 +885,9 @@ class ZAbsences(
|
|||||||
security.declareProtected(ScoView, "ListMondays")
|
security.declareProtected(ScoView, "ListMondays")
|
||||||
|
|
||||||
def ListMondays(self, year=None, REQUEST=None):
|
def ListMondays(self, year=None, REQUEST=None):
|
||||||
"""return list of mondays (ISO dates), from september to june
|
"""return list of mondays (ISO dates), from september to june"""
|
||||||
"""
|
|
||||||
if not year:
|
if not year:
|
||||||
year = AnneeScolaire(REQUEST)
|
year = scu.AnneeScolaire(REQUEST)
|
||||||
d = ddmmyyyy("1/9/%d" % year, work_saturday=self.is_work_saturday())
|
d = ddmmyyyy("1/9/%d" % year, work_saturday=self.is_work_saturday())
|
||||||
while d.weekday != 0:
|
while d.weekday != 0:
|
||||||
d = d.next()
|
d = d.next()
|
||||||
@ -934,7 +932,7 @@ class ZAbsences(
|
|||||||
):
|
):
|
||||||
"Saisie hebdomadaire des absences"
|
"Saisie hebdomadaire des absences"
|
||||||
if not moduleimpl_id:
|
if not moduleimpl_id:
|
||||||
moduleimp_id = None
|
moduleimpl_id = None
|
||||||
|
|
||||||
groups_infos = sco_groups_view.DisplayedGroupsInfos(
|
groups_infos = sco_groups_view.DisplayedGroupsInfos(
|
||||||
self, group_ids, REQUEST=REQUEST
|
self, group_ids, REQUEST=REQUEST
|
||||||
@ -963,10 +961,10 @@ class ZAbsences(
|
|||||||
)[0]
|
)[0]
|
||||||
|
|
||||||
# calcule dates jours de cette semaine
|
# calcule dates jours de cette semaine
|
||||||
datessem = [DateDMYtoISO(datelundi)]
|
# liste de dates iso "yyyy-mm-dd"
|
||||||
for jour in self.day_names()[1:]:
|
datessem = [notesdb.DateDMYtoISO(datelundi)]
|
||||||
|
for _ in self.day_names()[1:]:
|
||||||
datessem.append(self.NextISODay(datessem[-1]))
|
datessem.append(self.NextISODay(datessem[-1]))
|
||||||
|
|
||||||
#
|
#
|
||||||
if groups_infos.tous_les_etuds_du_sem:
|
if groups_infos.tous_les_etuds_du_sem:
|
||||||
gr_tit = "en"
|
gr_tit = "en"
|
||||||
@ -1044,9 +1042,7 @@ class ZAbsences(
|
|||||||
% {"menu_module": menu_module, "url": base_url, "sel": sel}
|
% {"menu_module": menu_module, "url": base_url, "sel": sel}
|
||||||
)
|
)
|
||||||
|
|
||||||
H += self._gen_form_saisie_groupe(
|
H += self._gen_form_saisie_groupe(etuds, datessem, destination, moduleimpl_id)
|
||||||
etuds, self.day_names(), datessem, destination, None, moduleimpl_id
|
|
||||||
)
|
|
||||||
|
|
||||||
H.append(self.sco_footer(REQUEST))
|
H.append(self.sco_footer(REQUEST))
|
||||||
return "\n".join(H)
|
return "\n".join(H)
|
||||||
@ -1063,8 +1059,7 @@ class ZAbsences(
|
|||||||
moduleimpl_id=None,
|
moduleimpl_id=None,
|
||||||
REQUEST=None,
|
REQUEST=None,
|
||||||
):
|
):
|
||||||
"""Saisie des absences sur une journée sur un semestre (ou intervalle de dates) entier
|
"""Saisie des absences sur une journée sur un semestre (ou intervalle de dates) entier"""
|
||||||
"""
|
|
||||||
# log('SignaleAbsenceGrSemestre: moduleimpl_id=%s destination=%s' % (moduleimpl_id, destination))
|
# log('SignaleAbsenceGrSemestre: moduleimpl_id=%s destination=%s' % (moduleimpl_id, destination))
|
||||||
groups_infos = sco_groups_view.DisplayedGroupsInfos(
|
groups_infos = sco_groups_view.DisplayedGroupsInfos(
|
||||||
self, group_ids, REQUEST=REQUEST
|
self, group_ids, REQUEST=REQUEST
|
||||||
@ -1083,16 +1078,13 @@ class ZAbsences(
|
|||||||
]
|
]
|
||||||
|
|
||||||
if not moduleimpl_id:
|
if not moduleimpl_id:
|
||||||
moduleimp_id = None
|
moduleimpl_id = None
|
||||||
base_url_noweeks = (
|
base_url_noweeks = "SignaleAbsenceGrSemestre?datedebut=%s&datefin=%s&%s&destination=%s" % (
|
||||||
"SignaleAbsenceGrSemestre?datedebut=%s&datefin=%s&%s&destination=%s"
|
|
||||||
% (
|
|
||||||
datedebut,
|
datedebut,
|
||||||
datefin,
|
datefin,
|
||||||
groups_infos.groups_query_args,
|
groups_infos.groups_query_args,
|
||||||
urllib.quote(destination),
|
urllib.quote(destination),
|
||||||
)
|
)
|
||||||
)
|
|
||||||
base_url = (
|
base_url = (
|
||||||
base_url_noweeks + "&nbweeks=%s" % nbweeks
|
base_url_noweeks + "&nbweeks=%s" % nbweeks
|
||||||
) # sans le moduleimpl_id
|
) # sans le moduleimpl_id
|
||||||
@ -1139,7 +1131,6 @@ class ZAbsences(
|
|||||||
if moduleimpl_id:
|
if moduleimpl_id:
|
||||||
url_link_semaines += "&moduleimpl_id=" + moduleimpl_id
|
url_link_semaines += "&moduleimpl_id=" + moduleimpl_id
|
||||||
#
|
#
|
||||||
colnames = [str(x) for x in dates]
|
|
||||||
dates = [x.ISO() for x in dates]
|
dates = [x.ISO() for x in dates]
|
||||||
dayname = self.day_names()[jourdebut.weekday]
|
dayname = self.day_names()[jourdebut.weekday]
|
||||||
|
|
||||||
@ -1217,15 +1208,18 @@ class ZAbsences(
|
|||||||
% {"menu_module": menu_module, "url": base_url, "sel": sel}
|
% {"menu_module": menu_module, "url": base_url, "sel": sel}
|
||||||
)
|
)
|
||||||
|
|
||||||
H += self._gen_form_saisie_groupe(
|
H += self._gen_form_saisie_groupe(etuds, dates, destination, moduleimpl_id)
|
||||||
etuds, colnames, dates, destination, dayname, moduleimpl_id
|
|
||||||
)
|
|
||||||
H.append(self.sco_footer(REQUEST))
|
H.append(self.sco_footer(REQUEST))
|
||||||
return "\n".join(H)
|
return "\n".join(H)
|
||||||
|
|
||||||
def _gen_form_saisie_groupe(
|
def _gen_form_saisie_groupe(self, etuds, dates, destination="", moduleimpl_id=None):
|
||||||
self, etuds, colnames, dates, destination="", dayname="", moduleimpl_id=None
|
"""Formulaire saisie absences
|
||||||
):
|
|
||||||
|
Args:
|
||||||
|
etuds: liste des étudiants
|
||||||
|
dates: liste de dates iso, par exemple: [ '2020-12-24', ... ]
|
||||||
|
moduleimpl_id: optionnel, module concerné.
|
||||||
|
"""
|
||||||
H = [
|
H = [
|
||||||
"""
|
"""
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@ -1252,25 +1246,29 @@ class ZAbsences(
|
|||||||
"""
|
"""
|
||||||
% len(etuds)
|
% len(etuds)
|
||||||
]
|
]
|
||||||
|
# Dates
|
||||||
|
odates = [datetime.date(*[int(x) for x in d.split("-")]) for d in dates]
|
||||||
# Titres colonnes
|
# Titres colonnes
|
||||||
if dayname:
|
noms_jours = [] # eg [ "Lundi", "mardi", "Samedi", ... ]
|
||||||
for jour in colnames:
|
jn = self.day_names()
|
||||||
H.append(
|
for d in odates:
|
||||||
'<th colspan="2" width="100px" style="padding-left: 5px; padding-right: 5px;">'
|
idx_jour = d.weekday()
|
||||||
+ dayname
|
noms_jours.append(jn[idx_jour])
|
||||||
+ "</th>"
|
for jour in noms_jours:
|
||||||
)
|
|
||||||
H.append("</tr><tr><td> </td>")
|
|
||||||
|
|
||||||
for jour in colnames:
|
|
||||||
H.append(
|
H.append(
|
||||||
'<th colspan="2" width="100px" style="padding-left: 5px; padding-right: 5px;">'
|
'<th colspan="2" width="100px" style="padding-left: 5px; padding-right: 5px;">'
|
||||||
+ jour
|
+ jour
|
||||||
+ "</th>"
|
+ "</th>"
|
||||||
)
|
)
|
||||||
|
|
||||||
H.append("</tr><tr><td> </td>")
|
H.append("</tr><tr><td> </td>")
|
||||||
H.append("<th>AM</th><th>PM</th>" * len(colnames))
|
for d in odates:
|
||||||
|
H.append(
|
||||||
|
'<th colspan="2" width="100px" style="padding-left: 5px; padding-right: 5px;">'
|
||||||
|
+ d.strftime("%d/%m/%Y")
|
||||||
|
+ "</th>"
|
||||||
|
)
|
||||||
|
H.append("</tr><tr><td> </td>")
|
||||||
|
H.append("<th>AM</th><th>PM</th>" * len(dates))
|
||||||
H.append("</tr>")
|
H.append("</tr>")
|
||||||
#
|
#
|
||||||
if not etuds:
|
if not etuds:
|
||||||
@ -1373,14 +1371,13 @@ class ZAbsences(
|
|||||||
absjust_only=0,
|
absjust_only=0,
|
||||||
REQUEST=None,
|
REQUEST=None,
|
||||||
):
|
):
|
||||||
"""Tables des absences justifiees et non justifiees d'un étudiant sur l'année en cours
|
"""Tables des absences justifiees et non justifiees d'un étudiant sur l'année en cours"""
|
||||||
"""
|
|
||||||
absjust = self.ListeAbsJust(etudid=etudid, datedebut=datedebut)
|
absjust = self.ListeAbsJust(etudid=etudid, datedebut=datedebut)
|
||||||
absnonjust = self.ListeAbsNonJust(etudid=etudid, datedebut=datedebut)
|
absnonjust = self.ListeAbsNonJust(etudid=etudid, datedebut=datedebut)
|
||||||
# examens ces jours là ?
|
# examens ces jours là ?
|
||||||
if with_evals:
|
if with_evals:
|
||||||
cnx = self.GetDBConnexion()
|
cnx = self.GetDBConnexion()
|
||||||
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
|
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
|
||||||
for a in absnonjust + absjust:
|
for a in absnonjust + absjust:
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"""select eval.*
|
"""select eval.*
|
||||||
@ -1499,10 +1496,9 @@ class ZAbsences(
|
|||||||
format="html",
|
format="html",
|
||||||
REQUEST=None,
|
REQUEST=None,
|
||||||
):
|
):
|
||||||
"""Liste les absences de groupes
|
"""Liste les absences de groupes"""
|
||||||
"""
|
datedebut = notesdb.DateDMYtoISO(debut)
|
||||||
datedebut = DateDMYtoISO(debut)
|
datefin = notesdb.DateDMYtoISO(fin)
|
||||||
datefin = DateDMYtoISO(fin)
|
|
||||||
# Informations sur les groupes à afficher:
|
# Informations sur les groupes à afficher:
|
||||||
groups_infos = sco_groups_view.DisplayedGroupsInfos(
|
groups_infos = sco_groups_view.DisplayedGroupsInfos(
|
||||||
self, group_ids, REQUEST=REQUEST
|
self, group_ids, REQUEST=REQUEST
|
||||||
@ -1603,7 +1599,7 @@ class ZAbsences(
|
|||||||
base_url="%s&formsemestre_id=%s&debut=%s&fin=%s"
|
base_url="%s&formsemestre_id=%s&debut=%s&fin=%s"
|
||||||
% (groups_infos.base_url, formsemestre_id, debut, fin),
|
% (groups_infos.base_url, formsemestre_id, debut, fin),
|
||||||
filename="etat_abs_"
|
filename="etat_abs_"
|
||||||
+ make_filename(
|
+ scu.make_filename(
|
||||||
"%s de %s" % (groups_infos.groups_filename, sem["titreannee"])
|
"%s de %s" % (groups_infos.groups_filename, sem["titreannee"])
|
||||||
),
|
),
|
||||||
caption=title,
|
caption=title,
|
||||||
@ -1632,26 +1628,20 @@ ou entrez une date pour visualiser les absents un jour donné :
|
|||||||
def EtatAbsencesDate(
|
def EtatAbsencesDate(
|
||||||
self, group_ids=[], date=None, REQUEST=None # list of groups to display
|
self, group_ids=[], date=None, REQUEST=None # list of groups to display
|
||||||
):
|
):
|
||||||
"""Etat des absences pour un groupe à une date donnée
|
"""Etat des absences pour un groupe à une date donnée"""
|
||||||
"""
|
|
||||||
# Informations sur les groupes à afficher:
|
# Informations sur les groupes à afficher:
|
||||||
groups_infos = sco_groups_view.DisplayedGroupsInfos(
|
groups_infos = sco_groups_view.DisplayedGroupsInfos(
|
||||||
self, group_ids, REQUEST=REQUEST
|
self, group_ids, REQUEST=REQUEST
|
||||||
)
|
)
|
||||||
formsemestre_id = groups_infos.formsemestre_id
|
|
||||||
sem = sco_formsemestre.do_formsemestre_list(
|
|
||||||
self, {"formsemestre_id": formsemestre_id}
|
|
||||||
)[0]
|
|
||||||
H = [self.sco_header(page_title="Etat des absences", REQUEST=REQUEST)]
|
H = [self.sco_header(page_title="Etat des absences", REQUEST=REQUEST)]
|
||||||
if date:
|
if date:
|
||||||
dateiso = DateDMYtoISO(date)
|
dateiso = notesdb.DateDMYtoISO(date)
|
||||||
nbetud = 0
|
nbetud = 0
|
||||||
t_nbabsjustam = 0
|
t_nbabsjustam = 0
|
||||||
t_nbabsam = 0
|
t_nbabsam = 0
|
||||||
t_nbabsjustpm = 0
|
t_nbabsjustpm = 0
|
||||||
t_nbabspm = 0
|
t_nbabspm = 0
|
||||||
etuds = self.getEtudInfoGroupes(groups_infos.group_ids)
|
H.append("<h2>État des absences le %s</h2>" % date)
|
||||||
H.append("<h2>Etat des absences le %s</h2>" % date)
|
|
||||||
H.append(
|
H.append(
|
||||||
"""<table border="0" cellspacing="4" cellpadding="0">
|
"""<table border="0" cellspacing="4" cellpadding="0">
|
||||||
<tr><th> </th>
|
<tr><th> </th>
|
||||||
@ -1738,7 +1728,7 @@ ou entrez une date pour visualiser les absents un jour donné :
|
|||||||
etudid=etudid, code_nip=code_nip, REQUEST=REQUEST, filled=True
|
etudid=etudid, code_nip=code_nip, REQUEST=REQUEST, filled=True
|
||||||
)
|
)
|
||||||
if not etuds:
|
if not etuds:
|
||||||
return log_unknown_etud(self, REQUEST=REQUEST)
|
return scu.log_unknown_etud(self, REQUEST=REQUEST)
|
||||||
etud = etuds[0]
|
etud = etuds[0]
|
||||||
# check dates
|
# check dates
|
||||||
begin_date = ParseDateTimeUTC(begin) # may raises ValueError
|
begin_date = ParseDateTimeUTC(begin) # may raises ValueError
|
||||||
@ -1763,7 +1753,7 @@ ou entrez une date pour visualiser les absents un jour donné :
|
|||||||
if xml_reply:
|
if xml_reply:
|
||||||
# Renvoie le nouveau billet en XML
|
# Renvoie le nouveau billet en XML
|
||||||
if REQUEST:
|
if REQUEST:
|
||||||
REQUEST.RESPONSE.setHeader("content-type", XML_MIMETYPE)
|
REQUEST.RESPONSE.setHeader("content-type", scu.XML_MIMETYPE)
|
||||||
|
|
||||||
billets = billet_absence_list(cnx, {"billet_id": billet_id})
|
billets = billet_absence_list(cnx, {"billet_id": billet_id})
|
||||||
tab = self._tableBillets(billets, etud=etud)
|
tab = self._tableBillets(billets, etud=etud)
|
||||||
@ -1884,11 +1874,10 @@ ou entrez une date pour visualiser les absents un jour donné :
|
|||||||
security.declareProtected(ScoView, "listeBilletsEtud")
|
security.declareProtected(ScoView, "listeBilletsEtud")
|
||||||
|
|
||||||
def listeBilletsEtud(self, etudid=False, REQUEST=None, format="html"):
|
def listeBilletsEtud(self, etudid=False, REQUEST=None, format="html"):
|
||||||
"""Liste billets pour un etudiant
|
"""Liste billets pour un etudiant"""
|
||||||
"""
|
|
||||||
etuds = self.getEtudInfo(etudid=etudid, filled=1, REQUEST=REQUEST)
|
etuds = self.getEtudInfo(etudid=etudid, filled=1, REQUEST=REQUEST)
|
||||||
if not etuds:
|
if not etuds:
|
||||||
return log_unknown_etud(self, format=format, REQUEST=REQUEST)
|
return scu.log_unknown_etud(self, format=format, REQUEST=REQUEST)
|
||||||
|
|
||||||
etud = etuds[0]
|
etud = etuds[0]
|
||||||
cnx = self.GetDBConnexion()
|
cnx = self.GetDBConnexion()
|
||||||
@ -1899,8 +1888,7 @@ ou entrez une date pour visualiser les absents un jour donné :
|
|||||||
security.declareProtected(ScoView, "XMLgetBilletsEtud")
|
security.declareProtected(ScoView, "XMLgetBilletsEtud")
|
||||||
|
|
||||||
def XMLgetBilletsEtud(self, etudid=False, REQUEST=None):
|
def XMLgetBilletsEtud(self, etudid=False, REQUEST=None):
|
||||||
"""Liste billets pour un etudiant
|
"""Liste billets pour un etudiant"""
|
||||||
"""
|
|
||||||
if not self.get_preference("handle_billets_abs"):
|
if not self.get_preference("handle_billets_abs"):
|
||||||
return ""
|
return ""
|
||||||
t0 = time.time()
|
t0 = time.time()
|
||||||
@ -1937,8 +1925,7 @@ ou entrez une date pour visualiser les absents un jour donné :
|
|||||||
security.declareProtected(ScoAbsChange, "deleteBilletAbsence")
|
security.declareProtected(ScoAbsChange, "deleteBilletAbsence")
|
||||||
|
|
||||||
def deleteBilletAbsence(self, billet_id, REQUEST=None, dialog_confirmed=False):
|
def deleteBilletAbsence(self, billet_id, REQUEST=None, dialog_confirmed=False):
|
||||||
"""Supprime un billet.
|
"""Supprime un billet."""
|
||||||
"""
|
|
||||||
cnx = self.GetDBConnexion()
|
cnx = self.GetDBConnexion()
|
||||||
billets = billet_absence_list(cnx, {"billet_id": billet_id})
|
billets = billet_absence_list(cnx, {"billet_id": billet_id})
|
||||||
if not billets:
|
if not billets:
|
||||||
@ -2107,8 +2094,8 @@ ou entrez une date pour visualiser les absents un jour donné :
|
|||||||
|
|
||||||
Abs = self._ListeAbsDate(etud["etudid"], beg_date, end_date)
|
Abs = self._ListeAbsDate(etud["etudid"], beg_date, end_date)
|
||||||
|
|
||||||
REQUEST.RESPONSE.setHeader("content-type", XML_MIMETYPE)
|
REQUEST.RESPONSE.setHeader("content-type", scu.XML_MIMETYPE)
|
||||||
doc = jaxml.XML_document(encoding=SCO_ENCODING)
|
doc = jaxml.XML_document(encoding=scu.SCO_ENCODING)
|
||||||
doc.absences(etudid=etud["etudid"], beg_date=beg_date, end_date=end_date)
|
doc.absences(etudid=etud["etudid"], beg_date=beg_date, end_date=end_date)
|
||||||
doc._push()
|
doc._push()
|
||||||
for a in Abs:
|
for a in Abs:
|
||||||
@ -2126,7 +2113,7 @@ ou entrez une date pour visualiser les absents un jour donné :
|
|||||||
return repr(doc)
|
return repr(doc)
|
||||||
|
|
||||||
|
|
||||||
_billet_absenceEditor = EditableTable(
|
_billet_absenceEditor = notesdb.EditableTable(
|
||||||
"billet_absence",
|
"billet_absence",
|
||||||
"billet_id",
|
"billet_id",
|
||||||
(
|
(
|
||||||
@ -2210,7 +2197,6 @@ def MonthTableTail():
|
|||||||
def MonthTableBody(
|
def MonthTableBody(
|
||||||
month, year, events=[], halfday=0, trattributes="", work_saturday=False, pad_width=8
|
month, year, events=[], halfday=0, trattributes="", work_saturday=False, pad_width=8
|
||||||
):
|
):
|
||||||
# log('XXX events=%s' % events)
|
|
||||||
firstday, nbdays = calendar.monthrange(year, month)
|
firstday, nbdays = calendar.monthrange(year, month)
|
||||||
localtime = time.localtime()
|
localtime = time.localtime()
|
||||||
current_weeknum = time.strftime("%U", localtime)
|
current_weeknum = time.strftime("%U", localtime)
|
||||||
@ -2443,8 +2429,8 @@ class CAbsSemEtud:
|
|||||||
self.sem = sco_formsemestre.get_formsemestre(
|
self.sem = sco_formsemestre.get_formsemestre(
|
||||||
self.context, self.sem["formsemestre_id"]
|
self.context, self.sem["formsemestre_id"]
|
||||||
)
|
)
|
||||||
debut_sem = DateDMYtoISO(self.sem["date_debut"])
|
debut_sem = notesdb.DateDMYtoISO(self.sem["date_debut"])
|
||||||
fin_sem = DateDMYtoISO(self.sem["date_fin"])
|
fin_sem = notesdb.DateDMYtoISO(self.sem["date_fin"])
|
||||||
|
|
||||||
self._CountAbs = self.context.Absences.CountAbs(
|
self._CountAbs = self.context.Absences.CountAbs(
|
||||||
etudid=self.etudid, debut=debut_sem, fin=fin_sem
|
etudid=self.etudid, debut=debut_sem, fin=fin_sem
|
||||||
|
Loading…
Reference in New Issue
Block a user