diff --git a/sco_debouche.py b/sco_debouche.py index 360818d8..2b50cdd9 100644 --- a/sco_debouche.py +++ b/sco_debouche.py @@ -28,12 +28,14 @@ """ Rapport (table) avec dernier semestre fréquenté et débouché de chaque étudiant """ - +from types import StringType import safehtml -from notesdb import * -from sco_utils import * +import sco_utils as scu +import notesdb from notes_log import log +import VERSION +from sco_exceptions import AccessDenied from scolog import logdb from gen_tables import GenTable import sco_formsemestre @@ -42,8 +44,7 @@ import sco_tag_module def report_debouche_date(context, start_year=None, format="html", REQUEST=None): - """Rapport (table) pour les débouchés des étudiants sortis à partir de l'année indiquée. - """ + """Rapport (table) pour les débouchés des étudiants sortis à partir de l'année indiquée.""" if not start_year: return report_debouche_ask_date(context, REQUEST=REQUEST) if format == "xls": @@ -54,8 +55,8 @@ def report_debouche_date(context, start_year=None, format="html", REQUEST=None): etudids = get_etudids_with_debouche(context, start_year) tab = table_debouche_etudids(context, etudids, keep_numeric=keep_numeric) - tab.filename = make_filename("debouche_scodoc_%s" % start_year) - tab.origin = "Généré par %s le " % VERSION.SCONAME + timedate_human_repr() + "" + tab.filename = scu.make_filename("debouche_scodoc_%s" % start_year) + tab.origin = "Généré par %s le " % VERSION.SCONAME + scu.timedate_human_repr() + "" tab.caption = "Récapitulatif débouchés à partir du 1/1/%s." % start_year tab.base_url = "%s?start_year=%s" % (REQUEST.URL0, start_year) return tab.make_page( @@ -77,7 +78,7 @@ def get_etudids_with_debouche(context, start_year): start_date = str(start_year) + "-01-01" # Recupere tous les etudid avec un debouché renseigné et une inscription dans un semestre # posterieur à la date de depart: - # r = SimpleDictFetch(context, + # r = notesdb.SimpleDictFetch(context, # """SELECT DISTINCT i.etudid # FROM notes_formsemestre_inscription i, admissions adm, notes_formsemestre s # WHERE adm.debouche is not NULL @@ -86,7 +87,7 @@ def get_etudids_with_debouche(context, start_year): # """, # {'start_date' : start_date }) - r = SimpleDictFetch( + r = notesdb.SimpleDictFetch( context, """SELECT DISTINCT i.etudid FROM notes_formsemestre_inscription i, notes_formsemestre s, itemsuivi it @@ -100,8 +101,7 @@ def get_etudids_with_debouche(context, start_year): def table_debouche_etudids(context, etudids, keep_numeric=True): - """Rapport pour ces etudiants - """ + """Rapport pour ces etudiants""" L = [] for etudid in etudids: etud = context.getEtudInfo(filled=1, etudid=etudid)[0] @@ -122,7 +122,7 @@ def table_debouche_etudids(context, etudids, keep_numeric=True): "_prenom_target": "ficheEtud?etudid=" + etud["etudid"], "_nom_td_attrs": 'id="%s" class="etudinfo"' % (etud["etudid"]), # 'debouche' : etud['debouche'], - "moy": fmt_note(nt.get_etud_moy_gen(etudid), keep_numeric=keep_numeric), + "moy": scu.fmt_note(nt.get_etud_moy_gen(etudid), keep_numeric=keep_numeric), "rang": nt.get_etud_rang(etudid), "effectif": len(nt.T), "semestre_id": last_sem["semestre_id"], @@ -189,8 +189,7 @@ def table_debouche_etudids(context, etudids, keep_numeric=True): def report_debouche_ask_date(context, REQUEST=None): - """Formulaire demande date départ - """ + """Formulaire demande date départ""" return ( context.sco_header(REQUEST) + """
@@ -223,14 +222,17 @@ def report_debouche_ask_date(context, REQUEST=None): # admission_edit(cnx, adm) -_itemsuiviEditor = EditableTable( +_itemsuiviEditor = notesdb.EditableTable( "itemsuivi", "itemsuivi_id", ("itemsuivi_id", "etudid", "item_date", "situation"), sortkey="item_date desc", convert_null_outputs_to_empty=True, - output_formators={"situation": safehtml.HTML2SafeHTML, "item_date": DateISOtoDMY}, - input_formators={"item_date": DateDMYtoISO}, + output_formators={ + "situation": safehtml.HTML2SafeHTML, + "item_date": notesdb.DateISOtoDMY, + }, + input_formators={"item_date": notesdb.DateDMYtoISO}, ) _itemsuivi_create = _itemsuiviEditor.create @@ -240,8 +242,7 @@ _itemsuivi_edit = _itemsuiviEditor.edit class ItemSuiviTag(sco_tag_module.ScoTag): - """Les tags sur les items - """ + """Les tags sur les items""" tag_table = "itemsuivi_tags" # table (tag_id, title) assoc_table = "itemsuivi_tags_assoc" # table (tag_id, object_id) @@ -259,8 +260,7 @@ def itemsuivi_get(cnx, itemsuivi_id, ignore_errors=False): def itemsuivi_suppress(context, itemsuivi_id, REQUEST=None): - """Suppression d'un item - """ + """Suppression d'un item""" if not context.can_edit_suivi(REQUEST): raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !") cnx = context.GetDBConnexion() @@ -285,7 +285,7 @@ def itemsuivi_create( log("created itemsuivi %s for %s" % (itemsuivi_id, etudid)) item = itemsuivi_get(cnx, itemsuivi_id) if format == "json": - return sendJSON(REQUEST, item) + return scu.sendJSON(REQUEST, item) return item @@ -313,7 +313,7 @@ def itemsuivi_set_situation(context, object, value, REQUEST=None): item = itemsuivi_get(cnx, itemsuivi_id) item["situation"] = situation _itemsuivi_edit(cnx, item) - return situation or IT_SITUATION_MISSING_STR + return situation or scu.IT_SITUATION_MISSING_STR def itemsuivi_list_etud(context, etudid, format=None, REQUEST=None): @@ -323,13 +323,13 @@ def itemsuivi_list_etud(context, etudid, format=None, REQUEST=None): for it in items: it["tags"] = ", ".join(itemsuivi_tag_list(context, it["itemsuivi_id"])) if format == "json": - return sendJSON(REQUEST, items) + return scu.sendJSON(REQUEST, items) return items def itemsuivi_tag_list(context, itemsuivi_id): """les noms de tags associés à cet item""" - r = SimpleDictFetch( + r = notesdb.SimpleDictFetch( context, """SELECT t.title FROM itemsuivi_tags_assoc a, itemsuivi_tags t @@ -344,17 +344,17 @@ def itemsuivi_tag_list(context, itemsuivi_id): def itemsuivi_tag_search(context, term, REQUEST=None): """List all used tag names (for auto-completion)""" # restrict charset to avoid injections - if not ALPHANUM_EXP.match(term.decode(SCO_ENCODING)): + if not scu.ALPHANUM_EXP.match(term.decode(scu.SCO_ENCODING)): data = [] else: - r = SimpleDictFetch( + r = notesdb.SimpleDictFetch( context, "SELECT title FROM itemsuivi_tags WHERE title LIKE %(term)s", {"term": term + "%"}, ) data = [x["title"] for x in r] - return sendJSON(REQUEST, data) + return scu.sendJSON(REQUEST, data) def itemsuivi_tag_set(context, itemsuivi_id="", taglist=[], REQUEST=None): @@ -372,7 +372,7 @@ def itemsuivi_tag_set(context, itemsuivi_id="", taglist=[], REQUEST=None): # log('itemsuivi_tag_set: itemsuivi_id=%s taglist=%s' % (itemsuivi_id, taglist)) # Sanity check: cnx = context.GetDBConnexion() - item = itemsuivi_get(cnx, itemsuivi_id) + _ = itemsuivi_get(cnx, itemsuivi_id) newtags = set(taglist) oldtags = set(itemsuivi_tag_list(context, itemsuivi_id))