forked from ScoDoc/ScoDoc
pylinting
This commit is contained in:
parent
a4173e1877
commit
1576a64ccd
@ -35,7 +35,6 @@ import pprint
|
||||
from sco_zope import * # pylint: disable=unused-wildcard-import
|
||||
|
||||
# ---------------
|
||||
# from sco_utils import *
|
||||
import sco_utils as scu
|
||||
import notesdb as ndb
|
||||
from notes_log import log, sendAlarm
|
||||
|
163
ZScolar.py
163
ZScolar.py
@ -30,8 +30,15 @@
|
||||
|
||||
import sys
|
||||
import traceback
|
||||
import time, string, glob, re
|
||||
import urllib, urllib2, cgi, xml
|
||||
import time
|
||||
import string
|
||||
import glob
|
||||
import re
|
||||
import urllib
|
||||
import urllib2
|
||||
import cgi
|
||||
import xml
|
||||
import jaxml
|
||||
|
||||
try:
|
||||
from cStringIO import StringIO
|
||||
@ -41,7 +48,7 @@ from zipfile import ZipFile
|
||||
import thread
|
||||
import psycopg2
|
||||
|
||||
from sco_zope import *
|
||||
from sco_zope import * # pylint: disable=unused-wildcard-import
|
||||
|
||||
|
||||
# ---------------
|
||||
@ -53,12 +60,40 @@ log("restarting...")
|
||||
log("ZScolar home=%s" % file_path)
|
||||
|
||||
|
||||
from sco_utils import *
|
||||
import notesdb
|
||||
from notesdb import *
|
||||
import sco_utils as scu
|
||||
import notesdb as ndb
|
||||
from scolog import logdb
|
||||
|
||||
from sco_permissions import (
|
||||
ScoAbsChange,
|
||||
ScoView,
|
||||
ScoEnsView,
|
||||
ScoImplement,
|
||||
ScoChangeFormation,
|
||||
ScoChangePreferences,
|
||||
ScoObservateur,
|
||||
ScoEtudAddAnnotations,
|
||||
ScoEtudInscrit,
|
||||
ScoEtudChangeGroups,
|
||||
ScoEtudChangeAdr,
|
||||
ScoEtudSupprAnnotations,
|
||||
ScoEditAllEvals,
|
||||
ScoEditAllNotes,
|
||||
ScoEditFormationTags,
|
||||
ScoEditApo,
|
||||
ScoSuperAdmin,
|
||||
)
|
||||
import sco_permissions
|
||||
from sco_exceptions import (
|
||||
AccessDenied,
|
||||
ScoException,
|
||||
ScoValueError,
|
||||
ScoInvalidDateError,
|
||||
ScoLockedFormError,
|
||||
ScoGenError,
|
||||
)
|
||||
from TrivialFormulator import TrivialFormulator, tf_error_message
|
||||
import scolars
|
||||
import sco_codes_parcours
|
||||
import sco_preferences
|
||||
import sco_formations
|
||||
from scolars import (
|
||||
@ -110,9 +145,9 @@ import sco_dump_db
|
||||
|
||||
from VERSION import SCOVERSION, SCONEWS
|
||||
|
||||
if hasattr(CONFIG, "ABSOLUTE_URL") and CONFIG.ABSOLUTE_URL:
|
||||
log("ScoDoc: ABSOLUTE_URL='%s'" % CONFIG.ABSOLUTE_URL)
|
||||
log("ScoDoc: using encoding %s" % SCO_ENCODING)
|
||||
if hasattr(scu.CONFIG, "ABSOLUTE_URL") and scu.CONFIG.ABSOLUTE_URL:
|
||||
log("ScoDoc: ABSOLUTE_URL='%s'" % scu.CONFIG.ABSOLUTE_URL)
|
||||
log("ScoDoc: using encoding %s" % scu.SCO_ENCODING)
|
||||
|
||||
# import essai_cas
|
||||
|
||||
@ -197,8 +232,10 @@ class ZScolar(ObjectManager, PropertyManager, RoleManager, Item, Persistent, Imp
|
||||
H.append(r)
|
||||
ok = False
|
||||
|
||||
for permission in Sco_Default_Permissions.keys():
|
||||
roles = [r + DeptId for r in Sco_Default_Permissions[permission]]
|
||||
for permission in sco_permissions.Sco_Default_Permissions.keys():
|
||||
roles = [
|
||||
r + DeptId for r in sco_permissions.Sco_Default_Permissions[permission]
|
||||
]
|
||||
roles.append("Manager")
|
||||
log("granting '%s' to %s" % (permission, roles))
|
||||
try:
|
||||
@ -271,7 +308,7 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
|
||||
# raise ValueError("essai exception")
|
||||
# raise ScoValueError('essai exception !', dest_url='totoro', REQUEST=REQUEST)
|
||||
|
||||
# cursor = cnx.cursor(cursor_factory=ScoDocCursor)
|
||||
# cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
|
||||
# cursor.execute("select * from notes_formations")
|
||||
# b += str(cursor.fetchall())
|
||||
# b = self.Notes.gloups()
|
||||
@ -306,7 +343,7 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
|
||||
|
||||
authuser = REQUEST.AUTHENTICATED_USER
|
||||
for p in scoperms:
|
||||
permname, value = p[:2]
|
||||
permname, _ = p[:2]
|
||||
b += "<p>" + permname + " : "
|
||||
if authuser.has_permission(permname, self):
|
||||
b += "yes"
|
||||
@ -330,7 +367,7 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
|
||||
# absolute_url is the classic Zope method
|
||||
# The avoid the burden of configuring a proxy zope object, we offer
|
||||
# a custom configuration via scodoc_config
|
||||
return CONFIG.ABSOLUTE_URL or self.absolute_url()
|
||||
return scu.CONFIG.ABSOLUTE_URL or self.absolute_url()
|
||||
|
||||
security.declareProtected(ScoView, "sco_header")
|
||||
sco_header = html_sco_header.sco_header
|
||||
@ -349,7 +386,7 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
|
||||
return self._db_cnx_string
|
||||
|
||||
security.declareProtected(ScoSuperAdmin, "GetDBConnexion")
|
||||
GetDBConnexion = notesdb.GetDBConnexion
|
||||
GetDBConnexion = ndb.GetDBConnexion
|
||||
|
||||
# A enlever après re-ecriture de ZEntreprises.py
|
||||
security.declareProtected(ScoView, "TrivialFormulator")
|
||||
@ -395,7 +432,7 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
|
||||
<p>© Emmanuel Viennet 1997-2021</p>
|
||||
<p>Version %s (subversion %s)</p>
|
||||
"""
|
||||
% (SCOVERSION, get_svn_version(file_path))
|
||||
% (SCOVERSION, scu.get_svn_version(file_path))
|
||||
]
|
||||
H.append(
|
||||
'<p>Logiciel libre écrit en <a href="http://www.python.org">Python</a>.</p><p>Utilise <a href="http://www.reportlab.org/">ReportLab</a> pour générer les documents PDF, et <a href="http://sourceforge.net/projects/pyexcelerator">pyExcelerator</a> pour le traitement des documents Excel.</p>'
|
||||
@ -403,7 +440,7 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
|
||||
H.append("<h2>Dernières évolutions</h2>" + SCONEWS)
|
||||
H.append(
|
||||
'<div class="about-logo">'
|
||||
+ icontag("borgne_img")
|
||||
+ scu.icontag("borgne_img")
|
||||
+ " <em>Au pays des aveugles...</em></div>"
|
||||
)
|
||||
d = ""
|
||||
@ -417,12 +454,12 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
|
||||
if format == "html" or format == "pdf":
|
||||
raise ScoValueError(msg)
|
||||
elif format == "xml":
|
||||
REQUEST.RESPONSE.setHeader("content-type", XML_MIMETYPE)
|
||||
doc = jaxml.XML_document(encoding=SCO_ENCODING)
|
||||
REQUEST.RESPONSE.setHeader("content-type", scu.XML_MIMETYPE)
|
||||
doc = jaxml.XML_document(encoding=scu.SCO_ENCODING)
|
||||
doc.error(msg=msg)
|
||||
return repr(doc)
|
||||
elif format == "json":
|
||||
REQUEST.RESPONSE.setHeader("content-type", JSON_MIMETYPE)
|
||||
REQUEST.RESPONSE.setHeader("content-type", scu.JSON_MIMETYPE)
|
||||
return "undefined" # XXX voir quoi faire en cas d'erreur json
|
||||
else:
|
||||
raise ValueError("ScoErrorResponse: invalid format")
|
||||
@ -517,7 +554,7 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
|
||||
page_title="Opérations sur %(nomprenom)s" % etud,
|
||||
html_title="<h2>Opérations effectuées sur l'étudiant %(nomprenom)s</h2>"
|
||||
% etud,
|
||||
filename="log_" + make_filename(etud["nomprenom"]),
|
||||
filename="log_" + scu.make_filename(etud["nomprenom"]),
|
||||
html_next_section='<ul><li><a href="ficheEtud?etudid=%(etudid)s">fiche de %(nomprenom)s</a></li></ul>'
|
||||
% etud,
|
||||
preferences=self.get_preferences(),
|
||||
@ -530,7 +567,7 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
|
||||
def listScoLog(self, etudid):
|
||||
"liste des operations effectuees sur cet etudiant"
|
||||
cnx = self.GetDBConnexion()
|
||||
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
|
||||
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
|
||||
cursor.execute(
|
||||
"select * from scolog where etudid=%(etudid)s ORDER BY DATE DESC",
|
||||
{"etudid": etudid},
|
||||
@ -545,7 +582,7 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
|
||||
|
||||
def rssnews(self, REQUEST=None):
|
||||
"rss feed"
|
||||
REQUEST.RESPONSE.setHeader("content-type", XML_MIMETYPE)
|
||||
REQUEST.RESPONSE.setHeader("content-type", scu.XML_MIMETYPE)
|
||||
return sco_news.scolar_news_summary_rss(
|
||||
self, "Nouvelles de " + self.get_preference("DeptName"), self.ScoURL()
|
||||
)
|
||||
@ -851,13 +888,13 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
|
||||
"emailperso": "",
|
||||
"error": "code etudiant inconnu",
|
||||
}
|
||||
return sendResult(
|
||||
return scu.sendResult(
|
||||
REQUEST, d, name="etudiant", format=format, force_outer_xml_tag=False
|
||||
)
|
||||
d = {}
|
||||
etud = etuds[0]
|
||||
self.fillEtudsInfo([etud])
|
||||
etud["date_naissance_iso"] = DateDMYtoISO(etud["date_naissance"])
|
||||
etud["date_naissance_iso"] = ndb.DateDMYtoISO(etud["date_naissance"])
|
||||
for a in (
|
||||
"etudid",
|
||||
"code_nip",
|
||||
@ -885,8 +922,8 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
|
||||
"codelycee",
|
||||
"date_naissance_iso",
|
||||
):
|
||||
d[a] = quote_xml_attr(etud[a])
|
||||
d["photo_url"] = quote_xml_attr(sco_photos.etud_photo_url(self, etud))
|
||||
d[a] = scu.quote_xml_attr(etud[a])
|
||||
d["photo_url"] = scu.quote_xml_attr(sco_photos.etud_photo_url(self, etud))
|
||||
|
||||
sem = etud["cursem"]
|
||||
if sem:
|
||||
@ -895,10 +932,10 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
|
||||
{
|
||||
"current": "1",
|
||||
"formsemestre_id": sem["formsemestre_id"],
|
||||
"date_debut": DateDMYtoISO(sem["date_debut"]),
|
||||
"date_fin": DateDMYtoISO(sem["date_fin"]),
|
||||
"etat": quote_xml_attr(sem["ins"]["etat"]),
|
||||
"groupes": quote_xml_attr(
|
||||
"date_debut": ndb.DateDMYtoISO(sem["date_debut"]),
|
||||
"date_fin": ndb.DateDMYtoISO(sem["date_fin"]),
|
||||
"etat": scu.quote_xml_attr(sem["ins"]["etat"]),
|
||||
"groupes": scu.quote_xml_attr(
|
||||
etud["groupes"]
|
||||
), # slt pour semestre courant
|
||||
}
|
||||
@ -910,14 +947,14 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
|
||||
d["insemestre"].append(
|
||||
{
|
||||
"formsemestre_id": sem["formsemestre_id"],
|
||||
"date_debut": DateDMYtoISO(sem["date_debut"]),
|
||||
"date_fin": DateDMYtoISO(sem["date_fin"]),
|
||||
"etat": quote_xml_attr(sem["ins"]["etat"]),
|
||||
"date_debut": ndb.DateDMYtoISO(sem["date_debut"]),
|
||||
"date_fin": ndb.DateDMYtoISO(sem["date_fin"]),
|
||||
"etat": scu.quote_xml_attr(sem["ins"]["etat"]),
|
||||
}
|
||||
)
|
||||
|
||||
log("etud_info (%gs)" % (time.time() - t0))
|
||||
return sendResult(
|
||||
return scu.sendResult(
|
||||
REQUEST, d, name="etudiant", format=format, force_outer_xml_tag=False
|
||||
)
|
||||
|
||||
@ -960,7 +997,7 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
|
||||
def _descr_situation_etud(self, etudid, ne=""):
|
||||
"""chaine decrivant la situation actuelle de l'etudiant"""
|
||||
cnx = self.GetDBConnexion()
|
||||
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
|
||||
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
|
||||
cursor.execute(
|
||||
"select I.formsemestre_id, I.etat from notes_formsemestre_inscription I, notes_formsemestre S where etudid=%(etudid)s and S.formsemestre_id = I.formsemestre_id and date_debut < now() and date_fin > now() order by S.date_debut desc;",
|
||||
{"etudid": etudid},
|
||||
@ -1350,7 +1387,6 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
|
||||
operation_method="",
|
||||
):
|
||||
"Formulaire démission ou défaillance Etudiant"
|
||||
cnx = self.GetDBConnexion()
|
||||
etud = self.getEtudInfo(etudid=etudid, filled=1, REQUEST=REQUEST)[0]
|
||||
sem = sco_formsemestre.get_formsemestre(self, formsemestre_id)
|
||||
if sem["etat"] != "1":
|
||||
@ -1374,7 +1410,7 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
|
||||
"""<form action="%s" method="get">
|
||||
<b>Date de la %s (J/M/AAAA): </b>
|
||||
"""
|
||||
% (operation_method, strlower(operation_name))
|
||||
% (operation_method, scu.strlower(operation_name))
|
||||
)
|
||||
H.append(
|
||||
"""
|
||||
@ -1410,7 +1446,7 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
|
||||
etudid,
|
||||
formsemestre_id,
|
||||
event_date=event_date,
|
||||
etat_new=DEF,
|
||||
etat_new=sco_codes_parcours.DEF,
|
||||
operation_method="defailleEtudiant",
|
||||
event_type="DEFAILLANCE",
|
||||
REQUEST=REQUEST,
|
||||
@ -1488,7 +1524,7 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
|
||||
dialog_confirmed=dialog_confirmed,
|
||||
args=args,
|
||||
operation_name="défaillance",
|
||||
etat_current=DEF,
|
||||
etat_current=sco_codes_parcours.DEF,
|
||||
etat_new="I",
|
||||
operation_method="cancelDef",
|
||||
event_type="DEFAILLANCE",
|
||||
@ -1544,7 +1580,7 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
|
||||
args=ins, formsemestre_id=formsemestre_id
|
||||
)
|
||||
logdb(REQUEST, cnx, method=operation_method, etudid=etudid)
|
||||
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
|
||||
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
|
||||
cursor.execute(
|
||||
"delete from scolar_events where etudid=%(etudid)s and formsemestre_id=%(formsemestre_id)s and event_type='"
|
||||
+ event_type
|
||||
@ -1572,7 +1608,6 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
|
||||
"Le formulaire HTML"
|
||||
H = [self.sco_header(REQUEST, init_jquery_ui=True)]
|
||||
F = self.sco_footer(REQUEST)
|
||||
AUTHENTICATED_USER = REQUEST.AUTHENTICATED_USER
|
||||
etudid = REQUEST.form.get("etudid", None)
|
||||
cnx = self.GetDBConnexion()
|
||||
descr = []
|
||||
@ -1607,12 +1642,14 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
|
||||
# recuperation infos Apogee
|
||||
# Si on a le code NIP, fait juste une requete, sinon tente de rechercher par nom
|
||||
# (la recherche par nom ne fonctionne plus à Paris 13)
|
||||
code_nip = initvalues.get("code_nip", "")
|
||||
if code_nip:
|
||||
try:
|
||||
info = sco_portal_apogee.get_etud_apogee(self, code_nip)
|
||||
except ValueError:
|
||||
pass # XXX a terminer
|
||||
# XXX A terminer
|
||||
# code_nip = initvalues.get("code_nip", "")
|
||||
# if code_nip:
|
||||
# try:
|
||||
# infos = sco_portal_apogee.get_etud_apogee(self, code_nip)
|
||||
# except ValueError:
|
||||
# infos = None
|
||||
# pass # XXX a terminer
|
||||
nom = REQUEST.form.get("nom", None)
|
||||
if nom is None:
|
||||
nom = initvalues.get("nom", None)
|
||||
@ -1675,7 +1712,11 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
|
||||
("nom_usuel", {"size": 25, "title": "Nom usuel", "allow_null": True}),
|
||||
(
|
||||
"prenom",
|
||||
{"size": 25, "title": "Prénom", "allow_null": CONFIG.ALLOW_NULL_PRENOM},
|
||||
{
|
||||
"size": 25,
|
||||
"title": "Prénom",
|
||||
"allow_null": scu.CONFIG.ALLOW_NULL_PRENOM,
|
||||
},
|
||||
),
|
||||
(
|
||||
"sexe",
|
||||
@ -1776,7 +1817,7 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
|
||||
{
|
||||
"input_type": "menu",
|
||||
"title": "Voie d'admission",
|
||||
"allowed_values": TYPES_ADMISSION,
|
||||
"allowed_values": scu.TYPES_ADMISSION,
|
||||
},
|
||||
),
|
||||
(
|
||||
@ -2009,7 +2050,7 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
|
||||
"billet_absence",
|
||||
"identite",
|
||||
]
|
||||
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
|
||||
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
|
||||
for table in tables:
|
||||
cursor.execute("delete from %s where etudid=%%(etudid)s" % table, etud)
|
||||
cnx.commit()
|
||||
@ -2030,7 +2071,7 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
|
||||
XXX A re-écrire pour API 2: prendre liste dans l'étape et vérifier à partir de cela.
|
||||
"""
|
||||
etat = etat or None
|
||||
members, group, group_tit, sem, nbdem = sco_groups.get_group_infos(
|
||||
members, group, _, sem, _ = sco_groups.get_group_infos(
|
||||
self, group_id, etat=etat
|
||||
)
|
||||
formsemestre_id = group["formsemestre_id"]
|
||||
@ -2136,8 +2177,8 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
|
||||
% (
|
||||
REQUEST.URL0,
|
||||
formsemestre_id,
|
||||
strnone(group_id),
|
||||
strnone(etat),
|
||||
scu.strnone(group_id),
|
||||
scu.strnone(etat),
|
||||
formsemestre_id,
|
||||
)
|
||||
)
|
||||
@ -2155,8 +2196,8 @@ UE11 Découverte métiers <span class="ue_code">(code UCOD46, 16 ECTS, Apo <span
|
||||
% (
|
||||
REQUEST.URL0,
|
||||
formsemestre_id,
|
||||
strnone(group_id),
|
||||
strnone(etat),
|
||||
scu.strnone(group_id),
|
||||
scu.strnone(etat),
|
||||
formsemestre_id,
|
||||
)
|
||||
)
|
||||
@ -2335,7 +2376,6 @@ Les champs avec un astérisque (*) doivent être présents (nulls non autorisés
|
||||
|
||||
def form_students_import_infos_admissions(self, REQUEST, formsemestre_id=None):
|
||||
"formulaire import xls"
|
||||
sem = sco_formsemestre.get_formsemestre(self.Notes, formsemestre_id)
|
||||
authuser = REQUEST.AUTHENTICATED_USER
|
||||
F = self.sco_footer(REQUEST)
|
||||
if not authuser.has_permission(ScoEtudInscrit, self):
|
||||
@ -2505,7 +2545,6 @@ Les champs avec un astérisque (*) doivent être présents (nulls non autorisés
|
||||
def stat_bac(self, formsemestre_id):
|
||||
"Renvoie statistisques sur nb d'etudiants par bac"
|
||||
cnx = self.GetDBConnexion()
|
||||
sem = sco_formsemestre.get_formsemestre(self, formsemestre_id)
|
||||
ins = self.Notes.do_formsemestre_inscription_list(
|
||||
args={"formsemestre_id": formsemestre_id}
|
||||
)
|
||||
@ -2641,16 +2680,16 @@ def manage_addZScolarForm(context, DeptId, REQUEST=None):
|
||||
# default connexion string
|
||||
if not db_cnx_string:
|
||||
db_name = "SCO" + DeptId.upper()
|
||||
db_user = SCO_DEFAULT_SQL_USER
|
||||
db_user = scu.SCO_DEFAULT_SQL_USER
|
||||
db_cnx_string = "user=%s dbname=%s port=%s" % (
|
||||
db_user,
|
||||
db_name,
|
||||
SCO_DEFAULT_SQL_PORT,
|
||||
scu.SCO_DEFAULT_SQL_PORT,
|
||||
)
|
||||
# vérifie que la bd existe et possede le meme nom de dept.
|
||||
try:
|
||||
cnx = psycopg2.connect(db_cnx_string)
|
||||
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
|
||||
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
|
||||
cursor.execute("select * from sco_prefs where name='DeptName'")
|
||||
except:
|
||||
return _simple_error_page(
|
||||
|
@ -30,12 +30,14 @@
|
||||
# conçu et développé par Cléo Baras (IUT de Grenoble)
|
||||
##############################################################################
|
||||
|
||||
import os
|
||||
import codecs
|
||||
import re
|
||||
import scolars
|
||||
import pe_jurype, pe_tagtable, pe_tools
|
||||
|
||||
from sco_utils import *
|
||||
import sco_utils as scu
|
||||
from notes_log import log
|
||||
import scolars
|
||||
|
||||
import pe_jurype, pe_tagtable, pe_tools
|
||||
@ -55,7 +57,7 @@ def get_code_latex_from_modele(fichier):
|
||||
vers le modele : attention pas de vérification du format d'encodage
|
||||
Le fichier doit donc etre enregistré avec le même codage que ScoDoc (utf-8)
|
||||
"""
|
||||
fid_latex = codecs.open(fichier, "r", encoding=SCO_ENCODING)
|
||||
fid_latex = codecs.open(fichier, "r", encoding=scu.SCO_ENCODING)
|
||||
un_avis_latex = fid_latex.read()
|
||||
fid_latex.close()
|
||||
return un_avis_latex
|
||||
@ -72,7 +74,7 @@ def get_code_latex_from_scodoc_preference(
|
||||
template_latex = context.get_preference(champ, formsemestre_id)
|
||||
# Conversion du template en unicode:
|
||||
if template_latex:
|
||||
template_latex = template_latex.decode(SCO_ENCODING)
|
||||
template_latex = template_latex.decode(scu.SCO_ENCODING)
|
||||
else:
|
||||
template_latex = u"" # EV: preference non définie (None)
|
||||
|
||||
@ -119,10 +121,14 @@ def comp_latex_parcourstimeline(etudiant, promo, taille=17):
|
||||
\\end{parcourstimeline}
|
||||
"""
|
||||
reslatex = codelatexDebut
|
||||
reslatex = reslatex.replace("**debut**", etudiant["entree"].decode(SCO_ENCODING))
|
||||
reslatex = reslatex.replace("**fin**", str(etudiant["promo"]).decode(SCO_ENCODING))
|
||||
reslatex = reslatex.replace(
|
||||
"**nbreSemestres**", str(etudiant["nbSemestres"]).decode(SCO_ENCODING)
|
||||
"**debut**", etudiant["entree"].decode(scu.SCO_ENCODING)
|
||||
)
|
||||
reslatex = reslatex.replace(
|
||||
"**fin**", str(etudiant["promo"]).decode(scu.SCO_ENCODING)
|
||||
)
|
||||
reslatex = reslatex.replace(
|
||||
"**nbreSemestres**", str(etudiant["nbSemestres"]).decode(scu.SCO_ENCODING)
|
||||
)
|
||||
# Tri du parcours par ordre croissant : de la forme descr, nom sem date-date
|
||||
parcours = etudiant["parcours"][::-1] # EV: XXX je ne comprend pas ce commentaire ?
|
||||
@ -179,7 +185,7 @@ def get_code_latex_avis_etudiant(
|
||||
# Recherche des tags dans le fichier
|
||||
tags_latex = get_tags_latex(code)
|
||||
if DEBUG:
|
||||
print("Les tags" + str(tags_latex))
|
||||
log("Les tags" + str(tags_latex))
|
||||
|
||||
# Interprète et remplace chaque tags latex par les données numériques de l'étudiant (y compris les
|
||||
# tags "macros" tels que parcourstimeline
|
||||
@ -210,14 +216,13 @@ def get_code_latex_avis_etudiant(
|
||||
# Les tags "simples": par ex. nom, prenom, sexe, ...
|
||||
else:
|
||||
if tag_latex in donnees_etudiant:
|
||||
valeur = donnees_etudiant[tag_latex].decode(SCO_ENCODING)
|
||||
valeur = donnees_etudiant[tag_latex].decode(scu.SCO_ENCODING)
|
||||
elif tag_latex in prefs: # les champs **NomResponsablePE**, ...
|
||||
valeur = pe_tools.escape_for_latex(prefs[tag_latex]).decode(
|
||||
SCO_ENCODING
|
||||
scu.SCO_ENCODING
|
||||
)
|
||||
|
||||
# Gestion des pb d'encodage XXX debug
|
||||
# print(tag_latex, valeur)
|
||||
assert isinstance(tag_latex, unicode)
|
||||
assert isinstance(valeur, unicode)
|
||||
|
||||
@ -244,7 +249,7 @@ def get_annotation_PE(context, etudid, tag_annotation_pe):
|
||||
exp = re.compile(r"^" + tag_annotation_pe)
|
||||
|
||||
for a in annotations:
|
||||
commentaire = unescape_html(a["comment"]).decode(SCO_ENCODING)
|
||||
commentaire = scu.unescape_html(a["comment"]).decode(scu.SCO_ENCODING)
|
||||
if exp.match(commentaire): # tag en début de commentaire ?
|
||||
a["comment_u"] = commentaire # unicode, HTML non quoté
|
||||
annotationsPE.append(
|
||||
@ -282,7 +287,6 @@ def str_from_syntheseJury(donnees_etudiant, aggregat, groupe, tag_scodoc, champ)
|
||||
for chp in champ
|
||||
]
|
||||
else: # champ = str à priori
|
||||
# print(champ)
|
||||
valeur = DONNEE_MANQUANTE
|
||||
if (
|
||||
(aggregat in donnees_etudiant)
|
||||
@ -316,7 +320,6 @@ def str_from_syntheseJury(donnees_etudiant, aggregat, groupe, tag_scodoc, champ)
|
||||
else:
|
||||
valeur = u"%s" % donnees_numeriques[indice_champ]
|
||||
|
||||
# print(valeur)
|
||||
return valeur
|
||||
|
||||
|
||||
@ -339,7 +342,7 @@ def get_bilanParTag(donnees_etudiant, groupe="groupe"):
|
||||
|
||||
lignes = []
|
||||
valeurs = {"note": [], "rang": []}
|
||||
for (indice_aggregat, (aggregat, intitule, ordre)) in enumerate(entete):
|
||||
for (indice_aggregat, (aggregat, intitule, _)) in enumerate(entete):
|
||||
# print("> " + aggregat)
|
||||
# listeTags = jury.get_allTagForAggregat(aggregat) # les tags de l'aggrégat
|
||||
listeTags = [
|
||||
@ -366,25 +369,20 @@ def get_bilanParTag(donnees_etudiant, groupe="groupe"):
|
||||
("\\textit{" + rang + "}") if note else ""
|
||||
) # rang masqué si pas de notes
|
||||
|
||||
# pprint.pprint(valeurs)
|
||||
# print(len(entete))
|
||||
code_latex = u"\\begin{tabular}{|c|" + "|c" * (len(entete)) + "|}\n"
|
||||
code_latex += u"\\hline \n"
|
||||
code_latex += (
|
||||
u" & "
|
||||
+ " & ".join(
|
||||
["\\textbf{" + intitule + "}" for (agg, intitule, ordre) in entete]
|
||||
)
|
||||
+ " & ".join(["\\textbf{" + intitule + "}" for (agg, intitule, _) in entete])
|
||||
+ " \\\\ \n"
|
||||
)
|
||||
code_latex += u"\\hline"
|
||||
code_latex += u"\\hline \n"
|
||||
for (i, ligne_val) in enumerate(valeurs["note"]):
|
||||
titre = lignes[i] # règle le pb d'encodage
|
||||
# print titre, ligne_val
|
||||
code_latex += (
|
||||
u"\\textbf{"
|
||||
+ titre.decode(SCO_ENCODING)
|
||||
+ titre.decode(scu.SCO_ENCODING)
|
||||
+ u"} & "
|
||||
+ " & ".join(ligne_val)
|
||||
+ u"\\\\ \n"
|
||||
@ -412,9 +410,11 @@ def get_avis_poursuite_par_etudiant(
|
||||
if pe_tools.PE_DEBUG:
|
||||
pe_tools.pe_print(jury.syntheseJury[etudid]["nom"] + " " + etudid)
|
||||
|
||||
sexe = jury.syntheseJury[etudid]["sexe"].decode(SCO_ENCODING)
|
||||
nom = jury.syntheseJury[etudid]["nom"].replace(" ", "-").decode(SCO_ENCODING)
|
||||
prenom = jury.syntheseJury[etudid]["prenom"].replace(" ", "-").decode(SCO_ENCODING)
|
||||
sexe = jury.syntheseJury[etudid]["sexe"].decode(scu.SCO_ENCODING)
|
||||
nom = jury.syntheseJury[etudid]["nom"].replace(" ", "-").decode(scu.SCO_ENCODING)
|
||||
prenom = (
|
||||
jury.syntheseJury[etudid]["prenom"].replace(" ", "-").decode(scu.SCO_ENCODING)
|
||||
)
|
||||
|
||||
nom_fichier = (
|
||||
u"avis_poursuite_"
|
||||
@ -460,11 +460,11 @@ def get_templates_from_distrib(template="avis"):
|
||||
|
||||
if template in ["avis", "footer"]:
|
||||
# pas de preference pour le template: utilise fichier du serveur
|
||||
p = os.path.join(SCO_SRCDIR, pe_local_tmpl)
|
||||
p = os.path.join(scu.SCO_SRCDIR, pe_local_tmpl)
|
||||
if os.path.exists(p):
|
||||
template_latex = get_code_latex_from_modele(p)
|
||||
else:
|
||||
p = os.path.join(SCO_SRCDIR, pe_default_tmpl)
|
||||
p = os.path.join(scu.SCO_SRCDIR, pe_default_tmpl)
|
||||
if os.path.exists(p):
|
||||
template_latex = get_code_latex_from_modele(p)
|
||||
else:
|
||||
@ -534,7 +534,9 @@ def table_syntheseAnnotationPE(context, syntheseJury, tag_annotation_pe):
|
||||
annotationPE = get_annotation_PE(
|
||||
context, etudid, tag_annotation_pe=tag_annotation_pe
|
||||
)
|
||||
row["Annotation PE"] = annotationPE.encode(SCO_ENCODING) if annotationPE else ""
|
||||
row["Annotation PE"] = (
|
||||
annotationPE.encode(scu.SCO_ENCODING) if annotationPE else ""
|
||||
)
|
||||
rows.append(row)
|
||||
|
||||
T = GenTable(
|
||||
|
21
pe_jurype.py
21
pe_jurype.py
@ -42,6 +42,7 @@ Created on Fri Sep 9 09:15:05 2016
|
||||
# a l'edition d'un jury de poursuites d'etudes
|
||||
# ----------------------------------------------------------
|
||||
|
||||
import os
|
||||
|
||||
try:
|
||||
from cStringIO import StringIO
|
||||
@ -54,10 +55,9 @@ from zipfile import ZipFile, BadZipfile
|
||||
import pprint
|
||||
|
||||
from gen_tables import GenTable, SeqGenTable
|
||||
|
||||
import sco_utils as scu
|
||||
import sco_codes_parcours # sco_codes_parcours.NEXT -> sem suivant
|
||||
import sco_report
|
||||
from sco_utils import *
|
||||
|
||||
import pe_tagtable, pe_tools, pe_avislatex, pe_semestretag, pe_settag
|
||||
|
||||
@ -450,15 +450,15 @@ class JuryPE:
|
||||
end="",
|
||||
)
|
||||
|
||||
if pe_tools.PE_DEBUG and pe_tools.PE_DEBUG >= 2:
|
||||
print
|
||||
# if pe_tools.PE_DEBUG and pe_tools.PE_DEBUG >= 2:
|
||||
# print
|
||||
|
||||
# ------------------------------------------------------------------------------------------------------------------
|
||||
def est_un_etudiant_reoriente_ou_demissionnaire(self, etudid):
|
||||
"""Renvoie True si l'étudiant est réorienté (NAR) ou démissionnaire (DEM)"""
|
||||
reponse = False
|
||||
etud = self.get_cache_etudInfo_d_un_etudiant(self.context, etudid)
|
||||
(code, parcours) = sco_report.get_codeparcoursetud(self.context.Notes, etud)
|
||||
(_, parcours) = sco_report.get_codeparcoursetud(self.context.Notes, etud)
|
||||
if (
|
||||
len(set(sco_codes_parcours.CODES_SEM_REO.keys()) & set(parcours.values()))
|
||||
> 0
|
||||
@ -862,13 +862,13 @@ class JuryPE:
|
||||
|
||||
def get_dateEntree(self, etudid):
|
||||
"""Renvoie l'année d'entrée de l'étudiant à l'IUT"""
|
||||
etudinfo = self.ETUDINFO_DICT[etudid]
|
||||
# etudinfo = self.ETUDINFO_DICT[etudid]
|
||||
semDeb = self.get_semestresDUT_d_un_etudiant(etudid)[-1] # le 1er sem à l'IUT
|
||||
return semDeb["annee_debut"]
|
||||
|
||||
def get_parcoursIUT(self, etudid):
|
||||
"""Renvoie une liste d'infos sur les semestres du parcours d'un étudiant"""
|
||||
etudinfo = self.ETUDINFO_DICT[etudid]
|
||||
# etudinfo = self.ETUDINFO_DICT[etudid]
|
||||
sems = self.get_semestresDUT_d_un_etudiant(etudid)
|
||||
|
||||
infos = []
|
||||
@ -1073,7 +1073,7 @@ class JuryPE:
|
||||
if mode == "singlesheet"
|
||||
else "%s " % (sem)
|
||||
)
|
||||
row[champ + "note"] = fmt_note(resgroupe[0])
|
||||
row[champ + "note"] = scu.fmt_note(resgroupe[0])
|
||||
row[champ + "class groupe"] = "%s / %s" % (
|
||||
resgroupe[2],
|
||||
resgroupe[3],
|
||||
@ -1083,11 +1083,12 @@ class JuryPE:
|
||||
respromo[3],
|
||||
)
|
||||
row[champ + "min/moy/max groupe"] = "%s / %s / %s" % tuple(
|
||||
fmt_note(x)
|
||||
scu.fmt_note(x)
|
||||
for x in (resgroupe[6], resgroupe[4], resgroupe[5])
|
||||
)
|
||||
row[champ + "min/moy/max promo"] = "%s / %s / %s" % tuple(
|
||||
fmt_note(x) for x in (respromo[6], respromo[4], respromo[5])
|
||||
scu.fmt_note(x)
|
||||
for x in (respromo[6], respromo[4], respromo[5])
|
||||
)
|
||||
rows.append(row)
|
||||
|
||||
|
@ -35,8 +35,10 @@ Created on Fri Sep 9 09:15:05 2016
|
||||
|
||||
@author: barasc
|
||||
"""
|
||||
import notes_table
|
||||
import datetime
|
||||
|
||||
from notes_log import log
|
||||
import notes_table
|
||||
import sco_codes_parcours
|
||||
import sco_tag_module
|
||||
import sco_utils
|
||||
@ -57,7 +59,7 @@ class SemestreTag(pe_tagtable.TableTag):
|
||||
Attributs supplémentaires :
|
||||
- inscrlist/identdict: étudiants inscrits hors démissionnaires ou défaillants
|
||||
- _tagdict : Dictionnaire résumant les tags et les modules du semestre auxquels ils sont liés
|
||||
- _sum_coeff_semestre : la somme des coeffs du semestre
|
||||
|
||||
|
||||
Attributs hérités de TableTag :
|
||||
- nom :
|
||||
@ -136,8 +138,7 @@ class SemestreTag(pe_tagtable.TableTag):
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
def get_etudids(self):
|
||||
"""Renvoie la liste des etud_id des étudiants inscrits au semestre
|
||||
"""
|
||||
"""Renvoie la liste des etud_id des étudiants inscrits au semestre"""
|
||||
return [etud["etudid"] for etud in self.inscrlist]
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
@ -382,7 +383,7 @@ class SemestreTag(pe_tagtable.TableTag):
|
||||
+ (
|
||||
"%1.5f" % (coeff * self.somme_coeffs)
|
||||
if coeff != None and isinstance(coeff, float)
|
||||
else str(coeff * self._sum_coeff_semestre)
|
||||
else "???" # str(coeff * self._sum_coeff_semestre) # voir avec Cléo
|
||||
)
|
||||
+ delim
|
||||
)
|
||||
@ -477,8 +478,9 @@ def get_moduleimpl(nt, modimpl_id):
|
||||
] # la liste de id des modules (modimpl_id)
|
||||
if modimpl_id not in modimplids:
|
||||
if SemestreTag.DEBUG:
|
||||
print "SemestreTag.get_moduleimpl( %s ) : le modimpl recherche n'existe pas" % (
|
||||
modimpl_id
|
||||
log(
|
||||
"SemestreTag.get_moduleimpl( %s ) : le modimpl recherche n'existe pas"
|
||||
% (modimpl_id)
|
||||
)
|
||||
return None
|
||||
return nt._modimpls[modimplids.index(modimpl_id)]
|
||||
|
@ -27,9 +27,7 @@
|
||||
|
||||
"""Exportation des résultats des étudiants vers Apogée.
|
||||
|
||||
EXPERIMENTAL / PRECAUTIONS !
|
||||
|
||||
Code inspiré par les travaux de Damien Mascré, scodoc2apogee (en Java).
|
||||
Ce code a été au départ inspiré par les travaux de Damien Mascré, scodoc2apogee (en Java).
|
||||
|
||||
A utiliser en fin de semestre, après les jury.
|
||||
|
||||
@ -81,6 +79,13 @@ XXX A vérifier:
|
||||
AJAC car 1 sem. validé et pas de NAR
|
||||
|
||||
"""
|
||||
|
||||
import collections
|
||||
from types import FloatType
|
||||
import re
|
||||
import time
|
||||
import datetime
|
||||
import os
|
||||
from cStringIO import StringIO
|
||||
from zipfile import ZipFile
|
||||
import pprint
|
||||
@ -90,6 +95,10 @@ try:
|
||||
except:
|
||||
chardet_detect = None
|
||||
|
||||
import sco_utils as scu
|
||||
import notesdb as ndb
|
||||
from notes_log import log
|
||||
from sco_exceptions import ScoValueError, FormatError
|
||||
import sco_formsemestre
|
||||
from sco_formsemestre import ApoEtapeVDI
|
||||
import sco_formsemestre_status
|
||||
@ -98,8 +107,6 @@ import sco_codes_parcours
|
||||
from sco_codes_parcours import code_semestre_validant
|
||||
from sco_codes_parcours import ATT, ATB, ADM, ADC, ADJ, ATJ, ATB, AJ, CMP, NAR, RAT, DEF
|
||||
from gen_tables import GenTable
|
||||
from notesdb import *
|
||||
from sco_utils import *
|
||||
|
||||
APO_PORTAL_ENCODING = (
|
||||
"utf8" # encodage du fichier CSV Apogée (était 'ISO-8859-1' avant jul. 2016)
|
||||
@ -347,10 +354,10 @@ class ApoEtud(dict):
|
||||
for col_id in apo_data.col_ids[:4]:
|
||||
self.new_cols[col_id] = self.cols[col_id]
|
||||
|
||||
def unassociated_codes(self, apo_data):
|
||||
"list of apo elements for this student without a value in ScoDoc"
|
||||
codes = set([apo_data.cols[col_id].code for col_id in apo_data.col_ids])
|
||||
return codes - set(sco_elts)
|
||||
# def unassociated_codes(self, apo_data):
|
||||
# "list of apo elements for this student without a value in ScoDoc"
|
||||
# codes = set([apo_data.cols[col_id].code for col_id in apo_data.col_ids])
|
||||
# return codes - set(sco_elts)
|
||||
|
||||
def search_elt_in_sem(self, context, code, sem, cur_sem, autre_sem):
|
||||
"""
|
||||
@ -749,7 +756,7 @@ class ApoData:
|
||||
if not data:
|
||||
raise FormatError("Fichier Apogée vide !")
|
||||
|
||||
data_utf8 = data.decode(APO_INPUT_ENCODING).encode(SCO_ENCODING)
|
||||
data_utf8 = data.decode(APO_INPUT_ENCODING).encode(scu.SCO_ENCODING)
|
||||
f = StringIOFileLineWrapper(data_utf8) # pour traiter comme un fichier
|
||||
# check that we are at the begining of Apogee CSV
|
||||
line = f.readline().strip()
|
||||
@ -1023,7 +1030,7 @@ def _apo_read_cols(f):
|
||||
line = f.readline().strip(" " + APO_NEWLINE)
|
||||
fs = line.split(APO_SEP)
|
||||
if fs[0] != "apoL_a01_code":
|
||||
raise FormatError("invalid line: %s (expecting apoL_a01_code)"(line, i))
|
||||
raise FormatError("invalid line: %s (expecting apoL_a01_code)" % line)
|
||||
col_keys = fs
|
||||
|
||||
while True: # skip premiere partie (apoL_a02_nom, ...)
|
||||
@ -1046,7 +1053,9 @@ def _apo_read_cols(f):
|
||||
raise FormatError("duplicate column definition: %s" % col_id)
|
||||
m = re.match(r"^apoL_c([0-9]{4})$", col_id)
|
||||
if not m:
|
||||
raise FormatError("invalid column id: %s (expecting apoL_c%04d)"(line, i))
|
||||
raise FormatError(
|
||||
"invalid column id: %s (expecting apoL_c%04d)" % (line, col_id)
|
||||
)
|
||||
if int(m.group(1)) != i:
|
||||
raise FormatError("invalid column id: %s for index %s" % (col_id, i))
|
||||
|
||||
@ -1281,7 +1290,7 @@ def export_csv_to_apogee(
|
||||
)
|
||||
log(logf.getvalue()) # sortie aussi sur le log ScoDoc
|
||||
|
||||
csv_data = f.getvalue().decode(SCO_ENCODING).encode(APO_OUTPUT_ENCODING)
|
||||
csv_data = f.getvalue().decode(scu.SCO_ENCODING).encode(APO_OUTPUT_ENCODING)
|
||||
|
||||
# Write data to ZIP
|
||||
dest_zip.writestr(csv_filename, csv_data)
|
||||
|
@ -46,7 +46,10 @@ de la forme %(XXX)s sont remplacées par la valeur de XXX, pour XXX dans:
|
||||
Balises img: actuellement interdites.
|
||||
|
||||
"""
|
||||
import traceback, re
|
||||
import datetime
|
||||
import traceback
|
||||
import re
|
||||
import jaxml
|
||||
|
||||
import sco_utils as scu
|
||||
import sco_formsemestre
|
||||
|
@ -217,7 +217,7 @@ def ue_edit(context, ue_id=None, create=False, formation_id=None, REQUEST=None):
|
||||
REQUEST,
|
||||
)
|
||||
else:
|
||||
ue_id = do_ue_edit(context, tf[2])
|
||||
do_ue_edit(context, tf[2])
|
||||
return REQUEST.RESPONSE.redirect(
|
||||
REQUEST.URL1 + "/ue_list?formation_id=" + formation_id
|
||||
)
|
||||
|
@ -84,10 +84,10 @@ def formsemestre_load_ics(context, sem):
|
||||
return cal
|
||||
|
||||
|
||||
def formsemestre_edt_groups_used(context, sem):
|
||||
"""L'ensemble des groupes EDT utilisés dans l'emplois du temps publié"""
|
||||
cal = formsemestre_load_ics(context, sem)
|
||||
return {e["X-GROUP-ID"].decode("utf8") for e in events}
|
||||
# def formsemestre_edt_groups_used(context, sem):
|
||||
# """L'ensemble des groupes EDT utilisés dans l'emploi du temps publié"""
|
||||
# cal = formsemestre_load_ics(context, sem)
|
||||
# return {e["X-GROUP-ID"].decode("utf8") for e in events}
|
||||
|
||||
|
||||
def get_edt_transcodage_groups(context, formsemestre_id):
|
||||
|
@ -31,8 +31,8 @@ Contribution M. Salomon, UFC / IUT DE BELFORT-MONTBÉLIARD, 2016
|
||||
|
||||
"""
|
||||
|
||||
from notesdb import *
|
||||
from sco_utils import *
|
||||
import sco_utils as scu
|
||||
import notesdb as ndb
|
||||
from notes_log import log
|
||||
import scolars
|
||||
import sco_formsemestre
|
||||
@ -260,7 +260,6 @@ def do_placement(context, REQUEST):
|
||||
|
||||
if None in [g["group_name"] for g in groups]: # tous les etudiants
|
||||
getallstudents = True
|
||||
gr_title = "tous"
|
||||
gr_title_filename = "tous"
|
||||
else:
|
||||
getallstudents = False
|
||||
@ -273,7 +272,7 @@ def do_placement(context, REQUEST):
|
||||
M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=E["moduleimpl_id"])[0]
|
||||
Mod = context.do_module_list(args={"module_id": M["module_id"]})[0]
|
||||
sem = sco_formsemestre.get_formsemestre(context, M["formsemestre_id"])
|
||||
evalname = "%s-%s" % (Mod["code"], DateDMYtoISO(E["jour"]))
|
||||
evalname = "%s-%s" % (Mod["code"], ndb.DateDMYtoISO(E["jour"]))
|
||||
if E["description"]:
|
||||
evaltitre = E["description"]
|
||||
else:
|
||||
|
@ -136,11 +136,17 @@ def feuille_preparation_jury(context, formsemestre_id, REQUEST):
|
||||
# Codes des UE "semestre précédent":
|
||||
ue_prev_codes = prev_moy_ue.keys()
|
||||
ue_prev_codes.sort(
|
||||
lambda x, y, prev_ue_acro=prev_ue_acro: cmp(prev_ue_acro[x], prev_ue_acro[y])
|
||||
lambda x, y, prev_ue_acro=prev_ue_acro: cmp( # pylint: disable=undefined-variable
|
||||
prev_ue_acro[x], prev_ue_acro[y]
|
||||
)
|
||||
)
|
||||
# Codes des UE "semestre courant":
|
||||
ue_codes = moy_ue.keys()
|
||||
ue_codes.sort(lambda x, y, ue_acro=ue_acro: cmp(ue_acro[x], ue_acro[y]))
|
||||
ue_codes.sort(
|
||||
lambda x, y, ue_acro=ue_acro: cmp( # pylint: disable=undefined-variable
|
||||
ue_acro[x], ue_acro[y]
|
||||
)
|
||||
)
|
||||
|
||||
sid = sem["semestre_id"]
|
||||
sn = sp = ""
|
||||
|
@ -1242,7 +1242,7 @@ def graph_parcours(
|
||||
dem_nodes = {} # formsemestre_id : noeud pour demissionnaires
|
||||
nar_nodes = {} # formsemestre_id : noeud pour NAR
|
||||
for etud in etuds:
|
||||
nxt = None
|
||||
nxt = {}
|
||||
etudid = etud["etudid"]
|
||||
for s in etud["sems"]: # du plus recent au plus ancien
|
||||
nt = context._getNotesCache().get_NotesTable(
|
||||
|
@ -385,8 +385,8 @@ def _listeappel_photos_pdf(context, groups_infos, REQUEST):
|
||||
sem = groups_infos.formsemestre # suppose 1 seul semestre
|
||||
|
||||
PHOTOWIDTH = 2 * cm
|
||||
COLWIDTH = 3.6 * cm
|
||||
ROWS_PER_PAGE = 26 # XXX should be in ScoDoc preferences
|
||||
# COLWIDTH = 3.6 * cm
|
||||
# ROWS_PER_PAGE = 26 # XXX should be in ScoDoc preferences
|
||||
|
||||
StyleSheet = styles.getSampleStyleSheet()
|
||||
report = StringIO() # in-memory document, no disk file
|
||||
@ -460,71 +460,6 @@ def _listeappel_photos_pdf(context, groups_infos, REQUEST):
|
||||
|
||||
return sendPDFFile(REQUEST, data, filename)
|
||||
|
||||
objects = []
|
||||
StyleSheet = styles.getSampleStyleSheet()
|
||||
report = StringIO() # in-memory document, no disk file
|
||||
filename = ("trombino-%s.pdf" % ng).replace(
|
||||
" ", "_"
|
||||
) # XXX should sanitize this filename
|
||||
objects.append(
|
||||
Paragraph(SU("Liste " + sem["titreannee"] + " " + ng), StyleSheet["Heading3"])
|
||||
)
|
||||
PHOTOWIDTH = 3 * cm
|
||||
COLWIDTH = 3.6 * cm
|
||||
|
||||
L = [] # cells
|
||||
n = 0
|
||||
currow = []
|
||||
for t in T:
|
||||
n = n + 1
|
||||
img = _get_etud_platypus_image(context, t, image_width=2 * cm)
|
||||
currow += [
|
||||
Paragraph(
|
||||
SU(
|
||||
scolars.format_sexe(t["sexe"])
|
||||
+ " "
|
||||
+ scolars.format_prenom(t["prenom"])
|
||||
+ " "
|
||||
+ scolars.format_nom(t["nom"])
|
||||
),
|
||||
StyleSheet["Normal"],
|
||||
),
|
||||
"", # empty cell (signature ou autre info a remplir sur papier)
|
||||
img,
|
||||
]
|
||||
|
||||
if not L:
|
||||
table = Paragraph(SU("Aucune photo à exporter !"), StyleSheet["Normal"])
|
||||
else:
|
||||
table = Table(
|
||||
L,
|
||||
colWidths=[COLWIDTH] * 7,
|
||||
style=TableStyle(
|
||||
[
|
||||
("VALIGN", (0, 0), (-1, -1), "TOP"),
|
||||
("GRID", (0, 0), (2, -1), 0.25, colors.grey),
|
||||
("GRID", (2, 0), (-1, -1), 0.25, colors.red), # <<<
|
||||
]
|
||||
),
|
||||
)
|
||||
objects.append(table)
|
||||
|
||||
# Réduit sur une page
|
||||
objects = [KeepInFrame(0, 0, objects, mode="shrink")]
|
||||
|
||||
# --- Build document
|
||||
document = BaseDocTemplate(report)
|
||||
document.addPageTemplates(
|
||||
ScolarsPageTemplate(
|
||||
document,
|
||||
context=context,
|
||||
preferences=context.get_preferences(sem["formsemestre_id"]),
|
||||
)
|
||||
)
|
||||
document.build(objects)
|
||||
data = report.getvalue()
|
||||
return sendPDFFile(REQUEST, data, filename)
|
||||
|
||||
|
||||
# --------------------- Upload des photos de tout un groupe
|
||||
def photos_generate_excel_sample(context, group_ids=[], REQUEST=None):
|
||||
@ -614,7 +549,7 @@ def photos_import_files(
|
||||
def callback(context, etud, data, filename, REQUEST):
|
||||
sco_photos.store_photo(context, etud, data, REQUEST)
|
||||
|
||||
r = zip_excel_import_files(
|
||||
zip_excel_import_files(
|
||||
context, xlsfile, zipfile, REQUEST, callback, filename_title, page_title
|
||||
)
|
||||
return REQUEST.RESPONSE.redirect(back_url + "&head_message=photos%20 importees")
|
||||
@ -638,7 +573,7 @@ def zip_excel_import_files(
|
||||
exceldata = xlsfile.read()
|
||||
if not exceldata:
|
||||
raise ScoValueError("Fichier excel vide ou invalide")
|
||||
diag, data = sco_excel.Excel_to_list(exceldata)
|
||||
_, data = sco_excel.Excel_to_list(exceldata)
|
||||
if not data: # probably a bug
|
||||
raise ScoValueError("Fichier excel vide !")
|
||||
# on doit avoir une colonne etudid et une colonne filename_title ('fichier_photo')
|
||||
|
Loading…
Reference in New Issue
Block a user