Compare commits

..

2 Commits

Author SHA1 Message Date
IDK
2835777ea6 Changed sco_utils import 2021-02-04 20:02:44 +01:00
IDK
284257e5e1 code cleaning 2021-02-03 22:13:03 +01:00
52 changed files with 435 additions and 382 deletions

View File

@ -34,8 +34,9 @@ import time
import pdb
import collections
import types
import re
from sco_utils import *
import sco_utils as scu
import notesdb as ndb
from notes_log import log
import scolars
@ -107,7 +108,7 @@ ADMISSION_MODIFIABLE_FIELDS = (
def sco_import_format(with_codesemestre=True):
"returns tuples (Attribut, Type, Table, AllowNulls, Description)"
r = []
for l in open(SCO_SRCDIR + "/" + FORMAT_FILE):
for l in open(scu.SCO_SRCDIR + "/" + FORMAT_FILE):
l = l.strip()
if l and l[0] != "#":
fs = l.split(";")
@ -166,10 +167,10 @@ def sco_import_generate_excel_sample(
titles = []
titlesStyles = []
for l in fmt:
name = strlower(l[0])
name = scu.strlower(l[0])
if (not with_codesemestre) and name == "codesemestre":
continue # pas de colonne codesemestre
if only_tables is not None and strlower(l[2]) not in only_tables:
if only_tables is not None and scu.strlower(l[2]) not in only_tables:
continue # table non demandée
if name in exclude_cols:
continue # colonne exclue
@ -206,7 +207,7 @@ def sco_import_generate_excel_sample(
)
l.append(etud["partitionsgroupes"])
else:
key = strlower(field).split()[0]
key = scu.strlower(field).split()[0]
l.append(etud.get(key, ""))
lines.append(l)
else:
@ -279,7 +280,7 @@ def scolars_import_excel_file(
titles = {}
fmt = sco_import_format()
for l in fmt:
tit = strlower(l[0]).split()[0] # titles in lowercase, and take 1st word
tit = scu.strlower(l[0]).split()[0] # titles in lowercase, and take 1st word
if (
(not formsemestre_id) or (tit != "codesemestre")
) and tit not in exclude_cols:
@ -288,7 +289,7 @@ def scolars_import_excel_file(
# log("titles=%s" % titles)
# remove quotes, downcase and keep only 1st word
try:
fs = [strlower(stripquotes(s)).split()[0] for s in data[0]]
fs = [scu.strlower(scu.stripquotes(s)).split()[0] for s in data[0]]
except:
raise ScoValueError("Titres de colonnes invalides (ou vides ?)")
# log("excel: fs='%s'\ndata=%s" % (str(fs), str(data)))
@ -365,7 +366,7 @@ def scolars_import_excel_file(
% (val, linenum, titleslist[i])
)
# xxx Ad-hoc checks (should be in format description)
if strlower(titleslist[i]) == "sexe":
if scu.strlower(titleslist[i]) == "sexe":
try:
val = scolars.normalize_sexe(val)
except:
@ -374,13 +375,13 @@ def scolars_import_excel_file(
% (val, linenum, titleslist[i])
)
# Excel date conversion:
if strlower(titleslist[i]) == "date_naissance":
if scu.strlower(titleslist[i]) == "date_naissance":
if val:
if re.match("^[0-9]*\.?[0-9]*$", str(val)):
val = sco_excel.xldate_as_datetime(float(val))
# INE
if (
strlower(titleslist[i]) == "code_ine"
scu.strlower(titleslist[i]) == "code_ine"
and always_require_ine
and not val
):
@ -703,7 +704,7 @@ _ADM_PATTERN = re.compile(r"[\W]+", re.UNICODE) # supprime tout sauf alphanum
def adm_normalize_string(s): # normalize unicode title
return suppression_diacritics(_ADM_PATTERN.sub("", s.strip().lower())).replace(
return scu.suppression_diacritics(_ADM_PATTERN.sub("", s.strip().lower())).replace(
"_", ""
)

View File

@ -27,7 +27,7 @@
import cgi
from sco_utils import *
import sco_utils as scu
from sco_formsemestre_status import formsemestre_page_title
"""
@ -97,7 +97,7 @@ def sco_header(
"page_title": page_title or context.title_or_id(),
"no_side_bar": no_side_bar,
"ScoURL": context.ScoURL(),
"encoding": SCO_ENCODING,
"encoding": scu.SCO_ENCODING,
"titrebandeau_mkup": "<td>" + titrebandeau + "</td>",
"authuser": str(REQUEST.AUTHENTICATED_USER),
}
@ -226,7 +226,7 @@ def sco_header(
# Body et bandeau haut:
H.append("""<body %(bodyOnLoad_mkup)s>""" % params)
H.append(CUSTOM_HTML_HEADER)
H.append(scu.CUSTOM_HTML_HEADER)
#
if not no_side_bar:
H.append(context.sidebar(REQUEST))
@ -260,4 +260,6 @@ def sco_header(
def sco_footer(context, REQUEST=None):
"""Main HTMl pages footer"""
return """</div><!-- /gtrcontent -->""" + CUSTOM_HTML_FOOTER + """</body></html>"""
return (
"""</div><!-- /gtrcontent -->""" + scu.CUSTOM_HTML_FOOTER + """</body></html>"""
)

View File

@ -25,7 +25,7 @@
#
##############################################################################
from sco_utils import *
import sco_utils as scu
from sco_abs import getAbsSemEtud
from sco_permissions import (
ScoUsersAdmin,
@ -82,7 +82,7 @@ def sidebar_common(context, REQUEST=None):
def sidebar(context, REQUEST=None):
"Main HTML page sidebar"
# rewritten from legacy DTML code
params = {"ScoURL": context.ScoURL(), "SCO_USER_MANUAL": SCO_USER_MANUAL}
params = {"ScoURL": context.ScoURL(), "SCO_USER_MANUAL": scu.SCO_USER_MANUAL}
H = ['<div class="sidebar">', sidebar_common(context, REQUEST)]
@ -148,7 +148,7 @@ def sidebar(context, REQUEST=None):
# ---------
H.append("</div><br/>&nbsp;") # /etud-insidebar
# Logo
scologo_img = icontag("scologo_img")
scologo_img = scu.icontag("scologo_img")
H.append('<div class="logo-insidebar"><div class="logo-logo">%s<br/>' % scologo_img)
H.append(
"""<a href="%(ScoURL)s/about" class="sidebar">A propos</a><br/>

View File

@ -28,6 +28,7 @@
"""Calculs sur les notes et cache des resultats
"""
from types import StringType, FloatType
import time
import pdb
import inspect
@ -35,7 +36,7 @@ import inspect
import scolars
import sco_groups
from notes_log import log, logCallStack
from sco_utils import *
import sco_utils as scu
import notesdb as ndb
import sco_codes_parcours
from sco_codes_parcours import DEF, UE_SPORT, UE_is_fondamentale, UE_is_professionnelle
@ -56,7 +57,7 @@ from sco_exceptions import (
)
# Support for old user-written "bonus" functions with 2 args:
BONUS_TWO_ARGS = len(inspect.getargspec(CONFIG.compute_bonus)[0]) == 2
BONUS_TWO_ARGS = len(inspect.getargspec(scu.CONFIG.compute_bonus)[0]) == 2
def comp_ranks(T):
@ -195,7 +196,7 @@ class NotesTable:
for i in range(len(self.inscrlist)):
rangalpha[self.inscrlist[i]["etudid"]] = i
self.bonus = DictDefault(defaultvalue=0)
self.bonus = scu.DictDefault(defaultvalue=0)
# Notes dans les modules { moduleimpl_id : { etudid: note_moyenne_dans_ce_module } }
(
self._modmoys,
@ -371,16 +372,19 @@ class NotesTable:
def get_sexnom(self, etudid):
"M. DUPONT"
etud = self.identdict[etudid]
return etud["sexe"] + " " + strupper(etud["nom_usuel"] or etud["nom"])
return etud["sexe"] + " " + scu.strupper(etud["nom_usuel"] or etud["nom"])
def get_nom_short(self, etudid):
"formatte nom d'un etud (pour table recap)"
etud = self.identdict[etudid]
# Attention aux caracteres multibytes pour decouper les 2 premiers:
return (
strupper(etud["nom_usuel"] or etud["nom"])
scu.strupper(etud["nom_usuel"] or etud["nom"])
+ " "
+ etud["prenom"].decode(SCO_ENCODING).capitalize()[:2].encode(SCO_ENCODING)
+ etud["prenom"]
.decode(scu.SCO_ENCODING)
.capitalize()[:2]
.encode(scu.SCO_ENCODING)
+ "."
)
@ -624,7 +628,7 @@ class NotesTable:
# si 'NI', etudiant non inscrit a ce module
if val != "NI":
est_inscrit = True
if modimpl["module"]["module_type"] == MODULE_STANDARD:
if modimpl["module"]["module_type"] == scu.MODULE_STANDARD:
coef = modimpl["module"]["coefficient"]
if modimpl["ue"]["type"] != UE_SPORT:
notes.append(val, name=modimpl["module"]["code"])
@ -660,7 +664,7 @@ class NotesTable:
except:
# log('comp_etud_moy_ue: exception: val=%s coef=%s' % (val,coef))
pass
elif modimpl["module"]["module_type"] == MODULE_MALUS:
elif modimpl["module"]["module_type"] == scu.MODULE_MALUS:
try:
ue_malus += val
except:
@ -680,7 +684,7 @@ class NotesTable:
moy = sum_notes / sum_coefs
if ue_malus:
moy -= ue_malus
moy = max(NOTES_MIN, min(moy, 20.0))
moy = max(scu.NOTES_MIN, min(moy, 20.0))
moy_valid = True
else:
moy = "NA"
@ -906,7 +910,7 @@ class NotesTable:
# mu["moy"] can be a number, or "NA", or "ERR" (user-defined UE formulas)
if (
(mu["ue"]["type"] != UE_SPORT)
and isnumber(mu["moy"])
and scu.isnumber(mu["moy"])
and (mu["est_inscrit"] or mu["is_capitalized"])
):
coef_ue = mu["ue"]["coefficient"]
@ -939,9 +943,11 @@ class NotesTable:
if BONUS_TWO_ARGS:
# backward compat: compute_bonus took only 2 args
bonus = CONFIG.compute_bonus(notes_bonus_gen, coefs_bonus_gen)
bonus = scu.CONFIG.compute_bonus(
notes_bonus_gen, coefs_bonus_gen
)
else:
bonus = CONFIG.compute_bonus(
bonus = scu.CONFIG.compute_bonus(
notes_bonus_gen, coefs_bonus_gen, infos=infos
)
self.bonus[etudid] = bonus
@ -1154,7 +1160,7 @@ class NotesTable:
ue_capitalisees = { etudid :
[{ 'moy':, 'event_date' : ,'formsemestre_id' : }, ...] }
"""
self.ue_capitalisees = DictDefault(defaultvalue=[])
self.ue_capitalisees = scu.DictDefault(defaultvalue=[])
cnx = None
for etudid in self.get_etudids():
capital = formsemestre_get_etud_capitalisation(
@ -1295,7 +1301,7 @@ class NotesTable:
{
"formsemestre_id": self.formsemestre_id,
"etudid": etudid,
"code_attente": NOTES_ATTENTE,
"code_attente": scu.NOTES_ATTENTE,
},
)
return len(cursor.fetchall()) > 0
@ -1339,7 +1345,7 @@ class CacheNotesTable:
# Cache des classeur PDF (bulletins)
self.pdfcache = {} # { formsemestre_id : (filename, pdfdoc) }
# Listeners:
self.listeners = DictDefault(
self.listeners = scu.DictDefault(
defaultvalue={}
) # {formsemestre_id : {listener_id : callback }}

View File

@ -37,12 +37,14 @@ Created on Thu Sep 8 09:36:33 2016
"""
from __future__ import print_function
import os
import datetime
import operator
import re
import unicodedata
from sco_utils import *
import sco_utils as scu
from notes_log import log
import notes_table
PE_DEBUG = 0
@ -175,7 +177,7 @@ def add_pe_stuff_to_zip(context, zipfile, ziproot):
Also copy logos
"""
PE_AUX_DIR = os.path.join(SCO_SRCDIR, "config/doc_poursuites_etudes")
PE_AUX_DIR = os.path.join(scu.SCO_SRCDIR, "config/doc_poursuites_etudes")
distrib_dir = os.path.join(PE_AUX_DIR, "distrib")
distrib_pathnames = list_directory_filenames(
distrib_dir
@ -204,7 +206,7 @@ def add_pe_stuff_to_zip(context, zipfile, ziproot):
# Logos: (add to logos/ directory in zip)
logos_names = ["logo_header.jpg", "logo_footer.jpg"]
for f in logos_names:
logo = os.path.join(SCODOC_LOGOS_DIR, f)
logo = os.path.join(scu.SCODOC_LOGOS_DIR, f)
if os.path.isfile(logo):
add_local_file_to_zip(zipfile, ziproot, logo, "avis/logos/" + f)

View File

@ -35,7 +35,7 @@
"""
from sco_utils import *
import sco_utils as scu
from notes_log import log
import sco_formsemestre
import sco_formsemestre_status
@ -110,7 +110,7 @@ def pe_view_sem_recap(
# template fourni via le formulaire Web
if avis_tmpl_file:
template_latex = avis_tmpl_file.read()
template_latex = template_latex.decode(SCO_ENCODING)
template_latex = template_latex.decode(scu.SCO_ENCODING)
else:
# template indiqué dans préférences ScoDoc ?
template_latex = pe_avislatex.get_code_latex_from_scodoc_preference(
@ -127,7 +127,7 @@ def pe_view_sem_recap(
# template fourni via le formulaire Web
if footer_tmpl_file:
footer_latex = footer_tmpl_file.read()
footer_latex = footer_latex.decode(SCO_ENCODING)
footer_latex = footer_latex.decode(scu.SCO_ENCODING)
else:
footer_latex = pe_avislatex.get_code_latex_from_scodoc_preference(
context, formsemestre_id, champ="pe_avis_latex_footer"

View File

@ -31,6 +31,7 @@
Il suffit d'appeler abs_notify() après chaque ajout d'absence.
"""
import datetime
from email.MIMEMultipart import ( # pylint: disable=no-name-in-module,import-error
MIMEMultipart,
)
@ -40,7 +41,7 @@ from email.Header import Header # pylint: disable=no-name-in-module,import-erro
from email import Encoders # pylint: disable=no-name-in-module,import-error
import notesdb as ndb
from sco_utils import *
import sco_utils as scu
from notes_log import log
from scolog import logdb
import sco_bulletins
@ -257,10 +258,10 @@ def abs_notification_message(context, sem, prefs, etudid, nbabs, nbabsjust):
subject = """Trop d'absences pour %(nomprenom)s""" % etud
#
msg = MIMEMultipart()
subj = Header("[ScoDoc] " + subject, SCO_ENCODING)
subj = Header("[ScoDoc] " + subject, scu.SCO_ENCODING)
msg["Subject"] = subj
msg["From"] = prefs["email_from_addr"]
txt = MIMEText(txt, "plain", SCO_ENCODING)
txt = MIMEText(txt, "plain", scu.SCO_ENCODING)
msg.attach(txt)
return msg

View File

@ -46,7 +46,7 @@ Pour chaque étudiant commun:
from collections import OrderedDict
from sco_utils import *
import sco_utils as scu
from notes_log import log
import sco_apogee_csv
from gen_tables import GenTable

View File

@ -45,15 +45,17 @@
qui est une description (humaine, format libre) de l'archive.
"""
import os
import time
from mx.DateTime import DateTime as mxDateTime
import mx.DateTime
import re
import shutil
import glob
from sco_utils import *
import sco_utils as scu
import notesdb as ndb
from notes_log import log
import sco_formsemestre
import sco_pvjury
import sco_excel
@ -62,6 +64,7 @@ import sco_groups
import sco_groups_view
from sco_recapcomplet import make_formsemestre_recapcomplet
import sco_bulletins_pdf
from TrivialFormulator import TrivialFormulator
from sco_exceptions import (
AccessDenied,
)
@ -78,12 +81,12 @@ class BaseArchiver:
for dir in dirs[1:]:
path = os.path.join(path, dir)
try:
GSL.acquire()
scu.GSL.acquire()
if not os.path.isdir(path):
log("creating directory %s" % path)
os.mkdir(path)
finally:
GSL.release()
scu.GSL.release()
def get_obj_dir(self, context, oid):
"""
@ -92,7 +95,7 @@ class BaseArchiver:
"""
dept_dir = os.path.join(self.root, context.DeptId())
try:
GSL.acquire()
scu.GSL.acquire()
if not os.path.isdir(dept_dir):
log("creating directory %s" % dept_dir)
os.mkdir(dept_dir)
@ -101,7 +104,7 @@ class BaseArchiver:
log("creating directory %s" % obj_dir)
os.mkdir(obj_dir)
finally:
GSL.release()
scu.GSL.release()
return obj_dir
def list_oids(self, context):
@ -129,10 +132,10 @@ class BaseArchiver:
def delete_archive(self, archive_id):
"""Delete (forever) this archive"""
try:
GSL.acquire()
scu.GSL.acquire()
shutil.rmtree(archive_id, ignore_errors=True)
finally:
GSL.release()
scu.GSL.release()
def get_archive_date(self, archive_id):
"""Returns date (as a DateTime object) of an archive"""
@ -142,10 +145,10 @@ class BaseArchiver:
def list_archive(self, archive_id):
"""Return list of filenames (without path) in archive"""
try:
GSL.acquire()
scu.GSL.acquire()
files = os.listdir(archive_id)
finally:
GSL.release()
scu.GSL.release()
files.sort()
return [f for f in files if f and f[0] != "_"]
@ -185,10 +188,10 @@ class BaseArchiver:
)
log("creating archive: %s" % archive_id)
try:
GSL.acquire()
scu.GSL.acquire()
os.mkdir(archive_id) # if exists, raises an OSError
finally:
GSL.release()
scu.GSL.release()
self.store(archive_id, "_description.txt", description)
return archive_id
@ -197,21 +200,21 @@ class BaseArchiver:
Filename may be modified (sanitized): return used filename
The file is created or replaced.
"""
filename = sanitize_filename(filename)
filename = scu.sanitize_filename(filename)
log("storing %s (%d bytes) in %s" % (filename, len(data), archive_id))
try:
GSL.acquire()
scu.GSL.acquire()
fname = os.path.join(archive_id, filename)
f = open(fname, "w")
f.write(data)
f.close()
finally:
GSL.release()
scu.GSL.release()
return filename
def get(self, archive_id, filename):
"""Retreive data"""
if not is_valid_filename(filename):
if not scu.is_valid_filename(filename):
log('Archiver.get: invalid filename "%s"' % filename)
raise ValueError("invalid filename")
fname = os.path.join(archive_id, filename)
@ -223,18 +226,18 @@ class BaseArchiver:
# XXX très incomplet: devrait inférer et assigner un type MIME
archive_id = self.get_id_from_name(context, oid, archive_name)
data = self.get(archive_id, filename)
ext = os.path.splitext(strlower(filename))[1]
ext = os.path.splitext(scu.strlower(filename))[1]
if ext == ".html" or ext == ".htm":
return data
elif ext == ".xml":
REQUEST.RESPONSE.setHeader("content-type", XML_MIMETYPE)
REQUEST.RESPONSE.setHeader("content-type", scu.XML_MIMETYPE)
return data
elif ext == ".xls":
return sco_excel.sendExcelFile(REQUEST, data, filename)
elif ext == ".csv":
return sendCSVFile(REQUEST, data, filename)
return scu.sendCSVFile(REQUEST, data, filename)
elif ext == ".pdf":
return sendPDFFile(REQUEST, data, filename)
return scu.sendPDFFile(REQUEST, data, filename)
return data # should set mimetype...

View File

@ -30,7 +30,7 @@
les dossiers d'admission et autres pièces utiles.
"""
from sco_utils import *
import sco_utils as scu
from notes_log import log
import ImportScolars
import sco_formsemestre
@ -40,6 +40,7 @@ import sco_excel
import sco_archives
from sco_permissions import ScoEtudAddAnnotations
from sco_exceptions import AccessDenied
from TrivialFormulator import TrivialFormulator
class EtudsArchiver(sco_archives.BaseArchiver):
@ -67,10 +68,10 @@ def etud_list_archives_html(context, REQUEST, etudid):
"content": EtudsArchive.list_archive(archive_id),
}
L.append(a)
delete_icon = icontag(
delete_icon = scu.icontag(
"delete_small_img", title="Supprimer fichier", alt="supprimer"
)
delete_disabled_icon = icontag(
delete_disabled_icon = scu.icontag(
"delete_small_dis_img", title="Suppression non autorisée"
)
H = ['<div class="etudarchive"><ul>']
@ -139,7 +140,7 @@ def etud_upload_file_form(context, REQUEST, etudid):
% etud,
"""<p>Le fichier ne doit pas dépasser %sMo.</p>
"""
% (CONFIG.ETUD_MAX_FILE_SIZE / (1024 * 1024)),
% (scu.CONFIG.ETUD_MAX_FILE_SIZE / (1024 * 1024)),
]
tf = TrivialFormulator(
REQUEST.URL0,
@ -179,7 +180,7 @@ def _store_etud_file_to_new_archive(
):
"""Store data to new archive."""
filesize = len(data)
if filesize < 10 or filesize > CONFIG.ETUD_MAX_FILE_SIZE:
if filesize < 10 or filesize > scu.CONFIG.ETUD_MAX_FILE_SIZE:
return 0, "Fichier image de taille invalide ! (%d)" % filesize
archive_id = EtudsArchive.create_obj_archive(context, etudid, description)
EtudsArchive.store(archive_id, filename, data)

View File

@ -31,7 +31,7 @@
(coût théorique en heures équivalent TD)
"""
import notesdb as ndb
from sco_utils import *
import sco_utils as scu
from notes_log import log
from gen_tables import GenTable
import sco_excel, sco_pdf
@ -39,6 +39,7 @@ from sco_pdf import SU
import sco_formsemestre
import sco_moduleimpl
import sco_formsemestre_status
import VERSION
def formsemestre_table_estim_cost(
@ -144,7 +145,7 @@ def formsemestre_table_estim_cost(
(dans ce cas, retoucher le tableau excel exporté).
</div>
""",
origin="Généré par %s le " % VERSION.SCONAME + timedate_human_repr() + "",
origin="Généré par %s le " % VERSION.SCONAME + scu.timedate_human_repr() + "",
filename="EstimCout-S%s" % sem["semestre_id"],
)
return tab

View File

@ -28,7 +28,7 @@
"""Page accueil département (liste des semestres, etc)
"""
import notesdb as ndb
from sco_utils import *
import sco_utils as scu
from notes_log import log
import sco_modalites
import sco_news
@ -45,7 +45,7 @@ def index_html(context, REQUEST=None, showcodes=0, showsemtable=0):
# News:
# 2020-12-30: abandonne l'icon rss
# rssicon = icontag("rssscodoc_img", title="Flux RSS", border="0")
# rssicon = scu.icontag("rssscodoc_img", title="Flux RSS", border="0")
H.append(sco_news.scolar_news_summary_html(context)) # , rssicon=rssicon))
# Avertissement de mise à jour:
@ -56,9 +56,11 @@ def index_html(context, REQUEST=None, showcodes=0, showsemtable=0):
cursems = [] # semestres "courants"
othersems = [] # autres (verrouillés)
# icon image:
groupicon = icontag("groupicon_img", title="Inscrits", border="0")
emptygroupicon = icontag("emptygroupicon_img", title="Pas d'inscrits", border="0")
lockicon = icontag("lock32_img", title="verrouillé", border="0")
groupicon = scu.icontag("groupicon_img", title="Inscrits", border="0")
emptygroupicon = scu.icontag(
"emptygroupicon_img", title="Pas d'inscrits", border="0"
)
lockicon = scu.icontag("lock32_img", title="verrouillé", border="0")
# Sélection sur l'etat du semestre
for sem in sems:
if sem["etat"] == "1" and sem["modalite"] != "EXT":

View File

@ -46,7 +46,7 @@ pg_dump SCORT | psql ANORT
"""
import os
import fcntl
import subprocess
import requests
@ -61,7 +61,7 @@ from email import Encoders # pylint: disable=no-name-in-module,import-error
import notesdb as ndb
from sco_utils import *
import sco_utils as scu
from notes_log import log
from sco_exceptions import ScoValueError
@ -98,22 +98,25 @@ def sco_dump_and_send_db(context, REQUEST=None):
# Send
r = _send_db(context, REQUEST, ano_db_name)
if r.status_code == requests.codes.INSUFFICIENT_STORAGE:
if (
r.status_code
== requests.codes.INSUFFICIENT_STORAGE # pylint: disable=no-member
):
H.append(
"""<p class="warning">
Erreur: espace serveur trop plein.
Merci de contacter <a href="mailto:{0}">{0}</a></p>""".format(
SCO_DEV_MAIL
scu.SCO_DEV_MAIL
)
)
elif r.status_code == requests.codes.OK:
elif r.status_code == requests.codes.OK: # pylint: disable=no-member
H.append("""<p>Opération effectuée.</p>""")
else:
H.append(
"""<p class="warning">
Erreur: code <tt>{0} {1}</tt>
Merci de contacter <a href="mailto:{2}">{2}</a></p>""".format(
r.status_code, r.reason, SCO_DEV_MAIL
r.status_code, r.reason, scu.SCO_DEV_MAIL
)
)
@ -133,7 +136,7 @@ def _duplicate_db(db_name, ano_db_name):
cmd = ["createdb", "-E", "UTF-8", ano_db_name]
log("sco_dump_and_send_db/_duplicate_db: {}".format(cmd))
try:
out = subprocess.check_output(cmd)
_ = subprocess.check_output(cmd)
except subprocess.CalledProcessError as e:
log("sco_dump_and_send_db: exception createdb {}".format(e))
raise ScoValueError(
@ -143,7 +146,7 @@ def _duplicate_db(db_name, ano_db_name):
cmd = "pg_dump {} | psql {}".format(db_name, ano_db_name)
log("sco_dump_and_send_db/_duplicate_db: {}".format(cmd))
try:
out = subprocess.check_output(cmd, shell=1)
_ = subprocess.check_output(cmd, shell=1)
except subprocess.CalledProcessError as e:
log("sco_dump_and_send_db: exception {}".format(e))
raise ScoValueError(
@ -155,10 +158,10 @@ def _duplicate_db(db_name, ano_db_name):
def _anonymize_db(ano_db_name):
"""Anonymize a departement database"""
cmd = os.path.join(SCO_CONFIG_DIR, "anonymize_db.py")
cmd = os.path.join(scu.SCO_CONFIG_DIR, "anonymize_db.py")
log("_anonymize_db: {}".format(cmd))
try:
out = subprocess.check_output([cmd, ano_db_name])
_ = subprocess.check_output([cmd, ano_db_name])
except subprocess.CalledProcessError as e:
log("sco_dump_and_send_db: exception in anonymisation: {}".format(e))
raise ScoValueError(
@ -168,7 +171,7 @@ def _anonymize_db(ano_db_name):
def _get_scodoc_serial(context):
try:
return int(open(os.path.join(SCODOC_VERSION_DIR, "scodoc.sn")).read())
return int(open(os.path.join(scu.SCODOC_VERSION_DIR, "scodoc.sn")).read())
except:
return 0
@ -187,7 +190,7 @@ def _send_db(context, REQUEST, ano_db_name):
log("uploading anonymized dump...")
files = {"file": (ano_db_name + ".gz", data)}
r = requests.post(
SCO_DUMP_UP_URL,
scu.SCO_DUMP_UP_URL,
files=files,
data={
"dept_name": context.get_preference("DeptName"),
@ -196,8 +199,8 @@ def _send_db(context, REQUEST, ano_db_name):
"sent_by": context.Users.user_info(str(REQUEST.AUTHENTICATED_USER))[
"nomcomplet"
],
"sco_version": SCOVERSION,
"sco_subversion": get_svn_version(SCO_CONFIG_DIR),
"sco_version": scu.SCOVERSION,
"sco_subversion": scu.get_svn_version(scu.SCO_CONFIG_DIR),
},
)
return r
@ -215,7 +218,7 @@ def _drop_ano_db(ano_db_name):
cmd = ["dropdb", ano_db_name]
log("sco_dump_and_send_db: {}".format(cmd))
try:
out = subprocess.check_output(cmd)
_ = subprocess.check_output(cmd)
except subprocess.CalledProcessError as e:
log("sco_dump_and_send_db: exception dropdb {}".format(e))
raise ScoValueError(

View File

@ -29,9 +29,9 @@
(portage from DTML)
"""
import notesdb as ndb
from sco_utils import *
import sco_utils as scu
from notes_log import log
from TrivialFormulator import TrivialFormulator, TF
from TrivialFormulator import TrivialFormulator, TF, tf_error_message
import sco_codes_parcours
import sco_formsemestre
from sco_exceptions import ScoValueError

View File

@ -29,9 +29,9 @@
(portage from DTML)
"""
import notesdb as ndb
from sco_utils import *
import sco_utils as scu
from notes_log import log
from TrivialFormulator import TrivialFormulator, TF
from TrivialFormulator import TrivialFormulator, TF, tf_error_message
import sco_formsemestre
from sco_exceptions import ScoValueError
@ -91,7 +91,7 @@ associé.
+ tf[1]
+ context.sco_footer(REQUEST)
)
matiere_id = context.do_matiere_create(tf[2], REQUEST)
_ = context.do_matiere_create(tf[2], REQUEST)
return REQUEST.RESPONSE.redirect(dest_url)

View File

@ -29,7 +29,7 @@
(portage from DTML)
"""
import notesdb as ndb
from sco_utils import *
import sco_utils as scu
from notes_log import log
import sco_codes_parcours
from TrivialFormulator import TrivialFormulator, TF
@ -101,7 +101,7 @@ def module_create(context, matiere_id=None, REQUEST=None):
"title": "Type",
"explanation": "",
"labels": ("Standard", "Malus"),
"allowed_values": (str(MODULE_STANDARD), str(MODULE_MALUS)),
"allowed_values": (str(scu.MODULE_STANDARD), str(scu.MODULE_MALUS)),
},
),
(
@ -142,7 +142,7 @@ def module_create(context, matiere_id=None, REQUEST=None):
{
"input_type": "menu",
"type": "int",
"title": strcapitalize(parcours.SESSION_NAME),
"title": scu.strcapitalize(parcours.SESSION_NAME),
"explanation": "%s de début du module dans la formation standard"
% parcours.SESSION_NAME,
"labels": [str(x) for x in semestres_indices],
@ -288,7 +288,7 @@ def module_edit(context, module_id=None, REQUEST=None):
"title": "Type",
"explanation": "",
"labels": ("Standard", "Malus"),
"allowed_values": (str(MODULE_STANDARD), str(MODULE_MALUS)),
"allowed_values": (str(scu.MODULE_STANDARD), str(scu.MODULE_MALUS)),
"enabled": unlocked,
},
),
@ -401,7 +401,7 @@ def edit_module_set_code_apogee(context, id=None, value=None, REQUEST=None):
context.do_module_edit({"module_id": module_id, "code_apogee": value})
if not value:
value = APO_MISSING_CODE_STR
value = scu.APO_MISSING_CODE_STR
return value
@ -446,7 +446,7 @@ def formation_add_malus_modules(context, formation_id, titre=None, REQUEST=None)
[
mod
for mod in context.do_module_list(args={"ue_id": ue["ue_id"]})
if mod["module_type"] == MODULE_MALUS
if mod["module_type"] == scu.MODULE_MALUS
]
)
if nb_mod_malus == 0:
@ -492,7 +492,7 @@ def ue_add_malus_module(context, ue_id, titre=None, code=None, REQUEST=None):
"matiere_id": matiere_id,
"formation_id": ue["formation_id"],
"semestre_id": semestre_id,
"module_type": MODULE_MALUS,
"module_type": scu.MODULE_MALUS,
},
REQUEST,
)

View File

@ -29,7 +29,7 @@
"""
import notesdb as ndb
from sco_utils import *
import sco_utils as scu
from notes_log import log
from TrivialFormulator import TrivialFormulator, TF
from gen_tables import GenTable
@ -160,7 +160,7 @@ def ue_edit(context, ue_id=None, create=False, formation_id=None, REQUEST=None):
{
"input_type": "menu",
"type": "int",
"title": strcapitalize(parcours.SESSION_NAME),
"title": scu.strcapitalize(parcours.SESSION_NAME),
"explanation": "%s de début du module dans la formation"
% parcours.SESSION_NAME,
"labels": [str(x) for x in semestres_indices],
@ -308,15 +308,15 @@ def ue_list(context, formation_id=None, msg="", REQUEST=None):
editable = perm_change
tag_editable = authuser.has_permission(ScoEditFormationTags, context) or perm_change
if locked:
lockicon = icontag("lock32_img", title="verrouillé")
lockicon = scu.icontag("lock32_img", title="verrouillé")
else:
lockicon = ""
arrow_up, arrow_down, arrow_none = sco_groups.getArrowIconsTags(context, REQUEST)
delete_icon = icontag(
delete_icon = scu.icontag(
"delete_small_img", title="Supprimer (module inutilisé)", alt="supprimer"
)
delete_disabled_icon = icontag(
delete_disabled_icon = scu.icontag(
"delete_small_dis_img", title="Suppression impossible (module utilisé)"
)
H = [
@ -417,7 +417,7 @@ Si vous souhaitez modifier cette formation (par exemple pour y ajouter un module
klass = ""
UE["code_apogee_str"] = (
""", Apo: <span class="%s" data-url="edit_ue_set_code_apogee" id="%s" data-placeholder="%s">"""
% (klass, UE["ue_id"], APO_MISSING_CODE_STR)
% (klass, UE["ue_id"], scu.APO_MISSING_CODE_STR)
+ (UE["code_apogee"] or "")
+ "</span>"
)
@ -493,7 +493,7 @@ Si vous souhaitez modifier cette formation (par exemple pour y ajouter un module
Mod["module_id"]
)
klass = "notes_module_list"
if Mod["module_type"] == MODULE_MALUS:
if Mod["module_type"] == scu.MODULE_MALUS:
klass += " module_malus"
H.append('<li class="%s">' % klass)
@ -532,7 +532,7 @@ Si vous souhaitez modifier cette formation (par exemple pour y ajouter un module
)
H.append(
'<span class="formation_module_tit">%s</span>'
% join_words(Mod["code"], Mod["titre"])
% scu.join_words(Mod["code"], Mod["titre"])
)
if mod_editable:
H.append("</a>")
@ -546,7 +546,7 @@ Si vous souhaitez modifier cette formation (par exemple pour y ajouter un module
klass = ""
heurescoef += (
', Apo: <span class="%s" data-url="edit_module_set_code_apogee" id="%s" data-placeholder="%s">'
% (klass, Mod["module_id"], APO_MISSING_CODE_STR)
% (klass, Mod["module_id"], scu.APO_MISSING_CODE_STR)
+ (Mod["code_apogee"] or "")
+ "</span>"
)
@ -778,7 +778,7 @@ def edit_ue_set_code_apogee(context, id=None, value=None, REQUEST=None):
dont_invalidate_cache=False,
)
if not value:
value = APO_MISSING_CODE_STR
value = scu.APO_MISSING_CODE_STR
return value
@ -850,7 +850,7 @@ def formation_table_recap(context, formation_id, format="html", REQUEST=None):
columns_ids=columns_ids,
rows=T,
titles=titles,
origin="Généré par %s le " % VERSION.SCONAME + timedate_human_repr() + "",
origin="Généré par %s le " % scu.VERSION.SCONAME + scu.timedate_human_repr() + "",
caption=title,
html_caption=title,
html_class="table_leftalign",

View File

@ -38,7 +38,8 @@ import traceback
import icalendar
import pprint
from sco_utils import *
import sco_utils as scu
from notes_log import log
import sco_formsemestre
import sco_groups
import sco_groups_view
@ -148,7 +149,7 @@ def group_edt_json(context, group_id, start="", end="", REQUEST=None):
}
J.append(d)
return sendJSON(REQUEST, J)
return scu.sendJSON(REQUEST, J)
"""XXX

View File

@ -75,7 +75,9 @@
"""
from sco_utils import *
import re
import sco_utils as scu
from notes_log import log
import sco_formsemestre
import notes_table
@ -111,7 +113,7 @@ def apo_csv_store(context, csv_data, annee_scolaire, sem_id):
"""
# sanity check
filesize = len(csv_data)
if filesize < 10 or filesize > CONFIG.ETUD_MAX_FILE_SIZE:
if filesize < 10 or filesize > scu.CONFIG.ETUD_MAX_FILE_SIZE:
raise ScoValueError("Fichier csv de taille invalide ! (%d)" % filesize)
if not annee_scolaire:

View File

@ -31,7 +31,7 @@
from cStringIO import StringIO
from zipfile import ZipFile
from sco_utils import *
import sco_utils as scu
from notes_log import log
import sco_formsemestre
import sco_formsemestre_status
@ -448,7 +448,7 @@ def table_apo_csv_list(context, semset, REQUEST=None):
)
t["_filename_target"] = view_link
t["_etape_apo_target"] = view_link
t["suppress"] = icontag(
t["suppress"] = scu.icontag(
"delete_small_img", border="0", alt="supprimer", title="Supprimer"
)
t["_suppress_target"] = "view_apo_csv_delete?etape_apo=%s&semset_id=%s" % (
@ -485,8 +485,8 @@ def view_apo_etuds(context, semset_id, title="", nips=[], format="html", REQUEST
if not semset_id:
raise ValueError("invalid null semset_id")
semset = sco_semset.SemSet(context, semset_id=semset_id)
annee_scolaire = semset["annee_scolaire"]
sem_id = semset["sem_id"]
# annee_scolaire = semset["annee_scolaire"]
# sem_id = semset["sem_id"]
if nips and type(nips) != type([]):
nips = [nips]
@ -687,7 +687,7 @@ def view_apo_csv(context, etape_apo="", semset_id="", format="html", REQUEST=Non
sem_id = semset["sem_id"]
csv_data = sco_etape_apogee.apo_csv_get(context, etape_apo, annee_scolaire, sem_id)
if format == "raw":
return sendCSVFile(REQUEST, csv_data, etape_apo + ".txt")
return scu.sendCSVFile(REQUEST, csv_data, etape_apo + ".txt")
apo_data = sco_apogee_csv.ApoData(csv_data, periode=semset["sem_id"])
(
@ -839,7 +839,7 @@ def apo_csv_export_results(
+ "-%s-" % periode
+ "-".join(etapes_apo)
)
basename = sco_archives.sanitize_filename(unescape_html(basename))
basename = scu.sanitize_filename(scu.unescape_html(basename))
dest_zip.close()
size = data.tell()

View File

@ -33,8 +33,9 @@ from pyExcelerator import *
from notes_log import log
from scolog import logdb
from sco_exceptions import *
from sco_utils import *
from sco_exceptions import ScoValueError
import sco_utils as scu
import notesdb
import time, datetime
@ -57,9 +58,11 @@ def sendExcelFile(REQUEST, data, filename):
(on ne doit rien avoir émis avant, car ici sont générés les entetes)
"""
filename = (
unescape_html(suppress_accents(filename)).replace("&", "").replace(" ", "_")
scu.unescape_html(scu.suppress_accents(filename))
.replace("&", "")
.replace(" ", "_")
)
REQUEST.RESPONSE.setHeader("content-type", XLS_MIMETYPE)
REQUEST.RESPONSE.setHeader("content-type", scu.XLS_MIMETYPE)
REQUEST.RESPONSE.setHeader(
"content-disposition", 'attachment; filename="%s"' % filename
)
@ -216,7 +219,7 @@ class ScoExcelSheet:
sauvegarde = True
else:
sauvegarde = False
ws0 = wb.add_sheet(self.sheet_name.decode(SCO_ENCODING))
ws0 = wb.add_sheet(self.sheet_name.decode(scu.SCO_ENCODING))
li = 0
for l in self.cells:
co = 0
@ -225,7 +228,7 @@ class ScoExcelSheet:
if type(c) == LongType:
c = int(c) # assume all ScoDoc longs fits in int !
elif type(c) not in (IntType, FloatType):
c = str(c).decode(SCO_ENCODING)
c = str(c).decode(scu.SCO_ENCODING)
ws0.write(li, co, c, self.get_cell_style(li, co))
co += 1
@ -240,14 +243,14 @@ def Excel_SimpleTable(titles=[], lines=[[]], SheetName="feuille", titlesStyles=[
"""Export simple type 'CSV': 1ere ligne en gras, le reste tel quel"""
# XXX devrait maintenant utiliser ScoExcelSheet
wb = Workbook()
ws0 = wb.add_sheet(SheetName.decode(SCO_ENCODING))
ws0 = wb.add_sheet(SheetName.decode(scu.SCO_ENCODING))
if not titlesStyles:
style = Excel_MakeStyle(bold=True)
titlesStyles = [style] * len(titles)
# ligne de titres
col = 0
for it in titles:
ws0.write(0, col, it.decode(SCO_ENCODING), titlesStyles[col])
ws0.write(0, col, it.decode(scu.SCO_ENCODING), titlesStyles[col])
col += 1
# suite
default_style = Excel_MakeStyle()
@ -262,7 +265,7 @@ def Excel_SimpleTable(titles=[], lines=[[]], SheetName="feuille", titlesStyles=[
if type(it) == LongType:
it = int(it) # assume all ScoDoc longs fits in int !
elif type(it) not in (IntType, FloatType):
it = str(it).decode(SCO_ENCODING)
it = str(it).decode(scu.SCO_ENCODING)
cell_style = text_style
ws0.write(li, col, it, cell_style)
col += 1
@ -279,7 +282,7 @@ def Excel_feuille_saisie(E, titreannee, description, lines):
"""
SheetName = "Saisie notes"
wb = Workbook()
ws0 = wb.add_sheet(SheetName.decode(SCO_ENCODING))
ws0 = wb.add_sheet(SheetName.decode(scu.SCO_ENCODING))
# ajuste largeurs colonnes (unite inconnue, empirique)
ws0.col(0).width = 400 # codes
ws0.col(1).width = 6000 # noms
@ -366,10 +369,14 @@ def Excel_feuille_saisie(E, titreannee, description, lines):
ws0.write(li, 0, u"Ne pas modifier les cases en mauve !", style_expl)
li += 1
# Nom du semestre
ws0.write(li, 0, unescape_html(titreannee).decode(SCO_ENCODING), style_titres)
ws0.write(
li, 0, scu.unescape_html(titreannee).decode(scu.SCO_ENCODING), style_titres
)
li += 1
# description evaluation
ws0.write(li, 0, unescape_html(description).decode(SCO_ENCODING), style_titres)
ws0.write(
li, 0, scu.unescape_html(description).decode(scu.SCO_ENCODING), style_titres
)
li += 1
ws0.write(
li, 0, u"Evaluation du %s (coef. %g)" % (E["jour"], E["coefficient"]), style
@ -387,7 +394,7 @@ def Excel_feuille_saisie(E, titreannee, description, lines):
for line in lines:
li += 1
st = style_nom
ws0.write(li, 0, ("!" + line[0]).decode(SCO_ENCODING), style_ro) # code
ws0.write(li, 0, ("!" + line[0]).decode(scu.SCO_ENCODING), style_ro) # code
if line[3] != "I":
st = style_dem
if line[3] == "D": # demissionnaire
@ -396,15 +403,15 @@ def Excel_feuille_saisie(E, titreannee, description, lines):
s = line[3] # etat autre
else:
s = line[4] # groupes TD/TP/...
ws0.write(li, 1, line[1].decode(SCO_ENCODING), st)
ws0.write(li, 2, line[2].decode(SCO_ENCODING), st)
ws0.write(li, 3, s.decode(SCO_ENCODING), st)
ws0.write(li, 1, line[1].decode(scu.SCO_ENCODING), st)
ws0.write(li, 2, line[2].decode(scu.SCO_ENCODING), st)
ws0.write(li, 3, s.decode(scu.SCO_ENCODING), st)
try:
val = float(line[5])
except:
val = line[5].decode(SCO_ENCODING)
val = line[5].decode(scu.SCO_ENCODING)
ws0.write(li, 4, val, style_notes) # note
ws0.write(li, 5, line[6].decode(SCO_ENCODING), style_comment) # comment
ws0.write(li, 5, line[6].decode(scu.SCO_ENCODING), style_comment) # comment
# explication en bas
li += 2
ws0.write(li, 1, u"Code notes", style_titres)
@ -426,7 +433,7 @@ def Excel_to_list(data, convert_to_string=str): # we may need 'encoding' argume
convert_to_string is a conversion function applied to all non-string values (ie numbers)
"""
try:
P = parse_xls("", SCO_ENCODING, doc=data)
P = parse_xls("", scu.SCO_ENCODING, doc=data)
except:
log("Excel_to_list: failure to import document")
open("/tmp/last_scodoc_import_failure.xls", "w").write(data)
@ -443,7 +450,7 @@ def Excel_to_list(data, convert_to_string=str): # we may need 'encoding' argume
diag.append("Attention: n'utilise que la première feuille du classeur !")
# fill matrix
sheet_name, values = P[0]
sheet_name = sheet_name.encode(SCO_ENCODING, "backslashreplace")
sheet_name = sheet_name.encode(scu.SCO_ENCODING, "backslashreplace")
if not values:
diag.append("Aucune valeur trouvée dans le classeur !")
return diag, None
@ -454,13 +461,13 @@ def Excel_to_list(data, convert_to_string=str): # we may need 'encoding' argume
nbcols = max(cols) + 1
nbrows = max(rows) + 1
M = []
for i in range(nbrows):
for _ in range(nbrows):
M.append([""] * nbcols)
for row_idx, col_idx in indexes:
v = values[(row_idx, col_idx)]
if isinstance(v, unicode):
v = v.encode(SCO_ENCODING, "backslashreplace")
v = v.encode(scu.SCO_ENCODING, "backslashreplace")
elif convert_to_string:
v = convert_to_string(v)
M[row_idx][col_idx] = v
@ -485,7 +492,7 @@ def Excel_feuille_listeappel(
formsemestre_id = sem["formsemestre_id"]
SheetName = "Liste " + groupname
wb = Workbook()
ws0 = wb.add_sheet(SheetName.decode(SCO_ENCODING))
ws0 = wb.add_sheet(SheetName.decode(scu.SCO_ENCODING))
font1 = Font()
font1.name = "Arial"
@ -569,7 +576,7 @@ def Excel_feuille_listeappel(
sem["date_debut"],
sem["date_fin"],
)
).decode(SCO_ENCODING),
).decode(scu.SCO_ENCODING),
style2,
)
# ligne 2
@ -578,7 +585,7 @@ def Excel_feuille_listeappel(
# ligne 3
li += 1
ws0.write(li, 1, u"Enseignant :", style2)
ws0.write(li, 5, ("Groupe %s" % groupname).decode(SCO_ENCODING), style3)
ws0.write(li, 5, ("Groupe %s" % groupname).decode(scu.SCO_ENCODING), style3)
# Avertissement pour ne pas confondre avec listes notes
ws0.write(
li + 1, 2, u"Ne pas utiliser cette feuille pour saisir les notes !", style1i
@ -590,7 +597,9 @@ def Excel_feuille_listeappel(
co = 2
for partition in partitions:
if partition["partition_name"]:
ws0.write(li, co, partition["partition_name"].decode(SCO_ENCODING), style3)
ws0.write(
li, co, partition["partition_name"].decode(scu.SCO_ENCODING), style3
)
co += 1
if with_codes:
coc = co
@ -607,7 +616,11 @@ def Excel_feuille_listeappel(
li += 1
ws0.write(li, 0, n, style1b)
nomprenom = (
t["sexe"] + " " + t["nom"] + " " + strcapitalize(strlower(t["prenom"]))
t["sexe"]
+ " "
+ t["nom"]
+ " "
+ scu.strcapitalize(scu.strlower(t["prenom"]))
)
style_nom = style2t3
if with_paiement:
@ -618,31 +631,31 @@ def Excel_feuille_listeappel(
elif not paie:
nomprenom += " (non paiement)"
style_nom = style2t3bold
ws0.write(li, 1, nomprenom.decode(SCO_ENCODING), style_nom)
ws0.write(li, 1, nomprenom.decode(scu.SCO_ENCODING), style_nom)
co = 2
for partition in partitions:
if partition["partition_name"]:
ws0.write(
li,
co,
t.get(partition["partition_id"], "").decode(SCO_ENCODING),
t.get(partition["partition_id"], "").decode(scu.SCO_ENCODING),
style2t3,
)
co += 1
if with_codes:
ws0.write(li, coc, t["etudid"].decode(SCO_ENCODING), style2t3)
ws0.write(li, coc, t["etudid"].decode(scu.SCO_ENCODING), style2t3)
if t["code_nip"]:
code_nip = t["code_nip"].decode(SCO_ENCODING)
code_nip = t["code_nip"].decode(scu.SCO_ENCODING)
else:
code_nip = u""
ws0.write(li, coc + 1, code_nip, style2t3)
if t["code_ine"]:
code_ine = t["code_ine"].decode(SCO_ENCODING)
code_ine = t["code_ine"].decode(scu.SCO_ENCODING)
else:
code_ine = u""
ws0.write(li, coc + 2, code_ine, style2t3)
if t["etath"]:
etath = t["etath"].decode(SCO_ENCODING)
etath = t["etath"].decode(scu.SCO_ENCODING)
else:
etath = u""
ws0.write(li, co, etath, style2b) # etat
@ -654,7 +667,7 @@ def Excel_feuille_listeappel(
dt = time.strftime("%d/%m/%Y à %Hh%M")
if server_name:
dt += " sur " + server_name
ws0.write(li, 1, ("Liste éditée le " + dt).decode(SCO_ENCODING), style1i)
ws0.write(li, 1, ("Liste éditée le " + dt).decode(scu.SCO_ENCODING), style1i)
#
ws0.col(0).width = 850
ws0.col(1).width = 9000

View File

@ -29,6 +29,9 @@
"""
from types import ListType
import notesdb as ndb
import sco_utils as scu
from notes_log import log
import scolars
import sco_bac
import sco_formsemestre
@ -36,11 +39,10 @@ import sco_parcours_dut
import sco_codes_parcours
from sco_codes_parcours import NO_SEMESTRE_ID
import sco_excel
import notesdb as ndb
from sco_utils import *
from gen_tables import GenTable
import sco_pvjury
import html_sco_header
import VERSION
def _build_results_table(context, start_date=None, end_date=None, types_parcours=[]):
@ -97,9 +99,9 @@ def _build_results_table(context, start_date=None, end_date=None, types_parcours
rows=rows,
titles=titles,
columns_ids=columns_ids,
filename=make_filename("scodoc-results-%s-%s" % (start_date, end_date)),
filename=scu.make_filename("scodoc-results-%s-%s" % (start_date, end_date)),
caption="Résultats ScoDoc de %s à %s" % (start_date, end_date),
origin="Généré par %s le " % VERSION.SCONAME + timedate_human_repr() + "",
origin="Généré par %s le " % VERSION.SCONAME + scu.timedate_human_repr() + "",
html_class="table_leftalign",
html_sortable=True,
preferences=context.get_preferences(),
@ -190,7 +192,7 @@ def _build_results_list(context, dpv_by_sem, etuds_infos):
code = "-"
r[sem["semestre_id"]] = code
r["periode"] = sem["periode"]
r["anneescolaire"] = annee_scolaire_debut(
r["anneescolaire"] = scu.annee_scolaire_debut(
int(sem["annee_debut"]), sem["mois_debut_ord"]
)
r["sid"] = "{} {} {}".format(
@ -238,7 +240,7 @@ def scodoc_table_results(
REQUEST.URL0,
start_date,
end_date,
"&amp;types_parcours=".join([str(x) for s in types_parcours]),
"&amp;types_parcours=".join([str(x) for x in types_parcours]),
)
if format != "html":
return tab.make_page(

View File

@ -30,7 +30,7 @@
from types import ListType
import xml.dom.minidom
from sco_utils import *
import sco_utils as scu
import notesdb as ndb
from notes_log import log
@ -130,7 +130,7 @@ def search_etud_in_dept(
if title:
H.append("<h2>%s</h2>" % title)
if is_valid_code_nip(expnom):
if scu.is_valid_code_nip(expnom):
etuds = search_etuds_infos(context, code_nip=expnom, REQUEST=REQUEST)
elif expnom:
etuds = search_etuds_infos(context, expnom=expnom, REQUEST=REQUEST)
@ -220,10 +220,10 @@ def search_etuds_infos(context, expnom=None, code_nip=None, REQUEST=None):
"""recherche les étudiants correspondants à expnom ou au code_nip
et ramene liste de mappings utilisables en DTML.
"""
may_be_nip = is_valid_code_nip(expnom)
may_be_nip = scu.is_valid_code_nip(expnom)
cnx = context.GetDBConnexion()
if expnom and not may_be_nip:
expnom = strupper(expnom) # les noms dans la BD sont en uppercase
expnom = scu.strupper(expnom) # les noms dans la BD sont en uppercase
etuds = scolars.etudident_list(cnx, args={"nom": expnom}, test="~")
else:
code_nip = code_nip or expnom
@ -240,13 +240,12 @@ def search_etud_by_name(context, term, REQUEST=None):
Accepte aussi un début de code NIP (au moins 6 caractères)
Renvoie une liste de nom en JSON
"""
cnx = context.GetDBConnexion()
may_be_nip = is_valid_code_nip(term)
# term = strupper(term) # conserve les accents
may_be_nip = scu.is_valid_code_nip(term)
# term = scu.strupper(term) # conserve les accents
term = term.upper()
if (
not ALPHANUM_EXP.match(
term.decode(SCO_ENCODING)
not scu.ALPHANUM_EXP.match(
term.decode(scu.SCO_ENCODING)
) # n'autorise pas les caractères spéciaux
and not may_be_nip
):
@ -281,7 +280,7 @@ def search_etud_by_name(context, term, REQUEST=None):
for x in r
]
# log(data)
return sendJSON(REQUEST, data)
return scu.sendJSON(REQUEST, data)
# ---------- Recherche sur plusieurs département
@ -387,7 +386,7 @@ def search_inscr_etud_by_nip(context, code_nip, REQUEST=None, format="json"):
Renvoie une liste des inscriptions de l'étudiants dans tout ScoDoc:
code_nip, nom, prenom, sexe, dept, formsemestre_id, date_debut_sem, date_fin_sem
"""
result, depts = search_etud_in_accessible_depts(
result, _ = search_etud_in_accessible_depts(
context, code_nip=code_nip, REQUEST=REQUEST
)

View File

@ -30,7 +30,7 @@
from operator import itemgetter
import xml.dom.minidom
from sco_utils import *
import sco_utils as scu
import notesdb as ndb
from notes_log import log
@ -40,6 +40,7 @@ import sco_tag_module
from gen_tables import GenTable
from sco_exceptions import ScoValueError
from sco_permissions import ScoChangeFormation
import VERSION
def formation_export(
@ -83,7 +84,7 @@ def formation_export(
if mod["ects"] is None:
del mod["ects"]
return sendResult(
return scu.sendResult(
REQUEST, F, name="formation", format=format, force_outer_xml_tag=False
)
@ -115,7 +116,7 @@ def XMLToDicts(element, encoding):
def formation_import_xml(
context, REQUEST, doc, import_tags=True, encoding=SCO_ENCODING
context, REQUEST, doc, import_tags=True, encoding=scu.SCO_ENCODING
):
"""Create a formation from XML representation
(format dumped by formation_export( format='xml' ))
@ -206,13 +207,13 @@ def formation_list_table(context, formation_id=None, args={}, REQUEST=None):
"""
formations = context.formation_list(formation_id=formation_id, args=args)
title = "Programmes pédagogiques"
lockicon = icontag(
lockicon = scu.icontag(
"lock32_img", title="Comporte des semestres verrouillés", border="0"
)
suppricon = icontag(
suppricon = scu.icontag(
"delete_small_img", border="0", alt="supprimer", title="Supprimer"
)
editicon = icontag(
editicon = scu.icontag(
"edit_img", border="0", alt="modifier", title="Modifier titres et code"
)
@ -304,7 +305,7 @@ def formation_list_table(context, formation_id=None, args={}, REQUEST=None):
columns_ids=columns_ids,
rows=formations,
titles=titles,
origin="Généré par %s le " % VERSION.SCONAME + timedate_human_repr() + "",
origin="Généré par %s le " % VERSION.SCONAME + scu.timedate_human_repr() + "",
caption=title,
html_caption=title,
table_id="formation_list_table",

View File

@ -27,8 +27,9 @@
"""Operations de base sur les formsemestres
"""
import time
from sco_utils import *
import sco_utils as scu
import notesdb as ndb
from notes_log import log
from gen_tables import GenTable
@ -163,7 +164,9 @@ def formsemestre_enrich(context, sem):
sem["annee"] = annee_debut
# 2007 ou 2007-2008:
sem["anneescolaire"] = annee_scolaire_repr(int(annee_debut), sem["mois_debut_ord"])
sem["anneescolaire"] = scu.annee_scolaire_repr(
int(annee_debut), sem["mois_debut_ord"]
)
# La période: considère comme "S1" (ou S3) les débuts en aout-sept-octobre
# devrait sans doute pouvoir etre changé...
if sem["mois_debut_ord"] >= 8 and sem["mois_debut_ord"] <= 10:
@ -429,7 +432,7 @@ def sem_in_semestre_scolaire(context, sem, year=False, saison=0, REQUEST=None):
)
"""
if not year:
year = AnneeScolaire(REQUEST)
year = scu.AnneeScolaire(REQUEST)
# est-on dans la même année universitaire ?
if sem["mois_debut_ord"] > 7:
if sem["annee_debut"] != str(year):
@ -453,7 +456,7 @@ def sem_in_annee_scolaire(context, sem, year=False, REQUEST=None):
Si annee non specifiée, année scolaire courante
"""
if not year:
year = AnneeScolaire(REQUEST)
year = scu.AnneeScolaire(REQUEST)
return ((sem["annee_debut"] == str(year)) and (sem["mois_debut_ord"] > 7)) or (
(sem["annee_debut"] == str(year + 1)) and (sem["mois_debut_ord"] <= 7)
)
@ -595,7 +598,7 @@ def view_formsemestre_by_etape(context, etape_apo=None, format="html", REQUEST=N
tab = table_formsemestres(
context,
list_formsemestre_by_etape(
context, etape_apo=etape_apo, annee_scolaire=AnneeScolaire(REQUEST)
context, etape_apo=etape_apo, annee_scolaire=scu.AnneeScolaire(REQUEST)
),
html_title=html_title,
html_next_section="""<form action="view_formsemestre_by_etape">

View File

@ -29,7 +29,7 @@
"""
from sco_utils import *
import sco_utils as scu
import notesdb as ndb
from notes_log import log
from TrivialFormulator import TrivialFormulator, TF

View File

@ -29,7 +29,7 @@
"""
import notesdb as ndb
from sco_utils import *
import sco_utils as scu
import sco_groups
from notes_log import log
from TrivialFormulator import TrivialFormulator, TF
@ -88,7 +88,7 @@ def formsemestre_editwithmodules(context, REQUEST, formsemestre_id):
if sem["etat"] != "1":
H.append(
"""<p>%s<b>Ce semestre est verrouillé.</b></p>"""
% icontag("lock_img", border="0", title="Semestre verrouillé")
% scu.icontag("lock_img", border="0", title="Semestre verrouillé")
)
else:
H.append(do_formsemestre_createwithmodules(context, REQUEST=REQUEST, edit=1))
@ -346,7 +346,7 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False):
# fallback: code etape libre
mf = mf_manual
for n in range(1, EDIT_NB_ETAPES + 1):
for n in range(1, scu.EDIT_NB_ETAPES + 1):
mf["title"] = "Etape Apogée (%d)" % n
modform.append(("etape_apo" + str(n), mf.copy()))
modform.append(
@ -644,7 +644,7 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False):
if ndb.DateDMYtoISO(tf[2]["date_debut"]) > ndb.DateDMYtoISO(tf[2]["date_fin"]):
msg = '<ul class="tf-msg"><li class="tf-msg">Dates de début et fin incompatibles !</li></ul>'
if context.get_preference("always_require_apo_sem_codes") and not any(
[tf[2]["etape_apo" + str(n)] for n in range(0, EDIT_NB_ETAPES + 1)]
[tf[2]["etape_apo" + str(n)] for n in range(0, scu.EDIT_NB_ETAPES + 1)]
):
msg = '<ul class="tf-msg"><li class="tf-msg">Code étape Apogée manquant</li></ul>'
@ -695,7 +695,7 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False):
start_i = 0
else:
start_i = 1
for n in range(start_i, EDIT_NB_ETAPES + 1):
for n in range(start_i, scu.EDIT_NB_ETAPES + 1):
tf[2]["etapes"].append(
ApoEtapeVDI(
etape=tf[2]["etape_apo" + str(n)], vdi=tf[2]["vdi_apo" + str(n)]
@ -1666,12 +1666,12 @@ def get_formsemestre_session_id(context, sem, F, parcours):
(modalite or "").replace("FAP", "FA").replace("APP", "FA")
) # exception pour code Apprentissage
if sem["semestre_id"] > 0:
decale = sem_decale_str(sem)
decale = scu.sem_decale_str(sem)
semestre_id = "S%d" % sem["semestre_id"] + decale
else:
semestre_id = F["code_specialite"]
annee_sco = str(annee_scolaire_debut(sem["annee_debut"], sem["mois_debut_ord"]))
annee_sco = str(scu.annee_scolaire_debut(sem["annee_debut"], sem["mois_debut_ord"]))
return sanitize_string(
return scu.sanitize_string(
"-".join((ImputationDept, parcours_type, modalite, semestre_id, annee_sco))
)

View File

@ -30,13 +30,13 @@
import urllib, time, datetime
import notesdb as ndb
from sco_utils import *
import sco_utils as scu
from notes_log import log
from scolog import logdb
from notes_table import *
import notes_table
from TrivialFormulator import TrivialFormulator, tf_error_message
from sco_exceptions import ScoValueError
from sco_abs import getAbsSemEtud
import sco_formsemestre
import sco_formsemestre_edit
import sco_formsemestre_status
@ -486,8 +486,8 @@ def formsemestre_recap_parcours_table(
"""
H = []
linktmpl = '<span onclick="toggle_vis(this);" class="toggle_sem sem_%%s">%s</span>'
minuslink = linktmpl % icontag("minus_img", border="0", alt="-")
pluslink = linktmpl % icontag("plus_img", border="0", alt="+")
minuslink = linktmpl % scu.icontag("minus_img", border="0", alt="-")
pluslink = linktmpl % scu.icontag("plus_img", border="0", alt="+")
if show_details:
sd = " recap_show_details"
plusminus = minuslink
@ -497,7 +497,7 @@ def formsemestre_recap_parcours_table(
H.append('<table class="recap_parcours%s"><tr>' % sd)
H.append(
'<th><span onclick="toggle_all_sems(this);" title="Ouvrir/fermer tous les semestres">%s</span></th><th></th><th>Semestre</th>'
% icontag("plus18_img", width=18, height=18, border=0, title="", alt="+")
% scu.icontag("plus18_img", width=18, height=18, border=0, title="", alt="+")
)
H.append("<th>Etat</th><th>Abs</th>")
# titres des UE
@ -591,7 +591,7 @@ def formsemestre_recap_parcours_table(
else:
default_sem_info = ""
if sem["etat"] != "1": # locked
lockicon = icontag("lock32_img", title="verrouillé", border="0")
lockicon = scu.icontag("lock32_img", title="verrouillé", border="0")
default_sem_info += lockicon
if sem["formation_code"] != Se.formation["formation_code"]:
default_sem_info += "Autre formation: %s" % sem["formation_code"]
@ -601,8 +601,7 @@ def formsemestre_recap_parcours_table(
)
# Moy Gen (sous le code decision)
H.append(
'<td class="rcp_moy">%s</td>'
% notes_table.fmt_note(nt.get_etud_moy_gen(etudid))
'<td class="rcp_moy">%s</td>' % scu.fmt_note(nt.get_etud_moy_gen(etudid))
)
# Absences (nb d'abs non just. dans ce semestre)
AbsEtudSem = getAbsSemEtud(context, sem, etudid)
@ -642,7 +641,7 @@ def formsemestre_recap_parcours_table(
H.append(
'<td class="%s" title="%s">%s</td>'
% (class_ue, " ".join(explanation_ue), notes_table.fmt_note(moy_ue))
% (class_ue, " ".join(explanation_ue), scu.fmt_note(moy_ue))
)
if len(ues) < Se.nb_max_ue:
H.append('<td colspan="%d"></td>' % (Se.nb_max_ue - len(ues)))

View File

@ -32,7 +32,7 @@ import operator
import traceback
from types import FloatType, IntType, LongType, StringType
from sco_utils import *
import sco_utils as scu
from notes_log import log

View File

@ -33,7 +33,7 @@ Optimisation possible:
et éviter ainsi l'appel ulterieur à get_etud_groups() dans _make_table_notes
"""
import time
import collections
import re
import sets
@ -43,7 +43,7 @@ import operator
import jaxml
import xml.dom.minidom
from sco_utils import *
import sco_utils as scu
import notesdb as ndb
from notes_log import log
from scolog import logdb
@ -75,7 +75,8 @@ def checkGroupName(
): # XXX unused: now allow any string as a group or partition name
"Raises exception if not a valid group name"
if groupName and (
not re.match(r"^\w+$", groupName) or (simplesqlquote(groupName) != groupName)
not re.match(r"^\w+$", groupName)
or (scu.simplesqlquote(groupName) != groupName)
):
log("!!! invalid group name: " + groupName)
raise ValueError("invalid group name: " + groupName)
@ -247,7 +248,7 @@ def get_group_members(context, group_id, etat=None):
r.sort(key=operator.itemgetter("nom_disp", "prenom")) # tri selon nom_usuel ou nom
if CONFIG.ALLOW_NULL_PRENOM:
if scu.CONFIG.ALLOW_NULL_PRENOM:
for x in r:
x["prenom"] = x["prenom"] or ""
@ -433,7 +434,7 @@ def formsemestre_partition_list(context, formsemestre_id, format="xml", REQUEST=
# Ajoute les groupes
for p in partitions:
p["group"] = get_partition_groups(context, p)
return sendResult(REQUEST, partitions, name="partition", format=format)
return scu.sendResult(REQUEST, partitions, name="partition", format=format)
def XMLgetGroupsInPartition(context, partition_id, REQUEST=None): # was XMLgetGroupesTD
@ -454,8 +455,8 @@ def XMLgetGroupsInPartition(context, partition_id, REQUEST=None): # was XMLgetG
) # > inscrdict
etuds_set = set(nt.inscrdict)
# XML response:
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._text('<ajax-response><response type="object" id="MyUpdater">')
doc._push()
@ -687,7 +688,7 @@ def setGroups(
if not group_name:
continue
# ajax arguments are encoded in utf-8:
group_name = unicode(group_name, "utf-8").encode(SCO_ENCODING)
group_name = unicode(group_name, "utf-8").encode(scu.SCO_ENCODING)
group_id = createGroup(context, partition_id, group_name, REQUEST=REQUEST)
# Place dans ce groupe les etudiants indiqués:
for etudid in fs[1:-1]:
@ -695,7 +696,7 @@ def setGroups(
context, etudid, group_id, partition, REQUEST=REQUEST
)
REQUEST.RESPONSE.setHeader("content-type", XML_MIMETYPE)
REQUEST.RESPONSE.setHeader("content-type", scu.XML_MIMETYPE)
return (
'<?xml version="1.0" encoding="utf-8"?><response>Groupes enregistrés</response>'
)
@ -797,9 +798,9 @@ def partition_create(
def getArrowIconsTags(context, REQUEST):
"""returns html tags for arrows"""
#
arrow_up = icontag("arrow_up", title="remonter")
arrow_down = icontag("arrow_down", title="descendre")
arrow_none = icontag("arrow_none", title="")
arrow_up = scu.icontag("arrow_up", title="remonter")
arrow_down = scu.icontag("arrow_down", title="descendre")
arrow_none = scu.icontag("arrow_none", title="")
return arrow_up, arrow_down, arrow_none
@ -811,7 +812,7 @@ def editPartitionForm(context, formsemestre_id=None, REQUEST=None):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
partitions = get_partitions_list(context, formsemestre_id)
arrow_up, arrow_down, arrow_none = getArrowIconsTags(context, REQUEST)
suppricon = icontag(
suppricon = scu.icontag(
"delete_small_img", border="0", alt="supprimer", title="Supprimer"
)
#

View File

@ -30,7 +30,7 @@
import re
from sco_utils import *
import sco_utils as scu
import notesdb as ndb
from notes_log import log
import sco_formsemestre

View File

@ -36,7 +36,7 @@ from email.Header import Header # pylint: disable=no-name-in-module,import-erro
from email import Encoders # pylint: disable=no-name-in-module,import-error
import notesdb as ndb
from sco_utils import *
import sco_utils as scu
from notes_log import log
from TrivialFormulator import TrivialFormulator, TF
import sco_news
@ -74,11 +74,11 @@ def import_excel_file(datafile, REQUEST=None, context=None):
exceldata = datafile.read()
if not exceldata:
raise ScoValueError("Ficher 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 ScoException("import_excel_file: empty file !")
# 1- --- check title line
fs = [strlower(stripquotes(s)) for s in data[0]]
fs = [scu.strlower(scu.stripquotes(s)) for s in data[0]]
log("excel: fs='%s'\ndata=%s" % (str(fs), str(data)))
# check cols
cols = {}.fromkeys(TITLES)
@ -221,16 +221,16 @@ ScoDoc est un logiciel libre développé à l'Université Paris 13 par Emmanuel
Pour plus d'informations sur ce logiciel, voir %s
"""
% SCO_WEBSITE
% scu.SCO_WEBSITE
)
msg = MIMEMultipart()
if reset:
msg["Subject"] = Header("Mot de passe ScoDoc", SCO_ENCODING)
msg["Subject"] = Header("Mot de passe ScoDoc", scu.SCO_ENCODING)
else:
msg["Subject"] = Header("Votre accès ScoDoc", SCO_ENCODING)
msg["Subject"] = Header("Votre accès ScoDoc", scu.SCO_ENCODING)
msg["From"] = context.get_preference("email_from_addr")
msg["To"] = u["email"]
msg.epilogue = ""
txt = MIMEText(txt, "plain", SCO_ENCODING)
txt = MIMEText(txt, "plain", scu.SCO_ENCODING)
msg.attach(txt)
context.sendEmail(msg)

View File

@ -28,12 +28,12 @@
"""Form. pour inscription rapide des etudiants d'un semestre dans un autre
Utilise les autorisations d'inscription délivrées en jury.
"""
from gen_tables import GenTable
import datetime
import notesdb as ndb
from sco_utils import *
import sco_utils as scu
from notes_log import log
from gen_tables import GenTable
import sco_codes_parcours
import sco_pvjury
import sco_formsemestre
@ -226,14 +226,9 @@ def list_source_sems(context, sem, delai=None):
othersems = []
d, m, y = [int(x) for x in sem["date_debut"].split("/")]
date_debut_dst = datetime.date(y, m, d)
d, m, y = [int(x) for x in sem["date_fin"].split("/")]
date_fin_dst = datetime.date(y, m, d)
delais = datetime.timedelta(delai)
for s in sems:
# pdb.set_trace()
# if s['etat'] != '1':
# continue # saute semestres pas ouverts
if s["formsemestre_id"] == sem["formsemestre_id"]:
continue # saute le semestre destination
if s["date_fin"]:
@ -279,9 +274,6 @@ def formsemestre_inscr_passage(
"""
inscrit_groupes = int(inscrit_groupes)
# log('formsemestre_inscr_passage: formsemestre_id=%s submitted=%s, dialog_confirmed=%s len(etuds)=%d'
# % (formsemestre_id, submitted, dialog_confirmed, len(etuds)) )
cnx = context.GetDBConnexion()
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
# -- check lock
if sem["etat"] != "1":
@ -561,7 +553,7 @@ def etuds_select_boxes(
if base_url and etuds:
H.append(
'<a href="%s&amp;export_cat_xls=%s">%s</a>&nbsp;'
% (base_url, src_cat, ICON_XLS)
% (base_url, src_cat, scu.ICON_XLS)
)
H.append("</div>")
for etud in etuds:

View File

@ -28,15 +28,12 @@
"""Liste des notes d'une évaluation
"""
import urllib
from types import StringType
from htmlutils import histogram_notes
import sco_utils as scu
import notesdb as ndb
from sco_utils import *
from notes_log import log
from TrivialFormulator import TrivialFormulator, TF
from notes_table import *
import sco_formsemestre
import sco_moduleimpl
import sco_groups
@ -44,6 +41,8 @@ import sco_evaluations
import htmlutils
import sco_excel
from gen_tables import GenTable
from htmlutils import histogram_notes
import VERSION
def do_evaluation_listenotes(context, REQUEST):
@ -52,7 +51,6 @@ def do_evaluation_listenotes(context, REQUEST):
args: evaluation_id
"""
cnx = context.GetDBConnexion()
mode = None
if REQUEST.form.has_key("evaluation_id"):
evaluation_id = REQUEST.form["evaluation_id"]
@ -69,9 +67,6 @@ def do_evaluation_listenotes(context, REQUEST):
format = REQUEST.form.get("format", "html")
E = evals[0] # il y a au moins une evaluation
M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=E["moduleimpl_id"])[0]
formsemestre_id = M["formsemestre_id"]
# description de l'evaluation
if mode == "eval":
H = [
@ -318,11 +313,11 @@ def _make_table_notes(
"code": code,
"_code_td_attrs": 'style="padding-left: 1em; padding-right: 2em;"',
"etudid": etudid,
"nom": strupper(etud["nom"]),
"nom": scu.strupper(etud["nom"]),
"_nomprenom_target": "formsemestre_bulletinetud?formsemestre_id=%s&amp;etudid=%s"
% (M["formsemestre_id"], etudid),
"_nomprenom_td_attrs": 'id="%s" class="etudinfo"' % (etud["etudid"]),
"prenom": strcapitalize(strlower(etud["prenom"])),
"prenom": scu.strcapitalize(scu.strlower(etud["prenom"])),
"nomprenom": etud["nomprenom"],
"group": grc,
"email": etud["email"],
@ -437,7 +432,7 @@ def _make_table_notes(
if len(evals) == 1:
evalname = "%s-%s" % (Mod["code"], ndb.DateDMYtoISO(E["jour"]))
hh = "%s, %s (%d étudiants)" % (E["description"], gr_title, len(etudids))
filename = make_filename("notes_%s_%s" % (evalname, gr_title_filename))
filename = scu.make_filename("notes_%s_%s" % (evalname, gr_title_filename))
caption = hh
pdf_title = "%(description)s (%(jour)s)" % e
html_title = ""
@ -447,7 +442,7 @@ def _make_table_notes(
% (nb_abs, nb_att)
)
else:
filename = make_filename("notes_%s_%s" % (Mod["code"], gr_title_filename))
filename = scu.make_filename("notes_%s_%s" % (Mod["code"], gr_title_filename))
title = "Notes du module %(code)s %(titre)s" % Mod
title += " semestre %(titremois)s" % sem
if gr_title and gr_title != "tous":
@ -470,7 +465,7 @@ def _make_table_notes(
html_sortable=True,
base_url=base_url,
filename=filename,
origin="Généré par %s le " % VERSION.SCONAME + timedate_human_repr() + "",
origin="Généré par %s le " % VERSION.SCONAME + scu.timedate_human_repr() + "",
caption=caption,
html_next_section=html_next_section,
page_title="Notes de " + sem["titremois"],
@ -552,10 +547,10 @@ def _add_eval_columns(
val = NotesDB[etudid]["value"]
if val is None:
nb_abs += 1
if val == NOTES_ATTENTE:
if val == scu.NOTES_ATTENTE:
nb_att += 1
# calcul moyenne SANS LES ABSENTS
if val != None and val != NOTES_NEUTRALISE and val != NOTES_ATTENTE:
if val != None and val != scu.NOTES_NEUTRALISE and val != scu.NOTES_ATTENTE:
if e["note_max"] > 0:
valsur20 = val * 20.0 / e["note_max"] # remet sur 20
else:
@ -565,7 +560,7 @@ def _add_eval_columns(
val = valsur20 # affichage notes / 20 demandé
nb_notes = nb_notes + 1
sum_notes += val
val_fmt = fmt_note(val, keep_numeric=keep_numeric)
val_fmt = scu.fmt_note(val, keep_numeric=keep_numeric)
comment = NotesDB[etudid]["comment"]
if comment is None:
comment = ""
@ -661,7 +656,7 @@ def _add_moymod_column(
val = nt.get_etud_mod_moy(
e["moduleimpl_id"], etudid
) # note sur 20, ou 'NA','NI'
row[col_id] = fmt_note(val, keep_numeric=keep_numeric)
row[col_id] = scu.fmt_note(val, keep_numeric=keep_numeric)
row["_" + col_id + "_td_attrs"] = ' class="moyenne" '
if type(val) != StringType:
notes.append(val)
@ -715,8 +710,6 @@ def evaluation_check_absences(context, evaluation_id):
if not E["jour"]:
return [], [], [], [], [] # evaluation sans date
M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=E["moduleimpl_id"])[0]
formsemestre_id = M["formsemestre_id"]
etudids = sco_groups.do_evaluation_listeetuds_groups(
context, evaluation_id, getallstudents=True
)
@ -744,17 +737,17 @@ def evaluation_check_absences(context, evaluation_id):
if NotesDB.has_key(etudid):
val = NotesDB[etudid]["value"]
if (
val != None and val != NOTES_NEUTRALISE and val != NOTES_ATTENTE
val != None and val != scu.NOTES_NEUTRALISE and val != scu.NOTES_ATTENTE
) and etudid in As:
# note valide et absent
ValButAbs.append(etudid)
if val is None and not etudid in As:
# absent mais pas signale comme tel
AbsNonSignalee.append(etudid)
if val == NOTES_NEUTRALISE and not etudid in As:
if val == scu.NOTES_NEUTRALISE and not etudid in As:
# Neutralisé mais pas signale absent
ExcNonSignalee.append(etudid)
if val == NOTES_NEUTRALISE and etudid in NJs:
if val == scu.NOTES_NEUTRALISE and etudid in NJs:
# EXC mais pas justifié
ExcNonJust.append(etudid)
if val is None and etudid in Justs:

View File

@ -32,13 +32,14 @@
import tempfile, urllib, re
from sco_utils import *
import sco_utils as scu
from notes_log import log
import scolars
import sco_groups
import sco_report
from gen_tables import GenTable
import sco_formsemestre
import VERSION
def formsemestre_table_etuds_lycees(
@ -99,7 +100,7 @@ def _table_etuds_lycees(
context, etuds, group_lycees, title, preferences, no_links=False
):
etuds = [scolars.etud_add_lycee_infos(e) for e in etuds]
etuds_by_lycee = group_by_key(etuds, "codelycee")
etuds_by_lycee = scu.group_by_key(etuds, "codelycee")
#
if group_lycees:
L = [etuds_by_lycee[codelycee][0] for codelycee in etuds_by_lycee]
@ -156,7 +157,7 @@ def _table_etuds_lycees(
"nomlycee": "Lycée",
"villelycee": "Commune",
},
origin="Généré par %s le " % VERSION.SCONAME + timedate_human_repr() + "",
origin="Généré par %s le " % VERSION.SCONAME + scu.timedate_human_repr() + "",
caption=title,
page_title="Carte lycées d'origine",
html_sortable=True,
@ -176,7 +177,6 @@ def formsemestre_etuds_lycees(
REQUEST=None,
):
"""Table des lycées d'origine"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
tab, etuds_by_lycee = formsemestre_table_etuds_lycees(
context, formsemestre_id, only_primo=only_primo, group_lycees=not no_grouping
)

View File

@ -30,15 +30,15 @@
import notesdb as ndb
from sco_utils import *
import sco_utils as scu
from notes_log import log
from scolog import logdb
from notes_table import *
import sco_formsemestre
import sco_moduleimpl
import sco_groups
import htmlutils
from sco_permissions import ScoEtudInscrit
from sco_exceptions import ScoValueError
def moduleimpl_inscriptions_edit(
@ -454,7 +454,7 @@ def get_etuds_with_capitalized_ue(context, formsemestre_id):
"""For each UE, computes list of students capitalizing the UE.
returns { ue_id : [ { infos } ] }
"""
UECaps = DictDefault(defaultvalue=[])
UECaps = scu.DictDefault(defaultvalue=[])
nt = context._getNotesCache().get_NotesTable(
context, formsemestre_id
) # > get_ues, get_etud_ue_status

View File

@ -31,8 +31,9 @@
"""
from sco_utils import *
import sco_utils as scu
import notesdb as ndb
from notes_log import log
import scolars
import sco_bac
import sco_photos
@ -62,7 +63,7 @@ def _menuScolarite(context, authuser, sem, etudid):
"""
locked = sem["etat"] != "1"
if locked:
lockicon = icontag("lock32_img", title="verrouillé", border="0")
lockicon = scu.icontag("lock32_img", title="verrouillé", border="0")
return lockicon # no menu
if not authuser.has_permission(
ScoEtudInscrit, context
@ -220,7 +221,7 @@ def ficheEtud(context, etudid=None, REQUEST=None):
sem_info = {}
for sem in info["sems"]:
if sem["ins"]["etat"] != "I":
descr, junk = etud_descr_situation_semestre(
descr, _ = etud_descr_situation_semestre(
context.Notes,
etudid,
sem["formsemestre_id"],
@ -288,7 +289,7 @@ def ficheEtud(context, etudid=None, REQUEST=None):
] = '<td class="annodel"><a href="doSuppressAnnotation?etudid=%s&amp;annotation_id=%s">%s</a></td>' % (
etudid,
a["id"],
icontag(
scu.icontag(
"delete_img",
border="0",
alt="suppress",
@ -387,7 +388,7 @@ def ficheEtud(context, etudid=None, REQUEST=None):
else:
info["tit_anno"] = ""
# Inscriptions
if info["sems"]:
if info["sems"]: # XXX rcl unused ? à voir
rcl = (
"""(<a href="%(ScoURL)s/Notes/formsemestre_validation_etud_form?check=1&amp;etudid=%(etudid)s&amp;formsemestre_id=%(last_formsemestre_id)s&amp;desturl=ficheEtud?etudid=%(etudid)s">récapitulatif parcours</a>)"""
% info

View File

@ -44,7 +44,9 @@ import sco_evaluations
import sco_saisie_notes
import sco_excel
from sco_excel import *
from TrivialFormulator import TrivialFormulator
from gen_tables import GenTable
import VERSION
def do_placement_selectetuds(context, REQUEST):
@ -125,7 +127,10 @@ def do_placement_selectetuds(context, REQUEST):
(
"group_ids",
{
"default": [g["group_id"] for g in groups],
"default": [
g["group_id"] # pylint: disable=invalid-sequence-index
for g in groups
],
"input_type": "hidden",
"type": "list",
},
@ -297,8 +302,8 @@ def do_placement(context, REQUEST):
{"etudid": etudid, "formsemestre_id": M["formsemestre_id"]}
)[0]
if inscr["etat"] != "D":
nom = strupper(ident["nom"])
prenom = strcapitalize(strlower(ident["prenom"]))
nom = scu.strupper(ident["nom"])
prenom = scu.strcapitalize(scu.strlower(ident["prenom"]))
listetud.append((nom, prenom))
random.shuffle(listetud)
@ -374,7 +379,9 @@ def do_placement(context, REQUEST):
columns_ids=columns_ids,
rows=rows,
filename=filename,
origin="Généré par %s le " % VERSION.SCONAME + timedate_human_repr() + "",
origin="Généré par %s le " % VERSION.SCONAME
+ scu.timedate_human_repr()
+ "",
pdf_title=pdf_title,
# pdf_shorttitle = '',
preferences=context.get_preferences(M["formsemestre_id"]),
@ -444,7 +451,7 @@ def Excel_feuille_placement(
wb = Workbook()
SheetName0 = "Emargement"
ws0 = wb.add_sheet(SheetName0.decode(SCO_ENCODING))
ws0 = wb.add_sheet(SheetName0.decode(scu.SCO_ENCODING))
# ajuste largeurs colonnes (unite inconnue, empirique)
width = 4500
if nbcolumns > 5:
@ -455,7 +462,7 @@ def Excel_feuille_placement(
ws0.col(0).width = 750
SheetName1 = "Positions"
ws1 = wb.add_sheet(SheetName1.decode(SCO_ENCODING))
ws1 = wb.add_sheet(SheetName1.decode(scu.SCO_ENCODING))
if numbering == "coordinate":
ws1.col(0).width = 4000
ws1.col(1).width = 4500
@ -654,8 +661,8 @@ def Excel_feuille_placement(
else:
li += 1
line += 1
ws0.write(li, 0, desceval[0].decode(SCO_ENCODING), style_titres)
ws1.write(li, 0, desceval[0].decode(SCO_ENCODING), style_titres)
ws0.write(li, 0, desceval[0].decode(scu.SCO_ENCODING), style_titres)
ws1.write(li, 0, desceval[0].decode(scu.SCO_ENCODING), style_titres)
li += 1
ws0.write(
li,
@ -727,8 +734,8 @@ def Excel_feuille_placement(
ws0.write(li0, 0, line, style2b)
col = 1
for etudid in linetud:
ws0.write(li0, col, (etudid[0]).decode(SCO_ENCODING), style1t)
ws0.write(li0 + 1, col, (etudid[1]).decode(SCO_ENCODING), style1m)
ws0.write(li0, col, (etudid[0]).decode(scu.SCO_ENCODING), style1t)
ws0.write(li0 + 1, col, (etudid[1]).decode(scu.SCO_ENCODING), style1m)
ws0.row(li0 + 2).height = space
if numbering == "coordinate":
ws0.write(li0 + 2, col, " ", style1bb)
@ -757,8 +764,8 @@ def Excel_feuille_placement(
for etudid in orderetud:
li1 += 1
line += 1
ws1.write(li1, col, (etudid[0]).decode(SCO_ENCODING), style2l)
ws1.write(li1, col + 1, (etudid[1]).decode(SCO_ENCODING), style2m1)
ws1.write(li1, col, (etudid[0]).decode(scu.SCO_ENCODING), style2l)
ws1.write(li1, col + 1, (etudid[1]).decode(scu.SCO_ENCODING), style2m1)
if numbering == "coordinate":
ws1.write(li1, col + 2, etudid[2], style2m2)
ws1.write(li1, col + 3, etudid[3], style2r)

View File

@ -31,13 +31,14 @@ Recapitule tous les semestres validés dans une feuille excel.
"""
import collections
from sco_utils import *
import sco_utils as scu
from notes_log import log
from gen_tables import GenTable
import sco_formsemestre
import sco_groups
import sco_abs
from sco_codes_parcours import code_semestre_validant, code_semestre_attente
import VERSION
def etud_get_poursuite_info(context, sem, etud):
@ -62,7 +63,7 @@ def etud_get_poursuite_info(context, sem, etud):
moy_ues = [
(
ue["acronyme"],
fmt_note(nt.get_etud_ue_status(etudid, ue["ue_id"])["moy"]),
scu.fmt_note(nt.get_etud_ue_status(etudid, ue["ue_id"])["moy"]),
)
for ue in ues
]
@ -79,7 +80,7 @@ def etud_get_poursuite_info(context, sem, etud):
for modimpl in modimpls: # dans chaque UE les modules
if modimpl["module"]["ue_id"] == ue["ue_id"]:
codeModule = modimpl["module"]["code"]
noteModule = fmt_note(
noteModule = scu.fmt_note(
nt.get_etud_mod_moy(modimpl["moduleimpl_id"], etudid)
)
if noteModule != "NI": # si étudiant inscrit au module
@ -103,8 +104,8 @@ def etud_get_poursuite_info(context, sem, etud):
and nt.get_etud_etat(etudid) == "I"
):
d = [
("moy", fmt_note(nt.get_etud_moy_gen(etudid))),
("moy_promo", fmt_note(nt.moy_moy)),
("moy", scu.fmt_note(nt.get_etud_moy_gen(etudid))),
("moy_promo", scu.fmt_note(nt.moy_moy)),
("rang", nt.get_etud_rang(etudid)),
("effectif", len(nt.T)),
("date_debut", s["date_debut"]),
@ -154,7 +155,6 @@ def formsemestre_poursuite_report(
):
"""Table avec informations "poursuite" """
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
nt = context._getNotesCache().get_NotesTable(context, formsemestre_id)
etuds = context.getEtudInfoGroupes(
[sco_groups.get_default_group(context, formsemestre_id)]
)
@ -191,9 +191,9 @@ def formsemestre_poursuite_report(
pdf_link=False, # pas d'export pdf
preferences=context.get_preferences(formsemestre_id),
)
tab.filename = make_filename("poursuite " + sem["titreannee"])
tab.filename = scu.make_filename("poursuite " + sem["titreannee"])
tab.origin = "Généré par %s le " % VERSION.SCONAME + timedate_human_repr() + ""
tab.origin = "Généré par %s le " % VERSION.SCONAME + scu.timedate_human_repr() + ""
tab.caption = "Récapitulatif %s." % sem["titreannee"]
tab.html_caption = "Récapitulatif %s." % sem["titreannee"]
tab.base_url = "%s?formsemestre_id=%s" % (REQUEST.URL0, formsemestre_id)

View File

@ -28,8 +28,9 @@
"""ScoDoc preferences (replaces old Zope properties)
"""
from sco_utils import *
import sco_utils as scu
import notesdb as ndb
from notes_log import log
from TrivialFormulator import TrivialFormulator, TF
import sco_formsemestre
import sco_bulletins_generator
@ -1749,7 +1750,7 @@ class sco_base_preferences:
"""Load all preferences from db"""
log("loading preferences")
try:
GSL.acquire()
scu.GSL.acquire()
cnx = self.context.GetDBConnexion()
preflist = self._editor.list(cnx)
self.prefs = {None: {}} # { formsemestre_id (or None) : { name : value } }
@ -1796,9 +1797,9 @@ class sco_base_preferences:
% (name, value)
)
except:
# search in CONFIG
if hasattr(CONFIG, name):
value = getattr(CONFIG, name)
# search in scu.CONFIG
if hasattr(scu.CONFIG, name):
value = getattr(scu.CONFIG, name)
log(
"sco_preferences: found default value in config for %s=%s"
% (name, value)
@ -1813,7 +1814,7 @@ class sco_base_preferences:
# add to db table
self._editor.create(cnx, {"name": name, "value": value})
finally:
GSL.release()
scu.GSL.release()
def get(self, formsemestre_id, name):
"""Returns preference value.
@ -1845,7 +1846,7 @@ class sco_base_preferences:
def save(self, formsemestre_id=None, name=None):
"""Write one or all (if name is None) values to db"""
try:
GSL.acquire()
scu.GSL.acquire()
modif = False
cnx = self.context.GetDBConnexion()
if name is None:
@ -1892,7 +1893,7 @@ class sco_base_preferences:
if modif:
self.context.Notes._inval_cache(pdfonly=False) # > modif preferences
finally:
GSL.release()
scu.GSL.release()
def set(self, formsemestre_id, name, value):
if not name or name[0] == "_" or name not in PREFS_NAMES:
@ -1908,7 +1909,7 @@ class sco_base_preferences:
if not formsemestre_id:
raise ScoException()
try:
GSL.acquire()
scu.GSL.acquire()
if formsemestre_id in self.prefs and name in self.prefs[formsemestre_id]:
del self.prefs[formsemestre_id][name]
cnx = self.context.GetDBConnexion()
@ -1920,7 +1921,7 @@ class sco_base_preferences:
self._editor.delete(cnx, pdb[0]["pref_id"])
self.context.Notes._inval_cache(pdfonly=False) # > modif preferences
finally:
GSL.release()
scu.GSL.release()
def edit(self, REQUEST):
"""HTML dialog: edit global preferences"""

View File

@ -27,8 +27,9 @@
"""Feuille excel pour preparation des jurys
"""
import time
from sco_utils import *
import sco_utils as scu
from notes_log import log
import notes_table
import sco_groups
@ -38,6 +39,7 @@ import sco_parcours_dut
import sco_codes_parcours
from scolars import format_nom, format_prenom, format_sexe, format_lycee
from sco_abs import getAbsSemEtud
import VERSION
def feuille_preparation_jury(context, formsemestre_id, REQUEST):
@ -53,10 +55,10 @@ def feuille_preparation_jury(context, formsemestre_id, REQUEST):
context, formsemestre_id
)["partition_id"]
prev_moy_ue = DictDefault(defaultvalue={}) # ue_code_s : { etudid : moy ue }
prev_moy_ue = scu.DictDefault(defaultvalue={}) # ue_code_s : { etudid : moy ue }
prev_ue_acro = {} # ue_code_s : acronyme (à afficher)
prev_moy = {} # moyennes gen sem prec
moy_ue = DictDefault(defaultvalue={}) # ue_acro : moyennes { etudid : moy ue }
moy_ue = scu.DictDefault(defaultvalue={}) # ue_acro : moyennes { etudid : moy ue }
ue_acro = {} # ue_code_s : acronyme (à afficher)
moy = {} # moyennes gen
moy_inter = {} # moyenne gen. sur les 2 derniers semestres
@ -155,7 +157,7 @@ def feuille_preparation_jury(context, formsemestre_id, REQUEST):
sp = "S%s" % (sid - 1)
L = sco_excel.ScoExcelSheet(sheet_name="Prepa Jury %s" % sn)
L.append(["Feuille préparation Jury %s" % unescape_html(sem["titreannee"])])
L.append(["Feuille préparation Jury %s" % scu.unescape_html(sem["titreannee"])])
L.append([]) # empty line
titles = ["Rang"]
@ -211,7 +213,7 @@ def feuille_preparation_jury(context, formsemestre_id, REQUEST):
def fmt(x):
"reduit les notes a deux chiffres"
x = notes_table.fmt_note(x, keep_numeric=False)
x = scu.fmt_note(x, keep_numeric=False)
try:
return float(x)
except:

View File

@ -28,6 +28,9 @@
"""Edition des PV de jury
"""
import sco_utils as scu
import notesdb as ndb
import scolars
import sco_formsemestre
import sco_groups
@ -36,8 +39,7 @@ import sco_parcours_dut
import sco_codes_parcours
from sco_codes_parcours import NO_SEMESTRE_ID
import sco_excel
import notesdb as ndb
from sco_utils import *
from TrivialFormulator import TrivialFormulator
from gen_tables import GenTable
import sco_pvpdf
from sco_pdf import *
@ -135,7 +137,7 @@ def _comp_ects_by_ue_code_and_type(nt, decision_ues):
return {}, {}
ects_by_ue_code = {}
ects_by_ue_type = DictDefault(defaultvalue=0) # { ue_type : ects validés }
ects_by_ue_type = scu.DictDefault(defaultvalue=0) # { ue_type : ects validés }
for ue_id in decision_ues:
d = decision_ues[ue_id]
ue = nt.uedict[ue_id]
@ -245,7 +247,7 @@ def dict_pvjury(
if d["decision_sem"] and sco_codes_parcours.code_semestre_validant(
d["decision_sem"]["code"]
):
d["mention"] = get_mention(nt.get_etud_moy_gen(etudid))
d["mention"] = scu.get_mention(nt.get_etud_moy_gen(etudid))
else:
d["mention"] = ""
# Versions "en français": (avec les UE capitalisées d'ailleurs)
@ -513,8 +515,8 @@ def formsemestre_pvjury(
rows=rows,
titles=titles,
columns_ids=columns_ids,
filename=make_filename("decisions " + sem["titreannee"]),
origin="Généré par %s le " % VERSION.SCONAME + timedate_human_repr() + "",
filename=scu.make_filename("decisions " + sem["titreannee"]),
origin="Généré par %s le " % VERSION.SCONAME + scu.timedate_human_repr() + "",
caption="Décisions jury pour " + sem["titreannee"],
html_class="table_leftalign",
html_sortable=True,
@ -552,7 +554,7 @@ def formsemestre_pvjury(
H.append(tab.html())
# Count number of cases for each decision
counts = DictDefault()
counts = scu.DictDefault()
for row in rows:
counts[row["decision"]] += 1
# add codes for previous (for explanation, without count)
@ -705,7 +707,7 @@ def formsemestre_pvjury_pdf(
else:
groups_filename = ""
filename = "PV-%s%s-%s.pdf" % (sem["titre_num"], groups_filename, dt)
return sendPDFFile(REQUEST, pdfdoc, filename)
return scu.sendPDFFile(REQUEST, pdfdoc, filename)
def descrform_pvjury(context, sem):
@ -872,7 +874,7 @@ def formsemestre_lettres_individuelles(
dt = time.strftime("%Y-%m-%d")
groups_filename = "-" + groups_infos.groups_filename
filename = "lettres-%s%s-%s.pdf" % (sem["titre_num"], groups_filename, dt)
return sendPDFFile(REQUEST, pdfdoc, filename)
return scu.sendPDFFile(REQUEST, pdfdoc, filename)
def descrform_lettres_individuelles():

View File

@ -27,18 +27,18 @@
"""Edition des PV de jury
"""
import os
import types
import sco_formsemestre
from sco_pdf import *
import sco_utils as scu
import sco_formsemestre
import sco_pvjury
import sco_codes_parcours
from sco_utils import *
from sco_pdf import PDFLOCK
import sco_preferences
import sco_bulletins_pdf
import os
import types
LOGO_FOOTER_ASPECT = CONFIG.LOGO_FOOTER_ASPECT # XXX A AUTOMATISER
LOGO_FOOTER_HEIGHT = CONFIG.LOGO_FOOTER_HEIGHT * mm
@ -354,7 +354,7 @@ def pdf_lettres_individuelles(
if e["decision_sem"]: # decision prise
etud = context.getEtudInfo(e["identite"]["etudid"], filled=True)[0]
params["nomEtud"] = etud["nomprenom"]
bookmarks[npages + 1] = suppress_accents(etud["nomprenom"])
bookmarks[npages + 1] = scu.suppress_accents(etud["nomprenom"])
objects += pdf_lettre_individuelle(
dpv["formsemestre"], e, etud, params, signature, context=context
)

View File

@ -27,8 +27,12 @@
"""Tableau recapitulatif des notes d'un semestre
"""
import time
import datetime
import jaxml
from notes_table import *
import sco_utils as scu
from notes_log import log
import sco_bulletins, sco_excel
import sco_groups
import sco_evaluations
@ -37,6 +41,7 @@ import sco_formsemestre_status
import sco_bulletins_xml
import sco_bulletins_json
import sco_codes_parcours
from sco_codes_parcours import DEF, UE_SPORT
import sco_bac
@ -133,7 +138,7 @@ def formsemestre_recapcomplet(
H.append("checked")
H.append(""" >cacher bac</input>""")
if tabformat == "xml":
REQUEST.RESPONSE.setHeader("content-type", XML_MIMETYPE)
REQUEST.RESPONSE.setHeader("content-type", scu.XML_MIMETYPE)
H.append(
do_formsemestre_recapcomplet(
context,
@ -201,11 +206,11 @@ def do_formsemestre_recapcomplet(
if format == "xml" or format == "html":
return data
elif format == "csv":
return sendCSVFile(REQUEST, data, filename)
return scu.sendCSVFile(REQUEST, data, filename)
elif format[:3] == "xls":
return sco_excel.sendExcelFile(REQUEST, data, filename)
elif format == "json":
return sendJSON(REQUEST, data)
return scu.sendJSON(REQUEST, data)
else:
raise ValueError("unknown format %s" % format)
@ -345,7 +350,7 @@ def make_formsemestre_recapcomplet(
return val
# Compte les decisions de jury
codes_nb = DictDefault(defaultvalue=0)
codes_nb = scu.DictDefault(defaultvalue=0)
#
is_dem = {} # etudid : bool
for t in T:
@ -396,7 +401,7 @@ def make_formsemestre_recapcomplet(
else:
l.append(gr_name) # groupe
l.append(fmtnum(fmt_note(t[0], keep_numeric=keep_numeric))) # moy_gen
l.append(fmtnum(scu.fmt_note(t[0], keep_numeric=keep_numeric))) # moy_gen
# Ajoute rangs dans groupes seulement si CSV ou XLS
if format[:3] == "xls" or format == "csv":
rang_gr, ninscrits_gr, gr_name = sco_bulletins.get_etud_rangs_groups(
@ -410,7 +415,7 @@ def make_formsemestre_recapcomplet(
i += 1
if ue["type"] != UE_SPORT:
l.append(
fmtnum(fmt_note(t[i], keep_numeric=keep_numeric))
fmtnum(scu.fmt_note(t[i], keep_numeric=keep_numeric))
) # moyenne etud dans ue
else: # UE_SPORT:
# n'affiche pas la moyenne d'UE dans ce cas
@ -423,7 +428,9 @@ def make_formsemestre_recapcomplet(
if modimpl["module"]["ue_id"] == ue["ue_id"]:
l.append(
fmtnum(
fmt_note(t[j + len(ues) + 1], keep_numeric=keep_numeric)
scu.fmt_note(
t[j + len(ues) + 1], keep_numeric=keep_numeric
)
)
) # moyenne etud dans module
if format == "xlsall":
@ -458,7 +465,7 @@ def make_formsemestre_recapcomplet(
l += [""]
l.append(corner_value)
if format[:3] == "xls" or format == "csv":
for partition in partitions:
for _ in partitions:
l += [""] # rangs dans les groupes
for ue in ues:
if ue["type"] != UE_SPORT:
@ -476,7 +483,7 @@ def make_formsemestre_recapcomplet(
else:
l.append(str(ue[key]))
else:
l.append(fmt_note(ue[key], keep_numeric=keep_numeric))
l.append(scu.fmt_note(ue[key], keep_numeric=keep_numeric))
else: # UE_SPORT:
# n'affiche pas la moyenne d'UE dans ce cas
if not hidemodules:
@ -500,7 +507,7 @@ def make_formsemestre_recapcomplet(
): # garde val numerique pour excel
val = str(val)
else: # moyenne du module
val = fmt_note(val, keep_numeric=keep_numeric)
val = scu.fmt_note(val, keep_numeric=keep_numeric)
l.append(val)
if format == "xlsall":
@ -514,13 +521,15 @@ def make_formsemestre_recapcomplet(
F.append(l + ["", ""]) # ajoute cellules code_nip et etudid inutilisees ici
add_bottom_stat(
"min", "Min", corner_value=fmt_note(nt.moy_min, keep_numeric=keep_numeric)
"min", "Min", corner_value=scu.fmt_note(nt.moy_min, keep_numeric=keep_numeric)
)
add_bottom_stat(
"max", "Max", corner_value=fmt_note(nt.moy_max, keep_numeric=keep_numeric)
"max", "Max", corner_value=scu.fmt_note(nt.moy_max, keep_numeric=keep_numeric)
)
add_bottom_stat(
"moy", "Moyennes", corner_value=fmt_note(nt.moy_moy, keep_numeric=keep_numeric)
"moy",
"Moyennes",
corner_value=scu.fmt_note(nt.moy_moy, keep_numeric=keep_numeric),
)
add_bottom_stat("coef", "Coef")
add_bottom_stat("nb_valid_evals", "Nb évals")
@ -645,7 +654,9 @@ def make_formsemestre_recapcomplet(
idx_col_moy = idx_col_gr + 1
cssclass = "recap_col_moy"
try:
if float(nsn[idx_col_moy]) < (nt.parcours.BARRE_MOY - NOTES_TOLERANCE):
if float(nsn[idx_col_moy]) < (
nt.parcours.BARRE_MOY - scu.NOTES_TOLERANCE
):
cssclass = "recap_col_moy_inf"
except:
pass
@ -734,7 +745,7 @@ def make_formsemestre_recapcomplet(
H.append("</table>")
return "\n".join(H), "", "html"
elif format == "csv":
CSV = CSV_LINESEP.join([CSV_FIELDSEP.join(str(x)) for x in F])
CSV = scu.CSV_LINESEP.join([scu.CSV_FIELDSEP.join(str(x)) for x in F])
semname = sem["titre_num"].replace(" ", "_")
date = time.strftime("%d-%m-%Y")
filename = "notes_modules-%s-%s.csv" % (semname, date)
@ -774,8 +785,8 @@ def _list_notes_evals(context, evals, etudid):
val = NotesDB[etudid]["value"]
else:
# Note manquante mais prise en compte immédiate: affiche ATT
val = NOTES_ATTENTE
val_fmt = fmt_note(val, keep_numeric=True)
val = scu.NOTES_ATTENTE
val_fmt = scu.fmt_note(val, keep_numeric=True)
L.append(val_fmt)
return L
@ -806,7 +817,7 @@ def _list_notes_evals_stats(context, evals, key):
):
if key == "moy":
val = e["etat"]["moy_num"]
L.append(fmt_note(val, keep_numeric=True))
L.append(scu.fmt_note(val, keep_numeric=True))
elif key == "max":
L.append(e["note_max"])
elif key == "min":
@ -834,7 +845,7 @@ def _formsemestre_recapcomplet_xml(
if not T:
return "", "", "xml"
doc = jaxml.XML_document(encoding=SCO_ENCODING)
doc = jaxml.XML_document(encoding=scu.SCO_ENCODING)
if xml_nodate:
docdate = ""
else:
@ -928,4 +939,4 @@ def formsemestres_bulletins(context, annee_scolaire, REQUEST=None):
)
jslist.append(J)
return sendJSON(REQUEST, jslist)
return scu.sendJSON(REQUEST, jslist)

View File

@ -39,7 +39,7 @@ sem_set_list(context)
"""
from sco_utils import *
import sco_utils as scu
import notesdb as ndb
from notes_log import log
import sco_formsemestre
@ -417,7 +417,7 @@ def semset_page(context, format="html", REQUEST=None):
"""
semsets = get_semsets_list(context)
for s in semsets:
s["suppress"] = icontag(
s["suppress"] = scu.icontag(
"delete_small_img", border="0", alt="supprimer", title="Supprimer"
)
s["_suppress_target"] = "do_semset_delete?semset_id=%s" % (s["semset_id"])
@ -479,7 +479,7 @@ def semset_page(context, format="html", REQUEST=None):
]
H.append(tab.html())
annee_courante = int(AnneeScolaire(REQUEST))
annee_courante = int(scu.AnneeScolaire(REQUEST))
menu_annee = "\n".join(
[
'<option value="%s">%s</option>' % (i, i)

View File

@ -36,7 +36,7 @@
import types
from sco_utils import *
import sco_utils as scu
import notesdb as ndb
from notes_log import log
from sco_exceptions import ScoValueError, AccessDenied
@ -200,7 +200,7 @@ class ModuleTag(ScoTag):
def module_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 = ndb.SimpleDictFetch(
@ -210,7 +210,7 @@ def module_tag_search(context, term, REQUEST=None):
)
data = [x["title"] for x in r]
return sendJSON(REQUEST, data)
return scu.sendJSON(REQUEST, data)
def module_tag_list(context, module_id=""):

View File

@ -37,8 +37,9 @@ import xml
import tempfile
from notes_log import log
from sco_utils import *
import sco_utils as scu
from sco_exceptions import ScoValueError
from TrivialFormulator import TrivialFormulator
import scolars
import sco_photos
import sco_formsemestre
@ -50,6 +51,7 @@ from sco_pdf import *
import ImportScolars
import sco_excel
from reportlab.lib import colors
from PIL import Image as PILImage
def trombino(
@ -166,8 +168,7 @@ def check_local_photos_availability(context, groups_infos, REQUEST, format=""):
"""
nb_missing = 0
for t in groups_infos.members:
etudid = t["etudid"]
url = sco_photos.etud_photo_url(
_ = sco_photos.etud_photo_url(
context, t, REQUEST=REQUEST
) # -> copy distant files if needed
if not sco_photos.etud_photo_is_local(context, t):
@ -376,7 +377,7 @@ def _trombino_pdf(context, groups_infos, REQUEST):
document.build(objects)
data = report.getvalue()
return sendPDFFile(REQUEST, data, filename)
return scu.sendPDFFile(REQUEST, data, filename)
# --------------------- Sur une idée de l'IUT d'Orléans:
@ -459,7 +460,7 @@ def _listeappel_photos_pdf(context, groups_infos, REQUEST):
document.build(objects)
data = report.getvalue()
return sendPDFFile(REQUEST, data, filename)
return scu.sendPDFFile(REQUEST, data, filename)
# --------------------- Upload des photos de tout un groupe
@ -593,7 +594,7 @@ def zip_excel_import_files(
fn = fn.replace("\\", "/") # not sure if this is necessary ?
fn = fn.strip()
if lowercase:
fn = strlower(fn)
fn = scu.strlower(fn)
fn = fn.split("/")[-1] # use only last component, not directories
return fn

View File

@ -38,8 +38,8 @@ from zipfile import ZipFile, BadZipfile
import xml
import tempfile
import sco_utils as scu
from notes_log import log
from sco_utils import *
import sco_abs
import scolars
import sco_photos
@ -283,7 +283,7 @@ def pdf_trombino_tours(
document.build(objects)
data = report.getvalue()
return sendPDFFile(REQUEST, data, filename)
return scu.sendPDFFile(REQUEST, data, filename)
# Feuille d'absences en pdf avec photos:
@ -477,4 +477,4 @@ def pdf_feuille_releve_absences(
document.build(objects)
data = report.getvalue()
return sendPDFFile(REQUEST, data, filename)
return scu.sendPDFFile(REQUEST, data, filename)

View File

@ -55,13 +55,14 @@ Solution proposée (nov 2014):
"""
import notesdb as ndb
from sco_utils import *
import sco_utils as scu
from notes_log import log
import sco_formsemestre
import sco_moduleimpl
import sco_edit_ue
import sco_saisie_notes
import sco_codes_parcours
from TrivialFormulator import TrivialFormulator, tf_error_message
from sco_permissions import ScoImplement
from sco_exceptions import AccessDenied, ScoValueError
@ -164,7 +165,7 @@ def external_ue_inscrit_et_note(
description="note externe",
)
# Saisie des notes
nbchanged, nbsuppress, existing_decisions = sco_saisie_notes._notes_add(
_, _, _ = sco_saisie_notes._notes_add(
context,
REQUEST.AUTHENTICATED_USER,
evaluation_id,

View File

@ -35,7 +35,7 @@ Pour une évaluation:
- historique: table notes_notes_log
saisie de notes == saisir ou supprimer une ou plusieurs notes (mêmes date et uid)
/!\ tolérance sur les dates (200ms ?)
! tolérance sur les dates (200ms ?)
Chaque saisie affecte ou remplace une ou plusieurs notes.
Opérations:
@ -48,12 +48,13 @@ Opérations:
import datetime
from intervals import intervalmap
from sco_utils import *
import sco_utils as scu
import notesdb as ndb
from notes_log import log
from gen_tables import GenTable
import sco_formsemestre
import sco_moduleimpl
import VERSION
# deux notes (de même uid) sont considérées comme de la même opération si
# elles sont séparées de moins de 2*tolerance:
@ -121,7 +122,7 @@ def list_operations(context, evaluation_id):
Ops = []
for uid in NotesDates.keys():
for (t0, t1), notes in NotesDates[uid].items():
for (t0, _), notes in NotesDates[uid].items():
Op = NotesOperation(
evaluation_id=evaluation_id,
date=t0,
@ -201,7 +202,7 @@ def formsemestre_list_saisies_notes(
caption="Saisies de notes dans %s" % sem["titreannee"],
preferences=context.get_preferences(formsemestre_id),
base_url="%s?formsemestre_id=%s" % (REQUEST.URL0, formsemestre_id),
origin="Généré par %s le " % VERSION.SCONAME + timedate_human_repr() + "",
origin="Généré par %s le " % VERSION.SCONAME + scu.timedate_human_repr() + "",
)
return tab.make_page(context, format=format, REQUEST=REQUEST)
@ -242,7 +243,7 @@ def get_note_history(context, evaluation_id, etudid, REQUEST=None, fmt=""):
x["user_name"] = context.Users.user_info(x["uid"])["nomcomplet"]
if fmt == "json":
return sendJSON(REQUEST, history)
return scu.sendJSON(REQUEST, history)
else:
return history

View File

@ -29,8 +29,11 @@
""" Verification version logiciel vs version "stable" sur serveur
N'effectue pas la mise à jour automatiquement, mais permet un affichage d'avertissement.
"""
import datetime
import re
from sco_utils import *
import sco_utils as scu
from notes_log import log
# Appel renvoyant la subversion "stable"
# La notion de "stable" est juste là pour éviter d'afficher trop frequemment
@ -46,7 +49,9 @@ def get_last_stable_version():
(do not wait server answer more than 3 seconds)
"""
global _LAST_UP_TO_DATE_REQUEST
ans = query_portal(GET_VER_URL, msg="ScoDoc version server", timeout=3) # sco_utils
ans = scu.query_portal(
GET_VER_URL, msg="ScoDoc version server", timeout=3
) # sco_utils
if ans:
ans = ans.strip()
_LAST_UP_TO_DATE_REQUEST = datetime.datetime.now()
@ -74,7 +79,7 @@ def is_up_to_date(context):
return _UP_TO_DATE, _UP_TO_DATE_MSG
last_stable_ver = get_last_stable_version()
cur_ver = get_svn_version(context.file_path) # in sco_utils
cur_ver = scu.get_svn_version(context.file_path) # in sco_utils
cur_ver2 = cur_ver
cur_ver_num = -1
# Convert versions to integers:

View File

@ -32,7 +32,6 @@ import os
import sys
import copy
import re
import bisect
import types
import numbers
@ -41,6 +40,10 @@ import urllib2
import xml.sax.saxutils
import time
import datetime
import json
# XML generation package (apt-get install jaxml)
import jaxml
try:
import six
@ -52,21 +55,11 @@ except ImportError:
from PIL import Image as PILImage
# XML generation package (apt-get install jaxml)
import jaxml
import json
from VERSION import SCOVERSION
import VERSION
from SuppressAccents import suppression_diacritics
# from sco_exceptions import *
# from sco_permissions import *
from TrivialFormulator import TrivialFormulator, TF, tf_error_message
from notes_log import log, logCallStack
from notes_log import log
from sco_codes_parcours import NOTES_TOLERANCE, CODES_EXPL
# ----- CALCUL ET PRESENTATION DES NOTES