Massive refactoring/reorganization of imports. Work in progress.

This commit is contained in:
Emmanuel Viennet 2021-06-19 23:21:37 +02:00
parent 3e225c9fda
commit 14d329fb0f
122 changed files with 4670 additions and 6487 deletions

View File

@ -1,2 +1,6 @@
[[MESSAGES CONTROL]
# pylint and black disagree...
disable=bad-continuation
[TYPECHECK]
ignored-classes=Permission

View File

@ -56,15 +56,3 @@ Installer le bon vieux `pyExcelerator` dans l'environnement:
### Méthodes qui ne devraient plus être publiées:

View File

@ -48,14 +48,17 @@ class ZRequest(object):
self.REQUEST_METHOD = request.method.encode("utf-8")
self.AUTHENTICATED_USER = current_user
if request.method == "POST":
self.form = request.form
self.form = request.form # xxx encode en utf-8 !
# Encode en utf-8 pour ScoDoc8 #sco8
self.form = {k: v.encode("utf-8") for (k, v) in request.form.items()}
if request.files:
# Add files in form: must copy to get a mutable version
# request.form is a werkzeug.datastructures.ImmutableMultiDict
self.form = self.form.copy()
# self.form = self.form.copy()
self.form.update(request.files)
elif request.method == "GET":
self.form = request.args
# Encode en utf-8 pour ScoDoc8 #sco8
self.form = {k: v.encode("utf-8") for (k, v) in request.args.items()}
self.RESPONSE = ZResponse()
def __str__(self):
@ -158,7 +161,11 @@ def scodoc7func(context):
elif arg_name == "context":
pos_arg_values.append(context)
else:
pos_arg_values.append(req_args[arg_name])
# XXX Convert to regular string for ScoDoc8/Python 2
if type(req_args[arg_name]) == types.UnicodeType:
pos_arg_values.append(req_args[arg_name].encode("utf-8"))
else:
pos_arg_values.append(req_args[arg_name])
current_app.logger.info("pos_arg_values=%s" % pos_arg_values)
# Add keyword arguments
if nb_default_args:
@ -167,7 +174,11 @@ def scodoc7func(context):
kwargs[arg_name] = REQUEST
elif arg_name in req_args:
# set argument kw optionnel
kwargs[arg_name] = req_args[arg_name]
# XXX Convert to regular string for ScoDoc8/Python 2
if type(req_args[arg_name]) == types.UnicodeType:
kwargs[arg_name] = req_args[arg_name].encode("utf-8")
else:
kwargs[arg_name] = req_args[arg_name]
current_app.logger.info(
"scodoc7func_decorator: top_level=%s, pos_arg_values=%s, kwargs=%s"
% (top_level, pos_arg_values, kwargs)

View File

@ -36,12 +36,14 @@ import collections
import types
import re
import sco_utils as scu
import notesdb as ndb
from notes_log import log
from sco_formsemestre_inscriptions import do_formsemestre_inscription_with_modules
from gen_tables import GenTable
from sco_exceptions import (
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from app.scodoc.notes_log import log
from app.scodoc.sco_formsemestre_inscriptions import (
do_formsemestre_inscription_with_modules,
)
from app.scodoc.gen_tables import GenTable
from app.scodoc.sco_exceptions import (
AccessDenied,
FormatError,
ScoException,
@ -50,14 +52,14 @@ from sco_exceptions import (
ScoLockedFormError,
ScoGenError,
)
import html_sco_header
import scolars
import sco_formsemestre
import sco_groups
import sco_excel
import sco_groups_view
import sco_news
import sco_preferences
from app.scodoc import html_sco_header
from app.scodoc import sco_etud
from app.scodoc import sco_formsemestre
from app.scodoc import sco_groups
from app.scodoc import sco_excel
from app.scodoc import sco_groups_view
from app.scodoc import sco_news
from app.scodoc import sco_preferences
# format description (relative to Product directory))
FORMAT_FILE = "misc/format_import_etudiants.txt"
@ -199,7 +201,7 @@ def sco_import_generate_excel_sample(
# rempli table avec données actuelles
lines = []
for i in members:
etud = scolars.get_etud_info(etudid=i["etudid"], filled=True)[0]
etud = sco_etud.get_etud_info(etudid=i["etudid"], filled=True)[0]
l = []
for field in titles:
if field == "groupes":
@ -371,7 +373,7 @@ def scolars_import_excel_file(
# xxx Ad-hoc checks (should be in format description)
if scu.strlower(titleslist[i]) == "sexe":
try:
val = scolars.input_civilite(val)
val = sco_etud.input_civilite(val)
except:
raise ScoValueError(
"valeur invalide pour 'SEXE' (doit etre 'M', 'F', ou 'MME', 'H', 'X' ou vide, mais pas '%s') ligne %d, colonne %s"
@ -405,7 +407,7 @@ def scolars_import_excel_file(
if values["code_ine"] and not is_new_ine:
raise ScoValueError("Code INE dupliqué (%s)" % values["code_ine"])
# Check nom/prenom
ok, NbHomonyms = scolars.check_nom_prenom(
ok, NbHomonyms = sco_etud.check_nom_prenom(
cnx, nom=values["nom"], prenom=values["prenom"]
)
if not ok:
@ -513,16 +515,16 @@ def _import_one_student(
)
# Identite
args = values.copy()
etudid = scolars.identite_create(cnx, args, context=context, REQUEST=REQUEST)
etudid = sco_etud.identite_create(cnx, args, context=context, REQUEST=REQUEST)
created_etudids.append(etudid)
# Admissions
args["etudid"] = etudid
args["annee"] = annee_courante
_ = scolars.admission_create(cnx, args)
_ = sco_etud.admission_create(cnx, args)
# Adresse
args["typeadresse"] = "domicile"
args["description"] = "(infos admission)"
_ = scolars.adresse_create(cnx, args)
_ = sco_etud.adresse_create(cnx, args)
# Inscription au semestre
args["etat"] = "I" # etat insc. semestre
if formsemestre_id:
@ -561,7 +563,7 @@ def _import_one_student(
def _is_new_ine(cnx, code_ine):
"True if this code is not in DB"
etuds = scolars.identite_list(cnx, {"code_ine": code_ine})
etuds = sco_etud.identite_list(cnx, {"code_ine": code_ine})
return not etuds
@ -642,7 +644,7 @@ def scolars_import_admission(
)
else:
etud = etuds_by_nomprenom[(nom, prenom)]
cur_adm = scolars.admission_list(cnx, args={"etudid": etud["etudid"]})[0]
cur_adm = sco_etud.admission_list(cnx, args={"etudid": etud["etudid"]})[0]
# peuple les champs presents dans le tableau
args = {}
for idx in fields:
@ -665,17 +667,17 @@ def scolars_import_admission(
# Type admission: traitement particulier
if not cur_adm["type_admission"] and not args.get("type_admission"):
args["type_admission"] = type_admission
scolars.etudident_edit(cnx, args)
adr = scolars.adresse_list(cnx, args={"etudid": etud["etudid"]})
sco_etud.etudident_edit(cnx, args)
adr = sco_etud.adresse_list(cnx, args={"etudid": etud["etudid"]})
if adr:
args["adresse_id"] = adr[0]["adresse_id"]
scolars.adresse_edit(
sco_etud.adresse_edit(
cnx, args
) # ne passe pas le contexte: pas de notification ici
else:
args["typeadresse"] = "domicile"
args["description"] = "(infos admission)"
adresse_id = scolars.adresse_create(cnx, args)
adresse_id = sco_etud.adresse_create(cnx, args)
# log('import_adm: %s' % args )
# Change les groupes si nécessaire:
if args["groupes"]:

View File

@ -485,7 +485,7 @@ class TF:
lem.append("<table>")
for i in range(len(labels)):
if input_type == "checkbox":
# from notes_log import log # debug only
# from app.scodoc.notes_log import log # debug only
# log('checkbox: values[%s] = "%s"' % (field,repr(values[field]) ))
# log("descr['allowed_values'][%s] = '%s'" % (i, repr(descr['allowed_values'][i])))
if descr["allowed_values"][i] in values[field]:

File diff suppressed because it is too large Load Diff

View File

@ -55,7 +55,7 @@ from email.MIMEBase import MIMEBase # pylint: disable=no-name-in-module,import-
from email.Header import Header # pylint: disable=no-name-in-module,import-error
from email import Encoders # pylint: disable=no-name-in-module,import-error
from sco_zope import (
from app.scodoc.sco_zope import (
ObjectManager,
PropertyManager,
RoleManager,
@ -72,13 +72,13 @@ try:
except:
import ZPsycopgDA.DA as ZopeDA # interp.py
import sco_utils as scu
import VERSION
import app.scodoc.sco_utils as scu
from app.scodoc import VERSION
import mails
from notes_log import log
import sco_find_etud
import sco_users
from sco_permissions import (
from app.scodoc.notes_log import log
from app.scodoc import sco_find_etud
from app.scodoc import sco_users
from app.scodoc.sco_permissions import (
ScoView,
ScoEnsView,
ScoImplement,
@ -94,8 +94,13 @@ from sco_permissions import (
ScoEditApo,
ScoSuperAdmin,
)
from sco_exceptions import ScoValueError, ScoLockedFormError, ScoGenError, AccessDenied
import html_sco_header
from app.scodoc.sco_exceptions import (
ScoValueError,
ScoLockedFormError,
ScoGenError,
AccessDenied,
)
from app.scodoc import html_sco_header
class ZScoDoc(ObjectManager, PropertyManager, RoleManager, Item, Persistent, Implicit):
@ -803,7 +808,7 @@ ErrorType: %(error_type)s
last_dept = None
last_date = None
for (dept, etuds) in depts_etud:
scolars.fillEtudsInfo(self, etuds)
sco_etud.fill_etuds_info(self, etuds)
etud = etuds[0]
if etud["sems"]:
if (not last_date) or (etud["sems"][0]["date_fin_iso"] > last_date):

View File

@ -34,23 +34,23 @@ import md5
import base64
import jaxml
from sco_zope import * # pylint: disable=unused-wildcard-import
from app.scodoc.sco_zope import * # pylint: disable=unused-wildcard-import
# ---------------
import sco_utils as scu
import notesdb as ndb
from notes_log import log
from scolog import logdb
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from app.scodoc.notes_log import log
from app.scodoc.scolog import logdb
from scolars import format_prenom, format_nom
import sco_import_users
import sco_excel
from TrivialFormulator import TrivialFormulator, TF, tf_error_message
from gen_tables import GenTable
import scolars
import sco_cache
import sco_users
from app.scodoc import sco_import_users
from app.scodoc import sco_excel
from app.scodoc.TrivialFormulator import TrivialFormulator, TF, tf_error_message
from app.scodoc.gen_tables import GenTable
from app.scodoc import sco_etud
from app.scodoc import sco_cache
from app.scodoc import sco_users
from sco_exceptions import (
from app.scodoc.sco_exceptions import (
AccessDenied,
ScoException,
ScoValueError,
@ -305,7 +305,7 @@ class ZScoUsers(
info["prenomnom"] = (prenom_abbrv + " " + n).strip()
# nom_fmt et prenom_fmt: minuscule capitalisé
info["nom_fmt"] = n
info["prenom_fmt"] = scolars.format_prenom(p)
info["prenom_fmt"] = sco_etud.format_prenom(p)
# nomcomplet est le prenom et le nom complets
info["nomcomplet"] = info["prenom_fmt"] + " " + info["nom_fmt"]
# nomplogin est le nom en majuscules suivi du prénom et du login

View File

@ -27,4 +27,3 @@
"""ScoDoc core package
"""
# from app.scodoc import sco_core

View File

@ -34,25 +34,37 @@ nt = context.Notes._getNotesCache().get_NotesTable(context.Notes, formsemestre_i
import pdb # pylint: disable=unused-import
import pprint
import app.scodoc.notesdb as ndb
from app.scodoc.notesdb import * # pylint: disable=unused-wildcard-import
import app.scodoc.notesdb as ndb # pylint: disable=unused-import
from app.scodoc.notesdb import * # pylint: disable=wildcard-import,unused-wildcard-import
from app.scodoc.notes_log import log
import app.scodoc.sco_utils as scu
from app.scodoc.sco_utils import * # pylint: disable=unused-wildcard-import
from app.scodoc.sco_utils import * # pylint: disable=wildcard-import, unused-wildcard-import
from gen_tables import GenTable
import sco_archives
import sco_groups
import sco_evaluations
import sco_formsemestre
import sco_formsemestre_edit
import sco_compute_moy
import sco_parcours_dut
import sco_codes_parcours
import sco_bulletins
import sco_excel
import sco_formsemestre_status
import sco_bulletins_xml
from app.scodoc.gen_tables import GenTable
from app.scodoc import html_sco_header
from app.scodoc import sco_archives
from app.scodoc import sco_bulletins
from app.scodoc import sco_bulletins_xml
from app.scodoc import sco_codes_parcours
from app.scodoc import sco_compute_moy
from app.scodoc import sco_core
from app.scodoc import sco_edit_matiere
from app.scodoc import sco_edit_module
from app.scodoc import sco_edit_ue
from app.scodoc import sco_excel
from app.scodoc import sco_formations
from app.scodoc import sco_formsemestre
from app.scodoc import sco_formsemestre_edit
from app.scodoc import sco_formsemestre_status
from app.scodoc import sco_formsemestre_validation
from app.scodoc import sco_groups
from app.scodoc import sco_moduleimpl
from app.scodoc import sco_news
from app.scodoc import sco_parcours_dut
from app.scodoc import sco_permissions
from app.scodoc import sco_preferences
from app.scodoc import sco_tag_module
from app.scodoc import sco_etud
# Prend le premier departement comme context

View File

@ -4,7 +4,7 @@
#
# Command: ./csv2rules.py misc/parcoursDUT.csv
#
from sco_codes_parcours import (
from app.scodoc.sco_codes_parcours import (
DUTRule,
ADC,
ADJ,

View File

@ -54,11 +54,11 @@ from reportlab.lib import styles
from reportlab.lib.units import inch, cm, mm
from reportlab.rl_config import defaultPageSize # pylint: disable=no-name-in-module
import sco_utils as scu
import sco_excel
import sco_pdf
from sco_pdf import SU
from notes_log import log
import app.scodoc.sco_utils as scu
import app.scodoc.sco_excel
import app.scodoc.sco_pdf
from app.scodoc.sco_pdf import SU
from app.scodoc.notes_log import log
def mark_paras(L, tags):
@ -71,6 +71,8 @@ def mark_paras(L, tags):
class DEFAULT_TABLE_PREFERENCES:
"""Default preferences for tables created without preferences argument"""
values = {
"SCOLAR_FONT": "Helvetica", # used for PDF, overriden by preferences argument
"SCOLAR_FONT_SIZE": 10,

View File

@ -25,16 +25,15 @@
#
##############################################################################
"""HTML Header/Footer for ScoDoc pages
"""
import cgi
import sco_utils as scu
from notes_log import log
import html_sidebar
import VERSION
"""
HTML Header/Footer for ScoDoc pages
"""
import app.scodoc.sco_utils as scu
from app.scodoc.notes_log import log
from app.scodoc import html_sidebar
from app.scodoc import VERSION
# Some constants:
@ -155,6 +154,7 @@ def sco_header(
user_check=True, # verifie passwords temporaires
):
"Main HTML page header for ScoDoc"
from app.scodoc.sco_formsemestre_status import formsemestre_page_title
# context est une instance de ZScolar. container est une instance qui "acquiert" ZScolar
if container:
@ -364,6 +364,3 @@ def html_sem_header(
return h + """<h2 class="formsemestre">%s</h2>""" % (title)
else:
return h
from sco_formsemestre_status import formsemestre_page_title

View File

@ -25,16 +25,14 @@
#
##############################################################################
import sco_utils as scu
import sco_preferences
from sco_abs import getAbsSemEtud
from app.scodoc.sco_permissions import Permission
import scolars
"""
Génération de la "sidebar" (marge gauche des pages HTML)
"""
import app.scodoc.sco_utils as scu
from app.scodoc import sco_preferences
from app.scodoc.sco_permissions import Permission
def sidebar_common(context, REQUEST=None):
"partie commune a toutes les sidebar"
@ -78,6 +76,9 @@ def sidebar_common(context, REQUEST=None):
def sidebar(context, REQUEST=None):
"Main HTML page sidebar"
# rewritten from legacy DTML code
from app.scodoc.sco_abs import getAbsSemEtud
from app.scodoc import sco_etud
params = {"ScoURL": scu.ScoURL(), "SCO_USER_MANUAL": scu.SCO_USER_MANUAL}
H = ['<div class="sidebar">', sidebar_common(context, REQUEST)]
@ -94,7 +95,7 @@ def sidebar(context, REQUEST=None):
# ---- s'il y a un etudiant selectionné:
if REQUEST.form.has_key("etudid"):
etudid = REQUEST.form["etudid"]
etud = scolars.get_etud_info(filled=1, etudid=etudid)[0]
etud = sco_etud.get_etud_info(filled=1, etudid=etudid)[0]
params.update(etud)
# compte les absences du semestre en cours
H.append(

View File

@ -31,6 +31,8 @@ from flask import g, url_for
import listhistogram
import app.scodoc.sco_utils as scu
def horizontal_bargraph(value, mark):
"""html drawing an horizontal bar and a mark
@ -102,7 +104,7 @@ def make_menu(title, items, css_class="", alone=False):
args = item.get("args", {})
item["urlq"] = url_for(
item["endpoint"], scodoc_dept=g.scodoc_dept, **args
)
).encode(scu.SCO_ENCODING)
else:
item["urlq"] = "#"
item["attr"] = item.get("attr", "")

View File

@ -39,8 +39,8 @@ from email.MIMEBase import MIMEBase # pylint: disable=no-name-in-module,import-
from email.Header import Header # pylint: disable=no-name-in-module,import-error
from email import Encoders # pylint: disable=no-name-in-module,import-error
import sco_utils as scu
from notes_log import log
import app.scodoc.sco_utils as scu
from app.scodoc.notes_log import log
def sendEmail(context, msg): # TODO A REECRIRE ScoDoc8

View File

@ -31,10 +31,10 @@
NOTA: inutilisable dans une instance Zope (can't pickle functions)
"""
from notes_log import log
from app.scodoc.notes_log import log
class CacheFunc:
class CacheFunc(object):
"""gestion rudimentaire de cache pour une fonction
func doit etre sans effet de bord, et sans arguments nommés
"""

View File

@ -1,8 +1,6 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
import pdb
import sys
import os
import re
import inspect
@ -10,18 +8,8 @@ import time
import traceback
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email.header import Header
from email.MIMEMultipart import ( # pylint: disable=no-name-in-module,import-error
MIMEMultipart,
)
from email.MIMEText import MIMEText # pylint: disable=no-name-in-module,import-error
from email.MIMEBase import MIMEBase # pylint: disable=no-name-in-module,import-error
from email.Header import Header # pylint: disable=no-name-in-module,import-error
from email import Encoders # pylint: disable=no-name-in-module,import-error
# Simple & stupid file logguer, used only to debug
# (logging to SQL is done in scolog)

View File

@ -32,34 +32,42 @@ import time
import pdb
import inspect
import sco_utils as scu
import notesdb as ndb
from notes_log import log, logCallStack
from sco_formulas import NoteVector
from sco_exceptions import (
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from app.scodoc.notes_log import log, logCallStack
from app.scodoc.sco_formulas import NoteVector
from app.scodoc.sco_exceptions import (
AccessDenied,
NoteProcessError,
ScoException,
ScoValueError,
)
from sco_formsemestre import formsemestre_uecoef_list, formsemestre_uecoef_create
from sco_codes_parcours import DEF, UE_SPORT, UE_is_fondamentale, UE_is_professionnelle
from sco_parcours_dut import formsemestre_get_etud_capitalisation
import sco_codes_parcours
import sco_compute_moy
import sco_core
import sco_edit_matiere
import sco_edit_module
import sco_edit_ue
import sco_evaluations
import sco_formations
import sco_formsemestre
import sco_formsemestre_inscriptions
import sco_groups
import sco_moduleimpl
import sco_parcours_dut
import sco_preferences
import scolars
from app.scodoc.sco_formsemestre import (
formsemestre_uecoef_list,
formsemestre_uecoef_create,
)
from app.scodoc.sco_codes_parcours import (
DEF,
UE_SPORT,
UE_is_fondamentale,
UE_is_professionnelle,
)
from app.scodoc.sco_parcours_dut import formsemestre_get_etud_capitalisation
from app.scodoc import sco_codes_parcours
from app.scodoc import sco_compute_moy
from app.scodoc import sco_core
from app.scodoc import sco_edit_matiere
from app.scodoc import sco_edit_module
from app.scodoc import sco_edit_ue
from app.scodoc import sco_evaluations
from app.scodoc import sco_formations
from app.scodoc import sco_formsemestre
from app.scodoc import sco_formsemestre_inscriptions
from app.scodoc import sco_groups
from app.scodoc import sco_moduleimpl
from app.scodoc import sco_parcours_dut
from app.scodoc import sco_preferences
from app.scodoc import sco_etud
# Support for old user-written "bonus" functions with 2 args:
@ -193,7 +201,7 @@ class NotesTable:
self.identdict = {} # { etudid : ident }
self.inscrdict = {} # { etudid : inscription }
for x in self.inscrlist:
i = scolars.etudident_list(cnx, {"etudid": x["etudid"]})[0]
i = sco_etud.etudident_list(cnx, {"etudid": x["etudid"]})[0]
self.identdict[x["etudid"]] = i
self.inscrdict[x["etudid"]] = x
x["nomp"] = (i["nom_usuel"] or i["nom"]) + i["prenom"] # pour tri
@ -405,7 +413,7 @@ class NotesTable:
def get_nom_long(self, etudid):
"formatte nom d'un etud: M. Pierre DUPONT"
etud = self.identdict[etudid]
return scolars.format_nomprenom(etud)
return sco_etud.format_nomprenom(etud)
def get_displayed_etud_code(self, etudid):
'code à afficher sur les listings "anonymes"'
@ -1084,7 +1092,7 @@ class NotesTable:
"Warning: %s capitalized an UE %s which is not part of current sem %s"
% (etudid, ue_id, self.formsemestre_id)
)
ue = self.sco_edit_ue.do_ue_list(context, args={"ue_id": ue_id})[0]
ue = sco_edit_ue.do_ue_list(self.context, args={"ue_id": ue_id})[0]
self.uedict[ue_id] = ue # record this UE
if ue_id not in self._uecoef:
cl = formsemestre_uecoef_list(
@ -1185,7 +1193,7 @@ class NotesTable:
"comp_ue_capitalisees: recomputing UE moy (etudid=%s, ue_id=%s formsemestre_id=%s)"
% (etudid, ue_cap["ue_id"], ue_cap["formsemestre_id"])
)
nt_cap = sco_core.get_notes_cache(context).get_NotesTable(
nt_cap = sco_core.get_notes_cache(self.context).get_NotesTable(
self.context, ue_cap["formsemestre_id"]
) # > UE capitalisees par un etud
moy_ue_cap = nt_cap.get_etud_ue_status(etudid, ue_cap["ue_id"])[

View File

@ -8,9 +8,9 @@ import psycopg2.pool
import psycopg2.extras
import thread
import sco_utils as scu
from notes_log import log
from sco_exceptions import ScoException, ScoValueError, NoteProcessError
import app.scodoc.sco_utils as scu
from app.scodoc.notes_log import log
from app.scodoc.sco_exceptions import ScoException, ScoValueError, NoteProcessError
from types import StringType
from cgi import escape
import datetime

View File

@ -33,17 +33,17 @@
import os
import codecs
import re
import scolars
import pe_jurype, pe_tagtable, pe_tools
from app.scodoc import pe_jurype
from app.scodoc import pe_tagtable
from app.scodoc import pe_tools
import sco_utils as scu
import notesdb as ndb
from notes_log import log
import scolars
import sco_preferences
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from app.scodoc.notes_log import log
from app.scodoc.gen_tables import GenTable, SeqGenTable
from app.scodoc import sco_preferences
from app.scodoc import sco_etud
import pe_jurype, pe_tagtable, pe_tools
from gen_tables import GenTable, SeqGenTable
DEBUG = False # Pour debug et repérage des prints à changer en Log
@ -243,7 +243,7 @@ def get_annotation_PE(context, etudid, tag_annotation_pe):
"""
if tag_annotation_pe:
cnx = ndb.GetDBConnexion()
annotations = scolars.etud_annotations_list(
annotations = sco_etud.etud_annotations_list(
cnx, args={"etudid": etudid}
) # Les annotations de l'étudiant
annotationsPE = []

View File

@ -54,19 +54,25 @@ except:
from zipfile import ZipFile, BadZipfile
import pprint
from gen_tables import GenTable, SeqGenTable
import sco_utils as scu
import sco_codes_parcours # sco_codes_parcours.NEXT -> sem suivant
import sco_report
from app.scodoc.gen_tables import GenTable, SeqGenTable
import app.scodoc.sco_utils as scu
from app.scodoc import sco_codes_parcours # sco_codes_parcours.NEXT -> sem suivant
import pe_tagtable, pe_tools, pe_avislatex, pe_semestretag, pe_settag
from app.scodoc import pe_tagtable
from app.scodoc import pe_tools
from app.scodoc import pe_semestretag
from app.scodoc import pe_settag
# ----------------------------------------------------------------------------------------
def comp_nom_semestre_dans_parcours(context, sem):
"""Le nom a afficher pour titrer un semestre
par exemple: "semestre 2 FI 2015"
"""
F = sco_formations.formation_list(context, args={"formation_id": sem["formation_id"]})[0]
from app.scodoc import sco_formations
F = sco_formations.formation_list(
context, args={"formation_id": sem["formation_id"]}
)[0]
parcours = sco_codes_parcours.get_parcours_from_code(F["type_parcours"])
return "%s %s %s %s" % (
parcours.SESSION_NAME, # eg "semestre"
@ -456,6 +462,8 @@ class JuryPE:
# ------------------------------------------------------------------------------------------------------------------
def est_un_etudiant_reoriente_ou_demissionnaire(self, etudid):
"""Renvoie True si l'étudiant est réorienté (NAR) ou démissionnaire (DEM)"""
from app.scodoc import sco_report
reponse = False
etud = self.get_cache_etudInfo_d_un_etudiant(self.context, etudid)
(_, parcours) = sco_report.get_codeparcoursetud(self.context.Notes, etud)
@ -518,6 +526,8 @@ class JuryPE:
"""Renvoie le n° (semestre_id) du dernier semestre validé par un étudiant fourni par son etudid
et None si aucun semestre n'a été validé
"""
from app.scodoc import sco_report
etud = self.get_cache_etudInfo_d_un_etudiant(self.context, etudid)
(code, parcours) = sco_report.get_codeparcoursetud(
self.context.Notes, etud
@ -1117,7 +1127,7 @@ class JuryPE:
ETUDINFO_DICT si mémorisée soit en les chargeant et en les mémorisant
"""
if etudid not in self.ETUDINFO_DICT:
self.ETUDINFO_DICT[etudid] = scolars.get_etud_info(
self.ETUDINFO_DICT[etudid] = sco_etud.get_etud_info(
etudid=etudid, filled=True
)[0]
return self.ETUDINFO_DICT[etudid]
@ -1139,7 +1149,7 @@ class JuryPE:
def get_semestresDUT_d_un_etudiant(self, etudid, semestre_id=None):
"""Renvoie la liste des semestres DUT d'un étudiant
pour un semestre_id (parmi 1,2,3,4) donné
en fonction de ses infos d'etud (cf. scolars.get_etud_info( etudid=etudid, filled=True)[0]),
en fonction de ses infos d'etud (cf. sco_etud.get_etud_info( etudid=etudid, filled=True)[0]),
les semestres étant triés par ordre décroissant.
Si semestre_id == None renvoie tous les semestres"""
etud = self.get_cache_etudInfo_d_un_etudiant(self.context, etudid)

View File

@ -35,15 +35,11 @@ Created on Fri Sep 9 09:15:05 2016
@author: barasc
"""
import datetime
from notes_log import log
import notes_table
import sco_codes_parcours
import sco_tag_module
import sco_utils
import pe_tagtable
import pe_jurype
from app.scodoc.notes_log import log
from app.scodoc import sco_codes_parcours
from app.scodoc import sco_tag_module
from app.scodoc import pe_tagtable
class SemestreTag(pe_tagtable.TableTag):

View File

@ -36,12 +36,8 @@ Created on Fri Sep 9 09:15:05 2016
@author: barasc
"""
from pe_tools import pe_print, PE_DEBUG
import pe_tagtable
import pe_semestretag
import notes_table
import pe_jurype
from app.scodoc.pe_tools import pe_print, PE_DEBUG
from app.scodoc import pe_tagtable
class SetTag(pe_tagtable.TableTag):

View File

@ -37,9 +37,9 @@ Created on Thu Sep 8 09:36:33 2016
@author: barasc
"""
import notes_table
import datetime
import codecs
from app.scodoc import notes_table
class TableTag:

View File

@ -39,13 +39,11 @@ from __future__ import print_function
import os
import datetime
import operator
import re
import unicodedata
import sco_utils as scu
from notes_log import log
import notes_table
import app.scodoc.sco_utils as scu
from app.scodoc.notes_log import log
PE_DEBUG = 0

View File

@ -35,23 +35,15 @@
"""
import sco_utils as scu
from notes_log import log
import sco_formsemestre
import sco_formsemestre_status
import notes_table
from gen_tables import GenTable
import html_sco_header
import sco_codes_parcours
import sco_preferences
import app.scodoc.sco_utils as scu
from app.scodoc import sco_formsemestre
from app.scodoc import html_sco_header
from app.scodoc import sco_preferences
import pe_tools
from pe_tools import PE_LATEX_ENCODING
import pe_tagtable
import pe_semestretag
import pe_settag
import pe_jurype
import pe_avislatex
from app.scodoc import pe_tools
from app.scodoc.pe_tools import PE_LATEX_ENCODING
from app.scodoc import pe_jurype
from app.scodoc import pe_avislatex
def _pe_view_sem_recap_form(context, formsemestre_id, REQUEST=None):

View File

@ -31,19 +31,35 @@
# Anciennement dans ZAbscences.py, séparé pour migration
import string
import datetime
import re
import time
import datetime
import calendar
import cgi
import notesdb
from scodoc_manager import sco_mgr
from sco_exceptions import ScoValueError, ScoInvalidDateError
import sco_formsemestre
import sco_compute_moy
import sco_preferences
import scolars
from app.scodoc import notesdb as ndb
from app.scodoc.scolog import logdb
from app.scodoc.sco_exceptions import ScoValueError, ScoInvalidDateError
from app.scodoc import sco_abs_notification
from app.scodoc import sco_formsemestre
from app.scodoc import sco_preferences
from app.scodoc import sco_etud
# --- Misc tools.... ------------------
def _isFarFutur(jour):
# check si jour est dans le futur "lointain"
# pour autoriser les saisies dans le futur mais pas a plus de 6 mois
y, m, d = [int(x) for x in jour.split("-")]
j = datetime.date(y, m, d)
# 6 mois ~ 182 jours:
return j - datetime.date.today() > datetime.timedelta(182)
def _toboolean(x):
"convert a value to boolean"
return x # not necessary anymore !
def is_work_saturday(context):
@ -264,9 +280,419 @@ def YearTable(
return string.join(T, "\n")
def list_abs_in_range(
context, etudid, debut, fin, matin=None, moduleimpl_id=None, cursor=None
):
"""Liste des absences entre deux dates.
Args:
etudid
debut string iso date ("2020-03-12")
end string iso date ("2020-03-12")
matin None, True, False
moduleimpl_id
"""
if matin != None:
matin = _toboolean(matin)
ismatin = " AND A.MATIN = %(matin)s "
else:
ismatin = ""
if moduleimpl_id:
modul = " AND A.MODULEIMPL_ID = %(moduleimpl_id)s "
else:
modul = ""
if not cursor:
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"""
SELECT DISTINCT A.JOUR, A.MATIN
FROM ABSENCES A
WHERE A.ETUDID = %(etudid)s
AND A.ESTABS"""
+ ismatin
+ modul
+ """
AND A.JOUR BETWEEN %(debut)s AND %(fin)s
""",
{"etudid": etudid, "debut": debut, "fin": fin, "moduleimpl_id": moduleimpl_id},
)
res = cursor.dictfetchall()
return res
def CountAbs(context, etudid, debut, fin, matin=None, moduleimpl_id=None):
"""CountAbs
matin= 1 ou 0.
Returns:
An integer.
"""
return len(
list_abs_in_range(
context, etudid, debut, fin, matin=matin, moduleimpl_id=moduleimpl_id
)
)
def CountAbsJust(context, etudid, debut, fin, matin=None, moduleimpl_id=None):
"Count just. abs"
if matin != None:
matin = _toboolean(matin)
ismatin = " AND A.MATIN = %(matin)s "
else:
ismatin = ""
if moduleimpl_id:
modul = " AND A.MODULEIMPL_ID = %(moduleimpl_id)s "
else:
modul = ""
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"""SELECT COUNT(*) AS NbAbsJust FROM (
SELECT DISTINCT A.JOUR, A.MATIN
FROM ABSENCES A, ABSENCES B
WHERE A.ETUDID = %(etudid)s
AND A.ETUDID = B.ETUDID
AND A.JOUR = B.JOUR AND A.MATIN = B.MATIN
AND A.JOUR BETWEEN %(debut)s AND %(fin)s
AND A.ESTABS AND (A.ESTJUST OR B.ESTJUST)"""
+ ismatin
+ modul
+ """
) AS tmp
""",
vars(),
)
res = cursor.fetchone()[0]
return res
def ListeAbsDate(context, etudid, beg_date, end_date):
"""Liste des absences et justifs entre deux dates (inclues)."""
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"""SELECT jour, matin, estabs, estjust, description FROM ABSENCES A
WHERE A.ETUDID = %(etudid)s
AND A.jour >= %(beg_date)s
AND A.jour <= %(end_date)s
""",
vars(),
)
Abs = cursor.dictfetchall()
# remove duplicates
A = {} # { (jour, matin) : abs }
for a in Abs:
jour, matin = a["jour"], a["matin"]
if (jour, matin) in A:
# garde toujours la description
a["description"] = a["description"] or A[(jour, matin)]["description"]
# et la justif:
a["estjust"] = a["estjust"] or A[(jour, matin)]["estjust"]
a["estabs"] = a["estabs"] or A[(jour, matin)]["estabs"]
A[(jour, matin)] = a
else:
A[(jour, matin)] = a
if A[(jour, matin)]["description"] is None:
A[(jour, matin)]["description"] = ""
# add hours: matin = 8:00 - 12:00, apresmidi = 12:00 - 18:00
dat = "%04d-%02d-%02d" % (a["jour"].year, a["jour"].month, a["jour"].day)
if a["matin"]:
A[(jour, matin)]["begin"] = dat + " 08:00:00"
A[(jour, matin)]["end"] = dat + " 11:59:59"
else:
A[(jour, matin)]["begin"] = dat + " 12:00:00"
A[(jour, matin)]["end"] = dat + " 17:59:59"
# sort
R = A.values()
R.sort(key=lambda x: (x["begin"]))
return R
def GetAbsDescription(context, a, cursor=None):
"Description associee a l'absence"
from app.scodoc import sco_moduleimpl
if not cursor:
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
a = a.copy()
# a['jour'] = a['jour'].date()
if a["matin"]: # devrait etre booleen... :-(
a["matin"] = True
else:
a["matin"] = False
cursor.execute(
"""select * from absences where etudid=%(etudid)s and jour=%(jour)s and matin=%(matin)s order by entry_date desc""",
a,
)
A = cursor.dictfetchall()
desc = None
module = ""
for a in A:
if a["description"]:
desc = a["description"]
if a["moduleimpl_id"] and a["moduleimpl_id"] != "NULL":
# Trouver le nom du module
Mlist = sco_moduleimpl.do_moduleimpl_withmodule_list(
context.Notes, moduleimpl_id=a["moduleimpl_id"]
)
if Mlist:
M = Mlist[0]
module += "%s " % M["module"]["code"]
if desc:
return "(%s) %s" % (desc, module)
if module:
return module
return ""
def ListeAbsJour(context, date, am=True, pm=True, is_abs=True, is_just=None):
"""Liste des absences et/ou justificatifs ce jour.
is_abs: None (peu importe), True, False
is_just: idem
"""
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
req = """SELECT DISTINCT etudid, jour, matin FROM ABSENCES A
WHERE A.jour = %(date)s
"""
if is_abs != None:
req += " AND A.estabs = %(is_abs)s"
if is_just != None:
req += " AND A.estjust = %(is_just)s"
if not am:
req += " AND NOT matin "
if not pm:
req += " AND matin"
cursor.execute(req, {"date": date, "is_just": is_just, "is_abs": is_abs})
A = cursor.dictfetchall()
for a in A:
a["description"] = GetAbsDescription(context, a, cursor=cursor)
return A
def ListeAbsNonJustJour(context, date, am=True, pm=True):
"Liste des absences non justifiees ce jour"
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
reqa = ""
if not am:
reqa += " AND NOT matin "
if not pm:
reqa += " AND matin "
req = (
"""SELECT etudid, jour, matin FROM ABSENCES A
WHERE A.estabs
AND A.jour = %(date)s
"""
+ reqa
+ """EXCEPT SELECT etudid, jour, matin FROM ABSENCES B
WHERE B.estjust AND B.jour = %(date)s"""
+ reqa
)
cursor.execute(req, {"date": date})
A = cursor.dictfetchall()
for a in A:
a["description"] = GetAbsDescription(context, a, cursor=cursor)
return A
def ListeAbsNonJust(context, etudid, datedebut):
"Liste des absences NON justifiees (par ordre chronologique)"
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"""SELECT ETUDID, JOUR, MATIN FROM ABSENCES A
WHERE A.ETUDID = %(etudid)s
AND A.estabs
AND A.jour >= %(datedebut)s
EXCEPT SELECT ETUDID, JOUR, MATIN FROM ABSENCES B
WHERE B.estjust
AND B.ETUDID = %(etudid)s
ORDER BY JOUR
""",
vars(),
)
A = cursor.dictfetchall()
for a in A:
a["description"] = GetAbsDescription(context, a, cursor=cursor)
return A
def ListeAbsJust(context, etudid, datedebut):
"Liste des absences justifiees (par ordre chronologique)"
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"""SELECT DISTINCT A.ETUDID, A.JOUR, A.MATIN FROM ABSENCES A, ABSENCES B
WHERE A.ETUDID = %(etudid)s
AND A.ETUDID = B.ETUDID
AND A.JOUR = B.JOUR AND A.MATIN = B.MATIN AND A.JOUR >= %(datedebut)s
AND A.ESTABS AND (A.ESTJUST OR B.ESTJUST)
ORDER BY A.JOUR
""",
vars(),
)
A = cursor.dictfetchall()
for a in A:
a["description"] = GetAbsDescription(context, a, cursor=cursor)
return A
def ListeJustifs(context, etudid, datedebut, datefin=None, only_no_abs=False):
"""Liste des justificatifs (sans absence relevée) à partir d'une date,
ou, si datefin spécifié, entre deux dates.
Si only_no_abs: seulement les justificatifs correspondant aux jours sans absences relevées.
"""
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
req = """SELECT DISTINCT ETUDID, JOUR, MATIN FROM ABSENCES A
WHERE A.ETUDID = %(etudid)s
AND A.ESTJUST
AND A.JOUR >= %(datedebut)s"""
if datefin:
req += """AND A.JOUR <= %(datefin)s"""
if only_no_abs:
req += """
EXCEPT SELECT ETUDID, JOUR, MATIN FROM ABSENCES B
WHERE B.estabs
AND B.ETUDID = %(etudid)s
"""
cursor.execute(req, vars())
A = cursor.dictfetchall()
for a in A:
a["description"] = GetAbsDescription(context, a, cursor=cursor)
return A
def add_absence(
context,
etudid,
jour,
matin,
estjust,
REQUEST,
description=None,
moduleimpl_id=None,
):
"Ajoute une absence dans la bd"
if _isFarFutur(jour):
raise ScoValueError("date absence trop loin dans le futur !")
estjust = _toboolean(estjust)
matin = _toboolean(matin)
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"insert into absences (etudid,jour,estabs,estjust,matin,description, moduleimpl_id) values (%(etudid)s, %(jour)s, TRUE, %(estjust)s, %(matin)s, %(description)s, %(moduleimpl_id)s )",
vars(),
)
logdb(
REQUEST,
cnx,
"AddAbsence",
etudid=etudid,
msg="JOUR=%(jour)s,MATIN=%(matin)s,ESTJUST=%(estjust)s,description=%(description)s,moduleimpl_id=%(moduleimpl_id)s"
% vars(),
)
cnx.commit()
invalidateAbsEtudDate(context, etudid, jour)
sco_abs_notification.abs_notify(context, etudid, jour)
def add_justif(context, etudid, jour, matin, REQUEST, description=None):
"Ajoute un justificatif dans la base"
# unpublished
if _isFarFutur(jour):
raise ScoValueError("date justificatif trop loin dans le futur !")
matin = _toboolean(matin)
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"insert into absences (etudid,jour,estabs,estjust,matin, description) values (%(etudid)s,%(jour)s, FALSE, TRUE, %(matin)s, %(description)s )",
vars(),
)
logdb(
REQUEST,
cnx,
"AddJustif",
etudid=etudid,
msg="JOUR=%(jour)s,MATIN=%(matin)s" % vars(),
)
cnx.commit()
invalidateAbsEtudDate(context, etudid, jour)
def _add_abslist(context, abslist, REQUEST, moduleimpl_id=None):
for a in abslist:
etudid, jour, ampm = a.split(":")
if ampm == "am":
matin = 1
elif ampm == "pm":
matin = 0
else:
raise ValueError("invalid ampm !")
# ajoute abs si pas deja absent
if CountAbs(context, etudid, jour, jour, matin, moduleimpl_id) == 0:
add_absence(context, etudid, jour, matin, 0, REQUEST, "", moduleimpl_id)
def annule_absence(context, etudid, jour, matin, moduleimpl_id=None, REQUEST=None):
"""Annule une absence ds base
Si moduleimpl_id, n'annule que pour ce module
"""
# unpublished
matin = _toboolean(matin)
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
req = "delete from absences where jour=%(jour)s and matin=%(matin)s and etudid=%(etudid)s and estabs"
if moduleimpl_id:
req += " and moduleimpl_id=%(moduleimpl_id)s"
cursor.execute(req, vars())
logdb(
REQUEST,
cnx,
"AnnuleAbsence",
etudid=etudid,
msg="JOUR=%(jour)s,MATIN=%(matin)s,moduleimpl_id=%(moduleimpl_id)s" % vars(),
)
cnx.commit()
invalidateAbsEtudDate(context, etudid, jour)
def annule_justif(context, etudid, jour, matin, REQUEST=None):
"Annule un justificatif"
# unpublished
matin = _toboolean(matin)
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"delete from absences where jour=%(jour)s and matin=%(matin)s and etudid=%(etudid)s and ESTJUST AND NOT ESTABS",
vars(),
)
cursor.execute(
"update absences set estjust=false where jour=%(jour)s and matin=%(matin)s and etudid=%(etudid)s",
vars(),
)
logdb(
REQUEST,
cnx,
"AnnuleJustif",
etudid=etudid,
msg="JOUR=%(jour)s,MATIN=%(matin)s" % vars(),
)
cnx.commit()
invalidateAbsEtudDate(context, etudid, jour)
# ---- BILLETS
_billet_absenceEditor = notesdb.EditableTable(
_billet_absenceEditor = ndb.EditableTable(
"billet_absence",
"billet_id",
(
@ -563,14 +989,14 @@ class CAbsSemEtud:
self.sem = sco_formsemestre.get_formsemestre(
self.context, self.sem["formsemestre_id"]
)
debut_sem = notesdb.DateDMYtoISO(self.sem["date_debut"])
fin_sem = notesdb.DateDMYtoISO(self.sem["date_fin"])
debut_sem = ndb.DateDMYtoISO(self.sem["date_debut"])
fin_sem = ndb.DateDMYtoISO(self.sem["date_fin"])
self._CountAbs = self.context.Absences.CountAbs(
etudid=self.etudid, debut=debut_sem, fin=fin_sem
self._CountAbs = self.sco_abs.CountAbs(
context, etudid=self.etudid, debut=debut_sem, fin=fin_sem
)
self._CountAbsJust = self.context.Absences.CountAbsJust(
etudid=self.etudid, debut=debut_sem, fin=fin_sem
self._CountAbsJust = self.sco_abs.CountAbsJust(
context, etudid=self.etudid, debut=debut_sem, fin=fin_sem
)
self._loaded = True
@ -606,8 +1032,10 @@ def invalidateAbsEtudDate(context, etudid, date):
Invalide cache absence et PDF bulletins si nécessaire.
date: date au format ISO
"""
import sco_compute_moy
# Semestres a cette date:
etud = scolars.get_etud_info(etudid=etudid, filled=True)[0]
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
sems = [
sem
for sem in etud["sems"]

View File

@ -37,15 +37,14 @@ from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.header import Header
import mails
import notesdb as ndb
import sco_utils as scu
from notes_log import log
from scolog import logdb
import sco_bulletins
import sco_formsemestre
import sco_preferences
import scolars
from app.scodoc import mails
import app.scodoc.notesdb as ndb
import app.scodoc.sco_utils as scu
from app.scodoc.notes_log import log
from app.scodoc.scolog import logdb
from app.scodoc import sco_formsemestre
from app.scodoc import sco_preferences
from app.scodoc import sco_etud
def abs_notify(context, etudid, date):
@ -54,13 +53,15 @@ def abs_notify(context, etudid, date):
(s'il n'y a pas de semestre courant, ne fait rien,
car l'etudiant n'est pas inscrit au moment de l'absence!).
"""
from app.scodoc import sco_abs
sem = retreive_current_formsemestre(context, etudid, date)
if not sem:
return # non inscrit a la date, pas de notification
debut_sem = ndb.DateDMYtoISO(sem["date_debut"])
fin_sem = ndb.DateDMYtoISO(sem["date_fin"])
nbabs = context.CountAbs(etudid, debut=debut_sem, fin=fin_sem)
nbabs = sco_abs.CountAbs(context, etudid, debut=debut_sem, fin=fin_sem)
nbabsjust = context.CountAbsJust(etudid, debut=debut_sem, fin=fin_sem)
do_abs_notify(context, sem, etudid, date, nbabs, nbabsjust)
@ -154,7 +155,7 @@ def abs_notify_get_destinations(context, sem, prefs, etudid, date, nbabs, nbabsj
if prefs["abs_notify_email"]:
destinations.append(prefs["abs_notify_email"])
if prefs["abs_notify_etud"]:
etud = scolars.get_etud_info(etudid=etudid, filled=1)[0]
etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0]
if etud["email_default"]:
destinations.append(etud["email_default"])
@ -238,7 +239,9 @@ def abs_notification_message(context, sem, prefs, etudid, nbabs, nbabsjust):
"""Mime notification message based on template.
returns None if sending should be canceled (emplty template).
"""
etud = scolars.get_etud_info(etudid=etudid, filled=True)[0]
from app.scodoc import sco_bulletins
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
# Variables accessibles dans les balises du template: %(nom_variable)s :
values = sco_bulletins.make_context_dict(context, sem, etud)

View File

@ -32,22 +32,23 @@ import datetime
from stripogram import html2text, html2safehtml
from gen_tables import GenTable
from notesdb import DateISOtoDMY
import sco_utils as scu
from sco_exceptions import ScoValueError
from sco_permissions import Permission
from notes_log import log
import html_sco_header
import sco_abs
import sco_find_etud
import sco_formsemestre
import sco_groups
import sco_moduleimpl
import sco_photos
import sco_preferences
import scolars
import app.scodoc.sco_utils as scu
from app.scodoc import notesdb as ndb
from app.scodoc.scolog import logdb
from app.scodoc.gen_tables import GenTable
from app.scodoc import html_sco_header
from app.scodoc import sco_abs
from app.scodoc import sco_etud
from app.scodoc import sco_find_etud
from app.scodoc import sco_formsemestre
from app.scodoc import sco_groups
from app.scodoc import sco_moduleimpl
from app.scodoc import sco_photos
from app.scodoc import sco_preferences
from app.scodoc.notes_log import log
from app.scodoc.sco_exceptions import ScoValueError
from app.scodoc.sco_permissions import Permission
def doSignaleAbsence(
@ -72,7 +73,7 @@ def doSignaleAbsence(
description: str
etudid: etudiant concerné. Si non spécifié, cherche dans REQUEST.form
"""
etud = scolars.get_etud_info(filled=1, etudid=etudid, REQUEST=REQUEST)[0]
etud = sco_etud.get_etud_info(filled=1, etudid=etudid, REQUEST=REQUEST)[0]
etudid = etud["etudid"]
description_abs = description
@ -81,15 +82,30 @@ def doSignaleAbsence(
demijournee = int(demijournee)
for jour in dates:
if demijournee == 2:
context._AddAbsence(
etudid, jour, False, estjust, REQUEST, description_abs, moduleimpl_id
sco_abs.add_absence(
context,
etudid,
jour,
False,
estjust,
REQUEST,
description_abs,
moduleimpl_id,
)
context._AddAbsence(
etudid, jour, True, estjust, REQUEST, description_abs, moduleimpl_id
sco_abs.add_absence(
context,
etudid,
jour,
True,
estjust,
REQUEST,
description_abs,
moduleimpl_id,
)
nbadded += 2
else:
context._AddAbsence(
sco_abs.add_absence(
context,
etudid,
jour,
demijournee,
@ -151,7 +167,7 @@ def doSignaleAbsence(
def SignaleAbsenceEtud(context, REQUEST=None): # etudid implied
"""Formulaire individuel simple de signalement d'une absence"""
# brute-force portage from very old dtml code ...
etud = scolars.get_etud_info(filled=1, REQUEST=REQUEST)[0]
etud = sco_etud.get_etud_info(filled=1, REQUEST=REQUEST)[0]
etudid = etud["etudid"]
disabled = False
if not etud["cursem"]:
@ -290,7 +306,7 @@ def doJustifAbsence(
description: str
etudid: etudiant concerné. Si non spécifié, cherche dans REQUEST.form
"""
etud = scolars.get_etud_info(filled=1, etudid=etudid, REQUEST=REQUEST)[0]
etud = sco_etud.get_etud_info(filled=1, etudid=etudid, REQUEST=REQUEST)[0]
etudid = etud["etudid"]
description_abs = description
dates = sco_abs.DateRangeISO(context, datedebut, datefin)
@ -298,14 +314,16 @@ def doJustifAbsence(
demijournee = int(demijournee)
for jour in dates:
if demijournee == 2:
context._AddJustif(
sco_abs.add_justif(
context,
etudid=etudid,
jour=jour,
matin=False,
REQUEST=REQUEST,
description=description_abs,
)
context._AddJustif(
sco_abs.add_justif(
context,
etudid=etudid,
jour=jour,
matin=True,
@ -314,7 +332,8 @@ def doJustifAbsence(
)
nbadded += 2
else:
context._AddJustif(
sco_abs.add_justif(
context,
etudid=etudid,
jour=jour,
matin=demijournee,
@ -359,7 +378,7 @@ def doJustifAbsence(
def JustifAbsenceEtud(context, REQUEST=None): # etudid implied
"""Formulaire individuel simple de justification d'une absence"""
# brute-force portage from very old dtml code ...
etud = scolars.get_etud_info(filled=1, REQUEST=REQUEST)[0]
etud = sco_etud.get_etud_info(filled=1, REQUEST=REQUEST)[0]
etudid = etud["etudid"]
H = [
html_sco_header.sco_header(
@ -417,7 +436,7 @@ def doAnnuleAbsence(
context, datedebut, datefin, demijournee, etudid=False, REQUEST=None
): # etudid implied
"""Annulation des absences pour une demi journée"""
etud = scolars.get_etud_info(filled=1, etudid=etudid, REQUEST=REQUEST)[0]
etud = sco_etud.get_etud_info(filled=1, etudid=etudid, REQUEST=REQUEST)[0]
etudid = etud["etudid"]
dates = sco_abs.DateRangeISO(context, datedebut, datefin)
@ -425,11 +444,11 @@ def doAnnuleAbsence(
demijournee = int(demijournee)
for jour in dates:
if demijournee == 2:
context._AnnuleAbsence(etudid, jour, False, REQUEST=REQUEST)
context._AnnuleAbsence(etudid, jour, True, REQUEST=REQUEST)
sco_abs.annule_absence(context, etudid, jour, False, REQUEST=REQUEST)
sco_abs.annule_absence(context, etudid, jour, True, REQUEST=REQUEST)
nbadded += 2
else:
context._AnnuleAbsence(etudid, jour, demijournee, REQUEST=REQUEST)
sco_abs.annule_absence(context, etudid, jour, demijournee, REQUEST=REQUEST)
nbadded += 1
#
H = [
@ -468,7 +487,7 @@ autre absence pour <b>%(nomprenom)s</b></a></li>
def AnnuleAbsenceEtud(context, REQUEST=None): # etudid implied
"""Formulaire individuel simple d'annulation d'une absence"""
# brute-force portage from very old dtml code ...
etud = scolars.get_etud_info(filled=1, REQUEST=REQUEST)[0]
etud = sco_etud.get_etud_info(filled=1, REQUEST=REQUEST)[0]
etudid = etud["etudid"]
H = [
@ -557,7 +576,7 @@ def doAnnuleJustif(
context, datedebut0, datefin0, demijournee, REQUEST=None
): # etudid implied
"""Annulation d'une justification"""
etud = scolars.get_etud_info(filled=1, REQUEST=REQUEST)[0]
etud = sco_etud.get_etud_info(filled=1, REQUEST=REQUEST)[0]
etudid = etud["etudid"]
dates = sco_abs.DateRangeISO(context, datedebut0, datefin0)
nbadded = 0
@ -565,11 +584,11 @@ def doAnnuleJustif(
for jour in dates:
# Attention: supprime matin et après-midi
if demijournee == 2:
context._AnnuleJustif(etudid, jour, False, REQUEST=REQUEST)
context._AnnuleJustif(etudid, jour, True, REQUEST=REQUEST)
sco_abs.annule_justif(context, etudid, jour, False, REQUEST=REQUEST)
sco_abs.annule_justif(context, etudid, jour, True, REQUEST=REQUEST)
nbadded += 2
else:
context._AnnuleJustif(etudid, jour, demijournee, REQUEST=REQUEST)
sco_abs.annule_justif(context, etudid, jour, demijournee, REQUEST=REQUEST)
nbadded += 1
#
H = [
@ -605,6 +624,59 @@ autre absence pour <b>%(nomprenom)s</b></a></li>
return "\n".join(H)
def AnnuleAbsencesDatesNoJust(context, etudid, dates, moduleimpl_id=None, REQUEST=None):
"""Supprime les absences aux dates indiquées
mais ne supprime pas les justificatifs.
"""
# log('AnnuleAbsencesDatesNoJust: moduleimpl_id=%s' % moduleimpl_id)
if not dates:
return
date0 = dates[0]
if len(date0.split(":")) == 2:
# am/pm is present
for date in dates:
jour, ampm = date.split(":")
if ampm == "am":
matin = 1
elif ampm == "pm":
matin = 0
else:
raise ValueError("invalid ampm !")
sco_abs.annule_absence(context, etudid, jour, matin, moduleimpl_id, REQUEST)
return
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
# supr les absences non justifiees
for date in dates:
cursor.execute(
"delete from absences where etudid=%(etudid)s and (not estjust) and jour=%(date)s and moduleimpl_id=%(moduleimpl_id)s",
vars(),
)
sco_abs.invalidateAbsEtudDate(context, etudid, date)
# s'assure que les justificatifs ne sont pas "absents"
for date in dates:
cursor.execute(
"update absences set estabs=FALSE where etudid=%(etudid)s and jour=%(date)s and moduleimpl_id=%(moduleimpl_id)s",
vars(),
)
if dates:
date0 = dates[0]
else:
date0 = None
if len(dates) > 1:
date1 = dates[1]
else:
date1 = None
logdb(
REQUEST,
cnx,
"AnnuleAbsencesDatesNoJust",
etudid=etudid,
msg="%s - %s - %s" % (date0, date1, moduleimpl_id),
)
cnx.commit()
def EtatAbsences(context, REQUEST=None):
"""Etat des absences: choix du groupe"""
# crude portage from 1999 DTML
@ -660,26 +732,26 @@ def formChoixSemestreGroupe(context, all=False):
def CalAbs(context, REQUEST=None): # etud implied
"""Calendrier des absences d un etudiant"""
"""Calendrier des absences d'un etudiant"""
# crude portage from 1999 DTML
etud = scolars.get_etud_info(filled=1, REQUEST=REQUEST)[0]
etud = sco_etud.get_etud_info(filled=1, REQUEST=REQUEST)[0]
etudid = etud["etudid"]
anneescolaire = int(scu.AnneeScolaire(REQUEST))
datedebut = str(anneescolaire) + "-08-31"
datefin = str(anneescolaire + 1) + "-07-31"
nbabs = context.CountAbs(etudid=etudid, debut=datedebut, fin=datefin)
nbabs = sco_abs.CountAbs(context, etudid=etudid, debut=datedebut, fin=datefin)
nbabsjust = context.CountAbsJust(etudid=etudid, debut=datedebut, fin=datefin)
events = []
for a in context.ListeAbsJust(etudid=etudid, datedebut=datedebut):
for a in sco_abs.ListeAbsJust(context, etudid=etudid, datedebut=datedebut):
events.append(
(str(a["jour"]), "a", "#F8B7B0", "", a["matin"], a["description"])
)
for a in context.ListeAbsNonJust(etudid=etudid, datedebut=datedebut):
for a in sco_abs.ListeAbsNonJust(context, etudid=etudid, datedebut=datedebut):
events.append(
(str(a["jour"]), "A", "#EE0000", "", a["matin"], a["description"])
)
justifs_noabs = context.ListeJustifs(
etudid=etudid, datedebut=datedebut, only_no_abs=True
justifs_noabs = sco_abs.ListeJustifs(
context, etudid=etudid, datedebut=datedebut, only_no_abs=True
)
for a in justifs_noabs:
events.append(
@ -750,11 +822,11 @@ def ListeAbsEtud(
absjust_only = int(absjust_only) # si vrai, table absjust seule (export xls ou pdf)
datedebut = "%s-08-31" % scu.AnneeScolaire(REQUEST)
etud = scolars.get_etud_info(etudid=etudid, filled=True)[0]
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
# Liste des absences et titres colonnes tables:
titles, columns_ids, absnonjust, absjust = context.Absences._TablesAbsEtud(
etudid, datedebut, with_evals=with_evals, format=format
titles, columns_ids, absnonjust, absjust = _TablesAbsEtud(
context, etudid, datedebut, with_evals=with_evals, format=format
)
if REQUEST:
base_url_nj = "%s?etudid=%s&absjust_only=0" % (REQUEST.URL0, etudid)
@ -805,7 +877,7 @@ def ListeAbsEtud(
)
H.append(
"""<h2>Absences de %s (à partir du %s)</h2>"""
% (etud["nomprenom"], DateISOtoDMY(datedebut))
% (etud["nomprenom"], ndb.DateISOtoDMY(datedebut))
)
if len(absnonjust):
@ -826,12 +898,12 @@ def ListeAbsEtud(
if not len(absnonjust) and not len(absjust):
T.append(
"""--- Pas d'absences enregistrées depuis le %s"""
% DateISOtoDMY(datedebut)
% ndb.DateISOtoDMY(datedebut)
)
else:
T.append(
"""--- Absences enregistrées à partir du %s:"""
% DateISOtoDMY(datedebut)
% ndb.DateISOtoDMY(datedebut)
)
T.append("\n")
if len(absnonjust):
@ -845,6 +917,136 @@ def ListeAbsEtud(
raise ValueError("Invalid format !")
def _TablesAbsEtud(
context,
etudid,
datedebut,
with_evals=True,
format="html",
absjust_only=0,
REQUEST=None,
):
"""Tables des absences justifiees et non justifiees d'un étudiant sur l'année en cours"""
absjust = sco_abs.ListeAbsJust(context, etudid=etudid, datedebut=datedebut)
absnonjust = sco_abs.ListeAbsNonJust(context, etudid=etudid, datedebut=datedebut)
# examens ces jours là ?
if with_evals:
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
for a in absnonjust + absjust:
cursor.execute(
"""select eval.*
from notes_evaluation eval, notes_moduleimpl_inscription mi, notes_moduleimpl m
where eval.jour = %(jour)s and eval.moduleimpl_id = m.moduleimpl_id
and mi.moduleimpl_id = m.moduleimpl_id and mi.etudid = %(etudid)s""",
{"jour": a["jour"].strftime("%Y-%m-%d"), "etudid": etudid},
)
a["evals"] = cursor.dictfetchall()
cursor.execute(
"""SELECT mi.moduleimpl_id
from absences abs, notes_moduleimpl_inscription mi, notes_moduleimpl m
where abs.matin = %(matin)s and abs.jour = %(jour)s and abs.etudid=%(etudid)s and abs.moduleimpl_id=mi.moduleimpl_id and mi.moduleimpl_id=m.moduleimpl_id
and mi.etudid = %(etudid)s""",
{
"matin": bool(a["matin"]),
"jour": a["jour"].strftime("%Y-%m-%d"),
"etudid": etudid,
},
)
a["absent"] = cursor.dictfetchall()
def matin(x):
if x:
return "matin"
else:
return "après-midi"
def descr_exams(a):
if not a.has_key("evals"):
return ""
ex = []
for ev in a["evals"]:
mod = sco_moduleimpl.do_moduleimpl_withmodule_list(
context.Notes, moduleimpl_id=ev["moduleimpl_id"]
)[0]
if format == "html":
ex.append(
'<a href="Notes/moduleimpl_status?moduleimpl_id=%s">%s</a>'
% (mod["moduleimpl_id"], mod["module"]["code"])
)
else:
ex.append(mod["module"]["code"])
if ex:
return ", ".join(ex)
return ""
def descr_abs(a):
ex = []
for ev in a.get("absent", []):
mod = sco_moduleimpl.do_moduleimpl_withmodule_list(
context.Notes, moduleimpl_id=ev["moduleimpl_id"]
)[0]
if format == "html":
ex.append(
'<a href="Notes/moduleimpl_status?moduleimpl_id=%s">%s</a>'
% (mod["moduleimpl_id"], mod["module"]["code"])
)
else:
ex.append(mod["module"]["code"])
if ex:
return ", ".join(ex)
return ""
# ajoute date formatée et évaluations
for L in (absnonjust, absjust):
for a in L:
if with_evals:
a["exams"] = descr_exams(a)
a["datedmy"] = a["jour"].strftime("%d/%m/%Y")
a["ampm"] = int(a["matin"])
a["matin"] = matin(a["matin"])
index = a["description"].find(")")
if index != -1:
a["motif"] = a["description"][1:index]
else:
a["motif"] = ""
a["description"] = descr_abs(a) or ""
# ajoute lien pour justifier
if format == "html":
for a in absnonjust:
a["justlink"] = "<em>justifier</em>"
a[
"_justlink_target"
] = "doJustifAbsence?etudid=%s&datedebut=%s&datefin=%s&demijournee=%s" % (
etudid,
a["datedmy"],
a["datedmy"],
a["ampm"],
)
#
titles = {
"datedmy": "Date",
"matin": "",
"exams": "Examens ce jour",
"justlink": "",
"description": "Modules",
"motif": "Motif",
}
columns_ids = ["datedmy", "matin"]
if format in ("json", "xml"):
columns_ids += ["jour", "ampm"]
if with_evals:
columns_ids.append("exams")
columns_ids.append("description")
columns_ids.append("motif")
if format == "html":
columns_ids.append("justlink")
return titles, columns_ids, absnonjust, absjust
def index_html(context, REQUEST=None):
"""Gestionnaire absences, page principale"""
# crude portage from 1999 DTML

View File

@ -44,15 +44,12 @@ Pour chaque étudiant commun:
"""
from collections import OrderedDict
import sco_utils as scu
from notes_log import log
import sco_apogee_csv
from gen_tables import GenTable
from sco_exceptions import ScoValueError
import html_sco_header
import sco_preferences
from app.scodoc.notes_log import log
from app.scodoc import sco_apogee_csv
from app.scodoc.gen_tables import GenTable
from app.scodoc.sco_exceptions import ScoValueError
from app.scodoc import html_sco_header
from app.scodoc import sco_preferences
_help_txt = """
<div class="help">

View File

@ -95,19 +95,32 @@ try:
except:
chardet_detect = None
import sco_utils as scu
import notesdb as ndb
from notes_log import log
from sco_exceptions import ScoValueError, FormatError
from gen_tables import GenTable
from sco_formsemestre import ApoEtapeVDI
from sco_codes_parcours import code_semestre_validant
from sco_codes_parcours import ATT, ATB, ADM, ADC, ADJ, ATJ, ATB, AJ, CMP, NAR, RAT, DEF
import sco_codes_parcours
import sco_formsemestre
import sco_formsemestre_status
import sco_parcours_dut
import scolars
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from app.scodoc.notes_log import log
from app.scodoc.sco_exceptions import ScoValueError, FormatError
from app.scodoc.gen_tables import GenTable
from app.scodoc.sco_formsemestre import ApoEtapeVDI
from app.scodoc.sco_codes_parcours import code_semestre_validant
from app.scodoc.sco_codes_parcours import (
ADC,
ADJ,
ADM,
AJ,
ATB,
ATJ,
ATT,
CMP,
DEF,
NAR,
RAT,
)
from app.scodoc import sco_codes_parcours
from app.scodoc import sco_core
from app.scodoc import sco_formsemestre
from app.scodoc import sco_formsemestre_status
from app.scodoc import sco_parcours_dut
from app.scodoc import sco_etud
APO_PORTAL_ENCODING = (
"utf8" # encodage du fichier CSV Apogée (était 'ISO-8859-1' avant jul. 2016)
@ -286,7 +299,7 @@ class ApoEtud(dict):
return "ApoEtud( nom='%s', nip='%s' )" % (self["nom"], self["nip"])
def lookup_scodoc(self, context, etape_formsemestre_ids):
etuds = scolars.get_etud_info(code_nip=self["nip"], filled=True)
etuds = sco_etud.get_etud_info(code_nip=self["nip"], filled=True)
if not etuds:
# pas dans ScoDoc
self.etud = None
@ -971,9 +984,9 @@ class ApoData:
s.add(code)
continue
# associé à une UE:
nt = self.sco_core.get_notes_cache(
context,
).get_NotesTable(self.context, sem["formsemestre_id"])
nt = sco_core.get_notes_cache(self.context).get_NotesTable(
self.context, sem["formsemestre_id"]
)
for ue in nt.get_ues():
if ue["code_apogee"] == code:
s.add(code)

View File

@ -52,24 +52,22 @@ import re
import shutil
import glob
import sco_utils as scu
import app.scodoc.sco_utils as scu
from config import Config
import notesdb as ndb
from notes_log import log
from sco_recapcomplet import make_formsemestre_recapcomplet
from TrivialFormulator import TrivialFormulator
from sco_exceptions import (
from app.scodoc.notes_log import log
from app.scodoc.TrivialFormulator import TrivialFormulator
from app.scodoc.sco_exceptions import (
AccessDenied,
)
import html_sco_header
import sco_bulletins_pdf
import sco_excel
import sco_formsemestre
import sco_groups
import sco_groups_view
import sco_permissions
import sco_pvjury
import sco_pvpdf
from app.scodoc import html_sco_header
from app.scodoc import sco_bulletins_pdf
from app.scodoc import sco_excel
from app.scodoc import sco_formsemestre
from app.scodoc import sco_groups
from app.scodoc import sco_groups_view
from app.scodoc import sco_permissions_check
from app.scodoc import sco_pvjury
from app.scodoc import sco_pvpdf
class BaseArchiver:
@ -276,6 +274,8 @@ def do_formsemestre_archive(
Store:
- tableau recap (xls), pv jury (xls et pdf), bulletins (xml et pdf), lettres individuelles (pdf)
"""
from app.scodoc.sco_recapcomplet import make_formsemestre_recapcomplet
archive_id = PVArchive.create_obj_archive(context, formsemestre_id, description)
date = PVArchive.get_archive_date(archive_id).strftime("%d/%m/%Y à %H:%M")
@ -370,7 +370,7 @@ def formsemestre_archive(context, REQUEST, formsemestre_id, group_ids=[]):
"""Make and store new archive for this formsemestre.
(all students or only selected groups)
"""
if not sco_permissions.can_edit_pv(context, REQUEST, formsemestre_id):
if not sco_permissions_check.can_edit_pv(context, REQUEST, formsemestre_id):
raise AccessDenied(
"opération non autorisée pour %s" % str(REQUEST.AUTHENTICATED_USER)
)
@ -553,7 +553,7 @@ def formsemestre_delete_archive(
context, REQUEST, formsemestre_id, archive_name, dialog_confirmed=False
):
"""Delete an archive"""
if not sco_permissions.can_edit_pv(context, REQUEST, formsemestre_id):
if not sco_permissions_check.can_edit_pv(context, REQUEST, formsemestre_id):
raise AccessDenied(
"opération non autorisée pour %s" % str(REQUEST.AUTHENTICATED_USER)
)

View File

@ -30,19 +30,17 @@
les dossiers d'admission et autres pièces utiles.
"""
import sco_utils as scu
from notes_log import log
import ImportScolars
import sco_formsemestre
import sco_groups
import sco_trombino
import sco_excel
import sco_archives
from sco_permissions import Permission
from sco_exceptions import AccessDenied
from TrivialFormulator import TrivialFormulator
import html_sco_header
import scolars
import app.scodoc.sco_utils as scu
from app.scodoc import ImportScolars
from app.scodoc import sco_groups
from app.scodoc import sco_trombino
from app.scodoc import sco_excel
from app.scodoc import sco_archives
from app.scodoc.sco_permissions import Permission
from app.scodoc.sco_exceptions import AccessDenied
from app.scodoc.TrivialFormulator import TrivialFormulator
from app.scodoc import html_sco_header
from app.scodoc import sco_etud
class EtudsArchiver(sco_archives.BaseArchiver):
@ -131,7 +129,7 @@ def etud_upload_file_form(context, REQUEST, etudid):
raise AccessDenied(
"opération non autorisée pour %s" % str(REQUEST.AUTHENTICATED_USER)
)
etud = scolars.get_etud_info(filled=1, REQUEST=REQUEST)[0]
etud = sco_etud.get_etud_info(filled=1, REQUEST=REQUEST)[0]
H = [
html_sco_header.sco_header(
context,
@ -196,7 +194,7 @@ def etud_delete_archive(context, REQUEST, etudid, archive_name, dialog_confirmed
raise AccessDenied(
"opération non autorisée pour %s" % str(REQUEST.AUTHENTICATED_USER)
)
etud = scolars.get_etud_info(filled=1, REQUEST=REQUEST)[0]
etud = sco_etud.get_etud_info(filled=1, REQUEST=REQUEST)[0]
archive_id = EtudsArchive.get_id_from_name(context, etudid, archive_name)
dest_url = "ficheEtud?etudid=%s" % etudid
if not dialog_confirmed:

View File

@ -32,7 +32,7 @@ import time
from types import StringType
import pprint
import urllib
import htmlutils
from app.scodoc import htmlutils
import email
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
@ -41,27 +41,38 @@ from email.header import Header
from reportlab.lib.colors import Color
import mails
import sco_utils as scu
import notesdb as ndb
from notes_log import log
from sco_permissions import Permission
from sco_exceptions import AccessDenied
import sco_abs
import sco_abs_views
import sco_bulletins_generator
import sco_bulletins_json
import sco_bulletins_xml
import sco_codes_parcours
import sco_core
import sco_formations
import sco_formsemestre
import sco_formsemestre_status
import sco_groups
import sco_photos
import sco_preferences
import sco_pvjury
import scolars
from app.scodoc import mails
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from app.scodoc.notes_log import log
from app.scodoc.sco_permissions import Permission
from app.scodoc.sco_exceptions import AccessDenied
from app.scodoc import html_sco_header
from app.scodoc import sco_abs_views
from app.scodoc import sco_bulletins_generator
from app.scodoc import sco_bulletins_json
from app.scodoc import sco_bulletins_xml
from app.scodoc import sco_codes_parcours
from app.scodoc import sco_core
from app.scodoc import sco_evaluations
from app.scodoc import sco_formations
from app.scodoc import sco_formsemestre
from app.scodoc import sco_groups
from app.scodoc import sco_photos
from app.scodoc import sco_permissions_check
from app.scodoc import sco_preferences
from app.scodoc import sco_pvjury
from app.scodoc import sco_etud
# ----- CLASSES DE BULLETINS DE NOTES
import sco_bulletins_standard
import sco_bulletins_legacy
# import sco_bulletins_example # format exemple (à désactiver en production)
# ... ajouter ici vos modules ...
import sco_bulletins_ucac # format expérimental UCAC Cameroun
def make_context_dict(context, sem, etud):
@ -85,7 +96,8 @@ def make_context_dict(context, sem, etud):
C["anneesem"] = annee
C.update(etud)
# copie preferences
for name in sco_preferences.PREFS_NAMES:
# XXX devrait acceder directement à un dict de preferences, à revoir
for name in sco_preferences.get_base_preferences(context).prefs_name:
C[name] = sco_preferences.get_preference(context, name, sem["formsemestre_id"])
# ajoute groupes et group_0, group_1, ...
@ -114,6 +126,8 @@ def formsemestre_bulletinetud_dict(
Cette fonction est utilisée pour les bulletins HTML et PDF, mais pas ceux en XML.
"""
from app.scodoc import sco_abs
if not version in ("short", "long", "selectedevals"):
raise ValueError("invalid version code !")
@ -139,7 +153,7 @@ def formsemestre_bulletinetud_dict(
I["formation"]["type_parcours"]
)
# Infos sur l'etudiant
I["etud"] = scolars.get_etud_info(etudid=etudid, filled=1)[0]
I["etud"] = sco_etud.get_etud_info(etudid=etudid, filled=1)[0]
I["descr_situation"] = I["etud"]["inscriptionstr"]
if I["etud"]["inscription_formsemestre_id"]:
I[
@ -200,7 +214,7 @@ def formsemestre_bulletinetud_dict(
# --- Appreciations
cnx = ndb.GetDBConnexion()
apprecs = scolars.appreciations_list(
apprecs = sco_etud.appreciations_list(
cnx, args={"etudid": etudid, "formsemestre_id": formsemestre_id}
)
I["appreciations_list"] = apprecs
@ -427,13 +441,15 @@ def _ue_mod_bulletin(context, etudid, formsemestre_id, ue_id, modimpls, nt, vers
is_malus = mod["module"]["module_type"] == scu.MODULE_MALUS
if bul_show_abs_modules:
mod_abs = [
context.Absences.CountAbs(
sco_abs.CountAbs(
context,
etudid=etudid,
debut=debut_sem,
fin=fin_sem,
moduleimpl_id=modimpl["moduleimpl_id"],
),
context.Absences.CountAbsJust(
sco_abs.CountAbsJust(
context,
etudid=etudid,
debut=debut_sem,
fin=fin_sem,
@ -662,7 +678,7 @@ def etud_descr_situation_semestre(
# --- Situation et décisions jury
# demission/inscription ?
events = scolars.scolar_events_list(
events = sco_etud.scolar_events_list(
cnx, args={"etudid": etudid, "formsemestre_id": formsemestre_id}
)
date_inscr = None
@ -680,7 +696,7 @@ def etud_descr_situation_semestre(
"etud_descr_situation_semestre: removing duplicate INSCRIPTION event for etudid=%s !"
% etudid
)
scolars.scolar_events_delete(cnx, event["event_id"])
sco_etud.scolar_events_delete(cnx, event["event_id"])
else:
date_inscr = event["event_date"]
elif event_type == "DEMISSION":
@ -690,7 +706,7 @@ def etud_descr_situation_semestre(
"etud_descr_situation_semestre: removing duplicate DEMISSION event for etudid=%s !"
% etudid
)
scolars.scolar_events_delete(cnx, event["event_id"])
sco_etud.scolar_events_delete(cnx, event["event_id"])
else:
date_dem = event["event_date"]
elif event_type == "DEFAILLANCE":
@ -699,7 +715,7 @@ def etud_descr_situation_semestre(
"etud_descr_situation_semestre: removing duplicate DEFAILLANCE event for etudid=%s !"
% etudid
)
scolars.scolar_events_delete(cnx, event["event_id"])
sco_etud.scolar_events_delete(cnx, event["event_id"])
else:
date_def = event["event_date"]
if show_date_inscr:
@ -781,7 +797,7 @@ def formsemestre_bulletinetud(
):
"page bulletin de notes"
try:
etud = scolars.get_etud_info(filled=1, REQUEST=REQUEST)[0]
etud = sco_etud.get_etud_info(filled=1, REQUEST=REQUEST)[0]
etudid = etud["etudid"]
except:
return scu.log_unknown_etud(context, REQUEST, format=format)
@ -1092,6 +1108,7 @@ def _formsemestre_bulletinetud_header_html(
H.append("""</select></td>""")
# Menu
endpoint = "notes.formsemestre_bulletinetud"
url = REQUEST.URL0
qurl = urllib.quote_plus(url + "?" + REQUEST.QUERY_STRING)
menuBul = [
@ -1182,7 +1199,7 @@ def _formsemestre_bulletinetud_header_html(
"formsemestre_id": formsemestre_id,
"etudid": etudid,
},
"enabled": sco_permcan_validate_semdate_sem(
"enabled": sco_permissions_check.can_validate_sem(
context, REQUEST, formsemestre_id
),
},
@ -1193,7 +1210,7 @@ def _formsemestre_bulletinetud_header_html(
"formsemestre_id": formsemestre_id,
"etudid": etudid,
},
"enabled": sco_permcan_validate_semdate_sem(
"enabled": sco_permissions_check.can_validate_sem(
context, REQUEST, formsemestre_id
),
},
@ -1204,7 +1221,7 @@ def _formsemestre_bulletinetud_header_html(
"formsemestre_id": formsemestre_id,
"etudid": etudid,
},
"enabled": sco_permcan_validate_semdate_sem(
"enabled": sco_permissions_check.can_validate_sem(
context, REQUEST, formsemestre_id
),
},

View File

@ -27,16 +27,12 @@
"""Generation bulletins de notes: exemple minimal pour les programmeurs
"""
import VERSION
import sco_utils as scu
import sco_pdf
import sco_preferences
from notes_log import log
import sco_bulletins_generator
import sco_bulletins_standard
from reportlab.platypus import Paragraph
from app.scodoc import sco_pdf
from app.scodoc import sco_bulletins_generator
from app.scodoc import sco_bulletins_standard
class BulletinGeneratorExample(sco_bulletins_standard.BulletinGeneratorStandard):
"""Un exemple simple de bulletin de notes en version PDF seulement.

View File

@ -50,18 +50,16 @@ import reportlab
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Frame, PageBreak
from reportlab.platypus import Table, TableStyle, Image, KeepInFrame
import sco_utils
import VERSION
from sco_exceptions import NoteProcessError
import sco_preferences
from notes_log import log
import sco_formsemestre
import sco_pdf
from sco_pdf import PDFLOCK
from app.scodoc import sco_utils
from app.scodoc import VERSION
from app.scodoc.sco_exceptions import NoteProcessError
from app.scodoc.notes_log import log
from app.scodoc import sco_formsemestre
from app.scodoc import sco_pdf
from app.scodoc.sco_pdf import PDFLOCK
BULLETIN_CLASSES = (
collections.OrderedDict()
) # liste des types des classes de générateurs de bulletins PDF
# Liste des types des classes de générateurs de bulletins PDF:
BULLETIN_CLASSES = collections.OrderedDict()
def register_bulletin_class(klass):
@ -87,6 +85,8 @@ def bulletin_get_class(class_name):
def bulletin_get_class_name_displayed(context, formsemestre_id):
"""Le nom du générateur utilisé, en clair"""
from app.scodoc import sco_preferences
bul_class_name = sco_preferences.get_preference(
context, "bul_class_name", formsemestre_id
)
@ -113,6 +113,8 @@ class BulletinGenerator:
filigranne=None,
server_name=None,
):
from app.scodoc import sco_preferences
if not version in ("short", "long", "selectedevals"):
raise ValueError("invalid version code !")
self.context = context
@ -191,6 +193,8 @@ class BulletinGenerator:
Sinon, renvoie juste une liste d'objets PLATYPUS pour intégration
dans un autre document.
"""
from app.scodoc import sco_preferences
formsemestre_id = self.infos["formsemestre_id"]
# partie haute du bulletin
@ -273,6 +277,8 @@ def make_formsemestre_bulletinetud(
selon les préférences du semestre.
"""
from app.scodoc import sco_preferences
if not version in ("short", "long", "selectedevals"):
raise ValueError("invalid version code !")
@ -325,15 +331,3 @@ def make_formsemestre_bulletinetud(
filename = bul_generator.get_filename()
return data, filename
# ---------------------------------------------------------------------------
# Classes de bulletins:
import sco_bulletins_standard
import sco_bulletins_legacy
# import sco_bulletins_example # format exemple (à désactiver en production)
# ... ajouter ici vos modules ...
import sco_bulletins_ucac # format expérimental UCAC Cameroun

View File

@ -31,18 +31,17 @@
import datetime
import json
import sco_utils as scu
import notesdb as ndb
import sco_abs
import sco_bulletins
import sco_core
import sco_edit_ue
import sco_evaluations
import sco_formsemestre
import sco_groups
import sco_photos
import sco_preferences
import scolars
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from app.scodoc import sco_abs
from app.scodoc import sco_core
from app.scodoc import sco_edit_ue
from app.scodoc import sco_evaluations
from app.scodoc import sco_formsemestre
from app.scodoc import sco_groups
from app.scodoc import sco_photos
from app.scodoc import sco_preferences
from app.scodoc import sco_etud
# -------- Bulletin en JSON
@ -90,6 +89,7 @@ def formsemestre_bulletinetud_published_dict(
"""Dictionnaire representant les informations _publiees_ du bulletin de notes
Utilisé pour JSON, devrait l'être aussi pour XML. (todo)
"""
from app.scodoc import sco_bulletins
d = {}
@ -120,7 +120,7 @@ def formsemestre_bulletinetud_published_dict(
d.update(**el)
# Infos sur l'etudiant
etudinfo = scolars.get_etud_info(etudid=etudid, filled=1)[0]
etudinfo = sco_etud.get_etud_info(etudid=etudid, filled=1)[0]
d["etudiant"] = dict(
etudid=etudid,
@ -405,7 +405,7 @@ def formsemestre_bulletinetud_published_dict(
# --- Appreciations
cnx = ndb.GetDBConnexion()
apprecs = scolars.appreciations_list(
apprecs = sco_etud.appreciations_list(
cnx, args={"etudid": etudid, "formsemestre_id": formsemestre_id}
)
d["appreciation"] = []

View File

@ -35,17 +35,16 @@
"""
import sco_utils as scu
from sco_permissions import Permission
import sco_formsemestre
import sco_pdf
from sco_pdf import Color, Paragraph, Spacer, Table
from sco_pdf import blue, cm, mm
from sco_pdf import SU
import sco_preferences
from notes_log import log
import sco_bulletins_generator
import sco_bulletins_pdf
import app.scodoc.sco_utils as scu
from app.scodoc.sco_permissions import Permission
from app.scodoc import sco_formsemestre
from app.scodoc import sco_pdf
from app.scodoc.sco_pdf import Color, Paragraph, Spacer, Table
from app.scodoc.sco_pdf import blue, cm, mm
from app.scodoc.sco_pdf import SU
from app.scodoc import sco_preferences
from app.scodoc import sco_bulletins_generator
from app.scodoc import sco_bulletins_pdf
# Important: Le nom de la classe ne doit pas changer (bien le choisir), car il sera stocké en base de données (dans les préférences)
class BulletinGeneratorLegacy(sco_bulletins_generator.BulletinGenerator):
@ -320,7 +319,7 @@ class BulletinGeneratorLegacy(sco_bulletins_generator.BulletinGenerator):
# le dir. des etud peut ajouter des appreciations,
# mais aussi le chef (perm. ScoEtudInscrit)
can_edit_app = (str(authuser) in self.infos["responsables"]) or (
authuser.has_permission(Permission.ScoEtudInscrit, self.context)
authuser.has_permission(Permission.ScoEtudInscrit)
)
H.append('<div class="bull_appreciations">')
if I["appreciations_list"]:

View File

@ -50,24 +50,22 @@ Pour définir un nouveau type de bulletin:
Chaque semestre peut si nécessaire utiliser un type de bulletin différent.
"""
import htmlutils
import time
import pprint
import traceback
import re
import os
import cStringIO
from reportlab.platypus.doctemplate import PageTemplate, BaseDocTemplate
import VERSION
import sco_utils as scu
from notes_log import log
import sco_bulletins
import sco_core
import sco_formsemestre
import sco_pdf
import sco_preferences
import scolars
from app.scodoc import VERSION
import app.scodoc.sco_utils as scu
from app.scodoc.notes_log import log
from app.scodoc import sco_core
from app.scodoc import sco_formsemestre
from app.scodoc import sco_pdf
from app.scodoc import sco_preferences
from app.scodoc import sco_etud
def pdfassemblebulletins(
@ -167,6 +165,8 @@ def get_formsemestre_bulletins_pdf(
context, formsemestre_id, REQUEST, version="selectedevals"
):
"document pdf et filename"
from app.scodoc import sco_bulletins
cached = sco_core.get_notes_cache(
context,
).get_bulletins_pdf(formsemestre_id, version)
@ -229,7 +229,9 @@ def get_formsemestre_bulletins_pdf(
def get_etud_bulletins_pdf(context, etudid, REQUEST, version="selectedevals"):
"Bulletins pdf de tous les semestres de l'étudiant, et filename"
etud = scolars.get_etud_info(etudid=etudid, filled=1)[0]
from app.scodoc import sco_bulletins
etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0]
fragments = []
bookmarks = {}
filigrannes = {}

View File

@ -46,33 +46,25 @@ de la forme %(XXX)s sont remplacées par la valeur de XXX, pour XXX dans:
Balises img: actuellement interdites.
"""
import datetime
import traceback
import re
import jaxml
import sco_utils as scu
import sco_formsemestre
import sco_pdf
from sco_pdf import Color, Paragraph, Spacer, Table
from sco_pdf import blue, cm, mm
from sco_pdf import SU
import sco_preferences
from notes_log import log
from sco_permissions import Permission
from sco_codes_parcours import (
import app.scodoc.sco_utils as scu
from app.scodoc.sco_pdf import Color, Paragraph, Spacer, Table
from app.scodoc.sco_pdf import blue, cm, mm
from app.scodoc.sco_pdf import SU
from app.scodoc import sco_preferences
from app.scodoc.sco_permissions import Permission
from app.scodoc.sco_codes_parcours import (
UE_COLORS,
UE_DEFAULT_COLOR,
UE_ELECTIVE,
UE_SPORT,
UE_STANDARD,
)
import sco_bulletins_generator
import sco_bulletins_pdf
import sco_groups
import sco_evaluations
import gen_tables
import sco_codes_parcours
from app.scodoc import sco_bulletins_generator
from app.scodoc import sco_bulletins_pdf
from app.scodoc import sco_groups
from app.scodoc import sco_evaluations
from app.scodoc import gen_tables
# Important: Le nom de la classe ne doit pas changer (bien le choisir), car il sera stocké en base de données (dans les préférences)
class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator):
@ -153,7 +145,7 @@ class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator):
# le dir. des etud peut ajouter des appreciations,
# mais aussi le chef (perm. ScoEtudInscrit)
can_edit_app = (str(self.authuser) in self.infos["responsables"]) or (
self.authuser.has_permission(Permission.ScoEtudInscrit, self.context)
self.authuser.has_permission(Permission.ScoEtudInscrit)
)
H.append('<div class="bull_appreciations">')
for app in self.infos["appreciations_list"]:

View File

@ -33,18 +33,15 @@ On redéfini la table centrale du bulletin de note et hérite de tout le reste d
E. Viennet, juillet 2011
"""
import sco_utils as scu
import sco_formsemestre
import sco_pdf
from sco_pdf import blue, cm, mm
from sco_pdf import Color, Paragraph, Spacer, Table
import app.scodoc.sco_utils as scu
from app.scodoc.sco_pdf import blue, cm, mm
from app.scodoc.sco_pdf import Color, Paragraph, Spacer, Table
import sco_preferences
from app.scodoc import sco_preferences
from notes_log import log
import sco_bulletins_generator
import sco_bulletins_standard
import gen_tables
from app.scodoc import sco_bulletins_generator
from app.scodoc import sco_bulletins_standard
from app.scodoc import gen_tables
class BulletinGeneratorUCAC(sco_bulletins_standard.BulletinGeneratorStandard):

View File

@ -40,19 +40,19 @@ Je propose de considérer le XMl comme "deprecated" et de ne plus le modifier, s
import datetime
import jaxml
import sco_utils as scu
import notesdb as ndb
from notes_log import log
import sco_abs
import sco_bulletins
import sco_codes_parcours
import sco_core
import sco_evaluations
import sco_formsemestre
import sco_groups
import sco_photos
import sco_preferences
import scolars
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from app.scodoc.notes_log import log
from app.scodoc import sco_abs
from app.scodoc import sco_codes_parcours
from app.scodoc import sco_core
from app.scodoc import sco_edit_ue
from app.scodoc import sco_evaluations
from app.scodoc import sco_formsemestre
from app.scodoc import sco_groups
from app.scodoc import sco_photos
from app.scodoc import sco_preferences
from app.scodoc import sco_etud
# -------- Bulletin en XML
# (fonction séparée: n'utilise pas formsemestre_bulletinetud_dict()
@ -70,6 +70,8 @@ def make_xml_formsemestre_bulletinetud(
version="long",
):
"bulletin au format XML"
from app.scodoc import sco_bulletins
log("xml_bulletin( formsemestre_id=%s, etudid=%s )" % (formsemestre_id, etudid))
if REQUEST:
REQUEST.RESPONSE.setHeader("content-type", scu.XML_MIMETYPE)
@ -102,7 +104,7 @@ def make_xml_formsemestre_bulletinetud(
doc.bulletinetud(**el)
# Infos sur l'etudiant
etudinfo = scolars.get_etud_info(etudid=etudid, filled=1)[0]
etudinfo = sco_etud.get_etud_info(etudid=etudid, filled=1)[0]
doc._push()
doc.etudiant(
etudid=etudid,
@ -416,7 +418,7 @@ def make_xml_formsemestre_bulletinetud(
doc._pop()
# --- Appreciations
cnx = ndb.GetDBConnexion()
apprecs = scolars.appreciations_list(
apprecs = sco_etud.appreciations_list(
cnx, args={"etudid": etudid, "formsemestre_id": formsemestre_id}
)
for app in apprecs:

View File

@ -29,8 +29,7 @@
"""
from notes_log import log
import thread, time
import time
# Cache data
class simpleCache:

View File

@ -32,26 +32,24 @@ import traceback
import pprint
from types import FloatType
import sco_utils as scu
import notesdb as ndb
from sco_utils import (
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from app.scodoc.sco_utils import (
NOTES_ATTENTE,
NOTES_NEUTRALISE,
EVALUATION_NORMALE,
EVALUATION_RATTRAPAGE,
EVALUATION_SESSION2,
)
from sco_exceptions import ScoException
from notesdb import EditableTable, quote_html
from notes_log import log, sendAlarm
import sco_abs
import sco_edit_module
import sco_evaluations
import sco_formsemestre
import sco_formulas
import sco_groups
import sco_moduleimpl
import scolars
from app.scodoc.sco_exceptions import ScoException
from app.scodoc.notes_log import log
from app.scodoc import sco_abs
from app.scodoc import sco_edit_module
from app.scodoc import sco_evaluations
from app.scodoc import sco_formsemestre
from app.scodoc import sco_formulas
from app.scodoc import sco_moduleimpl
from app.scodoc import sco_etud
def moduleimpl_has_expression(context, mod):
@ -89,7 +87,7 @@ def formsemestre_expressions_use_abscounts(context, formsemestre_id):
return False
_formsemestre_ue_computation_exprEditor = EditableTable(
_formsemestre_ue_computation_exprEditor = ndb.EditableTable(
"notes_formsemestre_ue_computation_expr",
"notes_formsemestre_ue_computation_expr_id",
(
@ -117,7 +115,7 @@ def get_ue_expression(formsemestre_id, ue_id, cnx, html_quote=False):
expr = el[0]["computation_expr"].strip()
if expr and expr[0] != "#":
if html_quote:
expr = quote_html(expr)
expr = ndb.quote_html(expr)
return expr
else:
return None
@ -169,7 +167,7 @@ def compute_user_formula(
if user_moy != "NA0" and user_moy != "NA":
user_moy = float(user_moy)
if (user_moy > 20) or (user_moy < 0):
etud = scolars.get_etud_info(etudid=etudid, filled=1)[0]
etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0]
raise ScoException(
"""valeur moyenne %s hors limite pour <a href="formsemestre_bulletinetud?formsemestre_id=%s&etudid=%s">%s</a>"""
@ -231,8 +229,8 @@ def do_moduleimpl_moyennes(context, nt, mod):
eval_rattr = None
for e in evals:
e["nb_inscrits"] = e["etat"]["nb_inscrits"]
NotesDB = context._notes_getall(
e["evaluation_id"]
NotesDB = sco_evaluations.do_evaluation_get_all_notes(
context, e["evaluation_id"]
) # toutes, y compris demissions
# restreint aux étudiants encore inscrits à ce module
notes = [

View File

@ -7,7 +7,7 @@
"""
from attrdict import AttrDict
import bonus_sport
from app.scodoc import bonus_sport
CONFIG = AttrDict()

View File

@ -6,8 +6,8 @@
import os
import sys
from notes_log import log
import sco_config
from app.scodoc.notes_log import log
from app.scodoc import sco_config
# scodoc_local defines a CONFIG object
# here we check if there is a local config file

View File

@ -6,35 +6,12 @@
import time
import thread
import types
from flask import url_for
import sco_utils as scu
from notes_log import log
from scodoc_manager import sco_mgr
from sco_exceptions import ScoInvalidDept, NoteProcessError
from sco_parcours_dut import list_formsemestre_utilisateurs_uecap
import sco_cache
import sco_core
def sco_get_version(context, REQUEST=None):
"""Une fonction typique de ScoDoc7"""
return """<html><body><p>%s</p></body></html>""" % scu.SCOVERSION
# def test_refactor(context, x=1):
# x = context.toto()
# y = ("context=" + sco_edit_module.module_is_locked(context, "alpha")) + "23"
# z = html_sco_header.sco_header(
# context,
# a_long_argument_hahahahaha=1,
# another_very_long_arggggggggggggg=2,
# z=6,
# u=99,
# kkkkkk=1,
# )
import app.scodoc.sco_utils as scu
from app.scodoc.notes_log import log
from app.scodoc.sco_exceptions import NoteProcessError
from app.scodoc import sco_cache
#
@ -134,6 +111,8 @@ class CacheNotesTable:
def inval_cache(self, context, formsemestre_id=None, pdfonly=False): # >
"expire cache pour un semestre (ou tous si pas d'argument)"
from app.scodoc import sco_parcours_dut
log(
"inval_cache, formsemestre_id=%s pdfonly=%s (id=%s)"
% (formsemestre_id, pdfonly, id(self)) # >
@ -151,14 +130,16 @@ class CacheNotesTable:
self.cache = {}
self.pdfcache = {}
self._call_all_listeners()
sco_core.get_evaluations_cache(
get_evaluations_cache(
context,
).inval_cache()
else:
# formsemestre_id modifié:
# on doit virer formsemestre_id et tous les semestres
# susceptibles d'utiliser des UE capitalisées de ce semestre.
to_trash = [formsemestre_id] + list_formsemestre_utilisateurs_uecap(
to_trash = [
formsemestre_id
] + sco_parcours_dut.list_formsemestre_utilisateurs_uecap(
context, formsemestre_id
)
if not pdfonly:
@ -170,7 +151,7 @@ class CacheNotesTable:
)
del self.cache[formsemestre_id]
self._call_listeners(formsemestre_id)
sco_core.get_evaluations_cache(
get_evaluations_cache(
context,
).inval_cache()

View File

@ -30,16 +30,13 @@
(coût théorique en heures équivalent TD)
"""
import notesdb as ndb
import sco_utils as scu
from notes_log import log
from gen_tables import GenTable
import sco_excel, sco_pdf
from sco_pdf import SU
import sco_formsemestre
import sco_moduleimpl
import sco_formsemestre_status
import VERSION
import app.scodoc.sco_utils as scu
from app.scodoc.gen_tables import GenTable
from app.scodoc import sco_formsemestre
from app.scodoc import sco_moduleimpl
from app.scodoc import sco_formsemestre_status
from app.scodoc import VERSION
from app.scodoc import sco_preferences
def formsemestre_table_estim_cost(

View File

@ -31,16 +31,19 @@ Rapport (table) avec dernier semestre fréquenté et débouché de chaque étudi
from types import StringType
import safehtml
import sco_utils as scu
import notesdb as ndb
from notes_log import log
import VERSION
from sco_exceptions import AccessDenied
from scolog import logdb
from gen_tables import GenTable
import sco_formsemestre
import sco_groups
import sco_tag_module
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from app.scodoc.notes_log import log
from app.scodoc import VERSION
from app.scodoc.sco_exceptions import AccessDenied
from app.scodoc.scolog import logdb
from app.scodoc.gen_tables import GenTable
from app.scodoc import html_sco_header
from app.scodoc import sco_core
from app.scodoc import sco_permissions_check
from app.scodoc import sco_preferences
from app.scodoc import sco_tag_module
from app.scodoc import sco_etud
def report_debouche_date(context, start_year=None, format="html", REQUEST=None):
@ -104,7 +107,7 @@ def table_debouche_etudids(context, etudids, keep_numeric=True):
"""Rapport pour ces etudiants"""
L = []
for etudid in etudids:
etud = scolars.get_etud_info(filled=1, etudid=etudid)[0]
etud = sco_etud.get_etud_info(filled=1, etudid=etudid)[0]
# retrouve le "dernier" semestre (au sens de la date de fin)
sems = etud["sems"]
es = [(sems[i]["date_fin_iso"], i) for i in range(len(sems))]
@ -211,12 +214,12 @@ def report_debouche_ask_date(context, REQUEST=None):
# def debouche_set(context, object, value, REQUEST=None):
# """Set debouche (field in admission table, may be deprecated ?)
# """
# if not sco_permissions.can_edit_suivi(context, REQUEST):
# if not sco_permissions_check.can_edit_suivi(context, REQUEST):
# raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
# adm_id = object
# debouche = value.strip('-_ \t')
# cnx = ndb.GetDBConnexion()
# adms = scolars.admission_list(cnx, {'etudid' : etudid})
# adms = sco_etud.admission_list(cnx, {'etudid' : etudid})
# if not adms:
# raise ValueError('no admission info for %s !' % etudid)
# adm = adms[0]
@ -263,7 +266,7 @@ def itemsuivi_get(cnx, itemsuivi_id, ignore_errors=False):
def itemsuivi_suppress(context, itemsuivi_id, REQUEST=None):
"""Suppression d'un item"""
if not sco_permissions.can_edit_suivi(context, REQUEST):
if not sco_permissions_check.can_edit_suivi(context, REQUEST):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
cnx = ndb.GetDBConnexion()
item = itemsuivi_get(cnx, itemsuivi_id, ignore_errors=True)
@ -277,7 +280,7 @@ def itemsuivi_create(
context, etudid, item_date=None, situation="", REQUEST=None, format=None
):
"""Creation d'un item"""
if not sco_permissions.can_edit_suivi(context, REQUEST):
if not sco_permissions_check.can_edit_suivi(context, REQUEST):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
cnx = ndb.GetDBConnexion()
itemsuivi_id = _itemsuivi_create(
@ -295,7 +298,7 @@ def itemsuivi_set_date(context, itemsuivi_id, item_date, REQUEST=None):
"""set item date
item_date is a string dd/mm/yyyy
"""
if not sco_permissions.can_edit_suivi(context, REQUEST):
if not sco_permissions_check.can_edit_suivi(context, REQUEST):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
# log('itemsuivi_set_date %s : %s' % (itemsuivi_id, item_date))
cnx = ndb.GetDBConnexion()
@ -306,7 +309,7 @@ def itemsuivi_set_date(context, itemsuivi_id, item_date, REQUEST=None):
def itemsuivi_set_situation(context, object, value, REQUEST=None):
"""set situation"""
if not sco_permissions.can_edit_suivi(context, REQUEST):
if not sco_permissions_check.can_edit_suivi(context, REQUEST):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
itemsuivi_id = object
situation = value.strip("-_ \t")
@ -364,7 +367,7 @@ def itemsuivi_tag_set(context, itemsuivi_id="", taglist=[], REQUEST=None):
a string with tag names separated by commas ("un;deux")
or a list of strings (["un", "deux"])
"""
if not sco_permissions.can_edit_suivi(context, REQUEST):
if not sco_permissions_check.can_edit_suivi(context, REQUEST):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
if not taglist:
taglist = []

View File

@ -27,17 +27,16 @@
"""Page accueil département (liste des semestres, etc)
"""
import notesdb as ndb
import sco_utils as scu
from notes_log import log
import sco_modalites
import sco_news
import sco_up_to_date
import sco_formsemestre
from gen_tables import GenTable
from sco_permissions import Permission, ScoEtudInscrit, ScoEditApo
import html_sco_header
import sco_formsemestre_inscriptions
import app.scodoc.sco_utils as scu
from app.scodoc.gen_tables import GenTable
from app.scodoc.sco_permissions import Permission
from app.scodoc import html_sco_header
from app.scodoc import sco_formsemestre
from app.scodoc import sco_formsemestre_inscriptions
from app.scodoc import sco_modalites
from app.scodoc import sco_news
from app.scodoc import sco_preferences
from app.scodoc import sco_up_to_date
def index_html(context, REQUEST=None, showcodes=0, showsemtable=0):

View File

@ -51,22 +51,23 @@ import fcntl
import subprocess
import requests
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email.header import Header
import notesdb as ndb
import sco_utils as scu
from notes_log import log
from sco_exceptions import ScoValueError
import app.scodoc.notesdb as ndb
import app.scodoc.sco_utils as scu
from app.scodoc.notes_log import log
from app.scodoc import html_sco_header
from app.scodoc import sco_preferences
from app.scodoc import VERSION
from app.scodoc.sco_exceptions import ScoValueError
SCO_DUMP_LOCK = "/tmp/scodump.lock"
def sco_dump_and_send_db(context, REQUEST=None):
"""Dump base de données du département courant et l'envoie anonymisée pour debug"""
H = [html_sco_header.sco_header(context, REQUEST, page_title="Assistance technique")]
H = [
html_sco_header.sco_header(context, REQUEST, page_title="Assistance technique")
]
# get currect (dept) DB name:
cursor = ndb.SimpleQuery(context, "SELECT current_database()", {})
db_name = cursor.fetchone()[0]
@ -194,7 +195,7 @@ def _send_db(context, REQUEST, ano_db_name):
"sent_by": context.Users.user_info(str(REQUEST.AUTHENTICATED_USER))[
"nomcomplet"
],
"sco_version": scu.SCOVERSION,
"sco_version": VERSION.SCOVERSION,
"sco_fullversion": scu.get_scodoc_version(),
},
)

View File

@ -28,16 +28,19 @@
"""Ajout/Modification/Supression formations
(portage from DTML)
"""
import notesdb as ndb
import sco_utils as scu
from notes_log import log
from TrivialFormulator import TrivialFormulator, TF, tf_error_message
import sco_codes_parcours
import sco_edit_module
import sco_edit_ue
import sco_formsemestre
from sco_exceptions import ScoValueError
import sco_formations
import app.scodoc.notesdb as ndb
import app.scodoc.sco_utils as scu
from app.scodoc.notes_log import log
from app.scodoc.TrivialFormulator import TrivialFormulator, tf_error_message
from app.scodoc.sco_exceptions import ScoValueError, ScoLockedFormError
from app.scodoc import html_sco_header
from app.scodoc import sco_codes_parcours
from app.scodoc import sco_core
from app.scodoc import sco_edit_module
from app.scodoc import sco_edit_ue
from app.scodoc import sco_formations
from app.scodoc import sco_formsemestre
from app.scodoc import sco_news
def formation_delete(context, formation_id=None, dialog_confirmed=False, REQUEST=None):
@ -105,7 +108,7 @@ def do_formation_delete(context, oid, REQUEST):
# delete all UE in this formation
ues = sco_edit_ue.do_ue_list(context, {"formation_id": oid})
for ue in ues:
do_ue_delete(ue["ue_id"], REQUEST=REQUEST, force=True)
sco_edit_ue.do_ue_delete(context, ue["ue_id"], REQUEST=REQUEST, force=True)
sco_formations._formationEditor.delete(cnx, oid)
@ -113,7 +116,7 @@ def do_formation_delete(context, oid, REQUEST):
sco_news.add(
context,
REQUEST,
typ=NEWS_FORM,
typ=sco_news.NEWS_FORM,
object=oid,
text="Suppression de la formation %(acronyme)s" % F,
)
@ -277,7 +280,7 @@ def do_formation_create(context, args, REQUEST):
sco_news.add(
context,
REQUEST,
typ=NEWS_FORM,
typ=sco_news.NEWS_FORM,
text="Création de la formation %(titre)s (%(acronyme)s)" % args,
)
return r

View File

@ -28,14 +28,13 @@
"""Ajout/Modification/Supression matieres
(portage from DTML)
"""
import notesdb as ndb
import sco_utils as scu
from notes_log import log
from TrivialFormulator import TrivialFormulator, TF, tf_error_message
import sco_edit_ue
import sco_formsemestre
import sco_news
from sco_exceptions import ScoValueError
import app.scodoc.notesdb as ndb
import app.scodoc.sco_utils as scu
from app.scodoc.notes_log import log
from app.scodoc.TrivialFormulator import TrivialFormulator, tf_error_message
from app.scodoc.sco_exceptions import ScoValueError, ScoLockedFormError
from app.scodoc import html_sco_header
from app.scodoc import sco_core
_matiereEditor = ndb.EditableTable(
"notes_matieres",
@ -56,10 +55,8 @@ def do_matiere_edit(context, *args, **kw):
"edit a matiere"
cnx = ndb.GetDBConnexion()
# check
mat = sco_edit_matiere.do_matiere_list(
context, {"matiere_id": args[0]["matiere_id"]}
)[0]
if sco_edit_matiere.matiere_is_locked(context, mat["matiere_id"]):
mat = do_matiere_list(context, {"matiere_id": args[0]["matiere_id"]})[0]
if matiere_is_locked(context, mat["matiere_id"]):
raise ScoLockedFormError()
# edit
_matiereEditor.edit(cnx, *args, **kw)
@ -68,6 +65,10 @@ def do_matiere_edit(context, *args, **kw):
def do_matiere_create(context, args, REQUEST):
"create a matiere"
from app.scodoc import sco_edit_ue
from app.scodoc import sco_formations
from app.scodoc import sco_news
cnx = ndb.GetDBConnexion()
# check
ue = sco_edit_ue.do_ue_list(context, {"ue_id": args["ue_id"]})[0]
@ -81,7 +82,7 @@ def do_matiere_create(context, args, REQUEST):
sco_news.add(
context,
REQUEST,
typ=NEWS_FORM,
typ=sco_news.NEWS_FORM,
object=ue["formation_id"],
text="Modification de la formation %(acronyme)s" % F,
)
@ -90,6 +91,8 @@ def do_matiere_create(context, args, REQUEST):
def matiere_create(context, ue_id=None, REQUEST=None):
"""Creation d'une matiere"""
from app.scodoc import sco_edit_ue
UE = sco_edit_ue.do_ue_list(context, args={"ue_id": ue_id})[0]
H = [
html_sco_header.sco_header(
@ -151,11 +154,16 @@ associé.
def do_matiere_delete(context, oid, REQUEST):
"delete matiere and attached modules"
from app.scodoc import sco_formations
from app.scodoc import sco_edit_ue
from app.scodoc import sco_edit_module
from app.scodoc import sco_news
cnx = ndb.GetDBConnexion()
# check
mat = do_matiere_list(context, {"matiere_id": oid})[0]
ue = sco_edit_ue.do_ue_list(context, {"ue_id": mat["ue_id"]})[0]
locked = sco_edit_matiere.matiere_is_locked(context, mat["matiere_id"])
locked = matiere_is_locked(context, mat["matiere_id"])
if locked:
log("do_matiere_delete: mat=%s" % mat)
log("do_matiere_delete: ue=%s" % ue)
@ -175,7 +183,7 @@ def do_matiere_delete(context, oid, REQUEST):
sco_news.add(
context,
REQUEST,
typ=NEWS_FORM,
typ=sco_news.NEWS_FORM,
object=ue["formation_id"],
text="Modification de la formation %(acronyme)s" % F,
)
@ -183,6 +191,8 @@ def do_matiere_delete(context, oid, REQUEST):
def matiere_delete(context, matiere_id=None, REQUEST=None):
"""Delete an UE"""
from app.scodoc import sco_edit_ue
M = do_matiere_list(context, args={"matiere_id": matiere_id})[0]
UE = sco_edit_ue.do_ue_list(context, args={"ue_id": M["ue_id"]})[0]
H = [
@ -212,6 +222,9 @@ def matiere_delete(context, matiere_id=None, REQUEST=None):
def matiere_edit(context, matiere_id=None, REQUEST=None):
"""Edit matiere"""
from app.scodoc import sco_formations
from app.scodoc import sco_edit_ue
F = do_matiere_list(context, args={"matiere_id": matiere_id})
if not F:
raise ScoValueError("Matière inexistante !")

View File

@ -25,19 +25,22 @@
#
##############################################################################
"""Ajout/Modification/Supression modules
"""Ajout/Modification/Suppression modules
(portage from DTML)
"""
import notesdb as ndb
import sco_utils as scu
from notes_log import log
import sco_codes_parcours
from TrivialFormulator import TrivialFormulator, TF
import sco_formsemestre
import sco_edit_ue
import sco_tag_module
from sco_permissions import ScoChangeFormation
from sco_exceptions import ScoValueError
import app.scodoc.notesdb as ndb
import app.scodoc.sco_utils as scu
from app.scodoc.notes_log import log
from app.scodoc.TrivialFormulator import TrivialFormulator
from app.scodoc.sco_permissions import Permission
from app.scodoc.sco_exceptions import ScoValueError, ScoLockedFormError, ScoGenError
from app.scodoc import html_sco_header
from app.scodoc import sco_codes_parcours
from app.scodoc import sco_core
from app.scodoc import sco_edit_matiere
from app.scodoc import sco_formsemestre
from app.scodoc import sco_moduleimpl
from app.scodoc import sco_news
_MODULE_HELP = """<p class="help">
Les modules sont décrits dans le programme pédagogique. Un module est pour ce
@ -98,6 +101,8 @@ def do_module_list(context, *args, **kw):
def do_module_create(context, args, REQUEST):
"create a module"
# create
from app.scodoc import sco_formations
cnx = ndb.GetDBConnexion()
r = _moduleEditor.create(cnx, args)
@ -108,7 +113,7 @@ def do_module_create(context, args, REQUEST):
sco_news.add(
context,
REQUEST,
typ=NEWS_FORM,
typ=sco_news.NEWS_FORM,
object=args["formation_id"],
text="Modification de la formation %(acronyme)s" % F,
)
@ -117,6 +122,9 @@ def do_module_create(context, args, REQUEST):
def module_create(context, matiere_id=None, REQUEST=None):
"""Creation d'un module"""
from app.scodoc import sco_formations
from app.scodoc import sco_edit_ue
if not matiere_id:
raise ScoValueError("invalid matiere !")
M = sco_edit_matiere.do_matiere_list(context, args={"matiere_id": matiere_id})[0]
@ -241,8 +249,10 @@ def module_create(context, matiere_id=None, REQUEST=None):
def do_module_delete(context, oid, REQUEST):
"delete module"
from app.scodoc import sco_formations
mod = do_module_list(context, {"module_id": oid})[0]
if sco_edit_module.module_is_locked(context, mod["module_id"]):
if module_is_locked(context, mod["module_id"]):
raise ScoLockedFormError()
# S'il y a des moduleimpls, on ne peut pas detruire le module !
@ -268,7 +278,7 @@ def do_module_delete(context, oid, REQUEST):
sco_news.add(
context,
REQUEST,
typ=NEWS_FORM,
typ=sco_news.NEWS_FORM,
object=mod["formation_id"],
text="Modification de la formation %(acronyme)s" % F,
)
@ -341,6 +351,9 @@ def check_module_code_unicity(code, field, formation_id, context, module_id=None
def module_edit(context, module_id=None, REQUEST=None):
"""Edit a module"""
from app.scodoc import sco_formations
from app.scodoc import sco_tag_module
if not module_id:
raise ScoValueError("invalid module !")
Mod = do_module_list(context, args={"module_id": module_id})
@ -532,6 +545,8 @@ def module_list(context, formation_id, REQUEST=None):
"""Liste des modules de la formation
(XXX inutile ou a revoir)
"""
from app.scodoc import sco_formations
if not formation_id:
raise ScoValueError("invalid formation !")
F = sco_formations.formation_list(context, args={"formation_id": formation_id})[0]
@ -581,6 +596,8 @@ def module_count_moduleimpls(context, module_id):
def formation_add_malus_modules(context, formation_id, titre=None, REQUEST=None):
"""Création d'un module de "malus" dans chaque UE d'une formation"""
from app.scodoc import sco_edit_ue
ue_list = sco_edit_ue.do_ue_list(context, args={"formation_id": formation_id})
for ue in ue_list:
@ -601,6 +618,8 @@ def formation_add_malus_modules(context, formation_id, titre=None, REQUEST=None)
def ue_add_malus_module(context, ue_id, titre=None, code=None, REQUEST=None):
"""Add a malus module in this ue"""
from app.scodoc import sco_edit_ue
ue = sco_edit_ue.do_ue_list(context, args={"ue_id": ue_id})[0]
if titre is None:

View File

@ -28,18 +28,27 @@
"""Ajout/Modification/Suppression UE
"""
import notesdb as ndb
import sco_utils as scu
from notes_log import log
from TrivialFormulator import TrivialFormulator, TF
from gen_tables import GenTable
import sco_groups
import sco_formsemestre
import sco_formsemestre_validation
import sco_codes_parcours
import sco_tag_module
from sco_permissions import ScoChangeFormation, ScoEditFormationTags, ScoImplement
from sco_exceptions import ScoValueError, ScoLockedFormError
import app.scodoc.notesdb as ndb
import app.scodoc.sco_utils as scu
from app.scodoc.notes_log import log
from app.scodoc.TrivialFormulator import TrivialFormulator, TF
from app.scodoc.gen_tables import GenTable
from app.scodoc.sco_permissions import Permission
from app.scodoc.sco_exceptions import ScoValueError, ScoLockedFormError
from app.scodoc import html_sco_header
from app.scodoc import sco_codes_parcours
from app.scodoc import sco_core
from app.scodoc import sco_edit_matiere
from app.scodoc import sco_edit_module
from app.scodoc import sco_formsemestre
from app.scodoc import sco_groups
from app.scodoc import sco_moduleimpl
from app.scodoc import sco_news
from app.scodoc import sco_permissions
from app.scodoc import sco_preferences
from app.scodoc import sco_tag_module
from app.scodoc import sco_etud
_ueEditor = ndb.EditableTable(
"notes_ue",
@ -75,6 +84,8 @@ def do_ue_list(context, *args, **kw):
def do_ue_create(context, args, REQUEST):
"create an ue"
from app.scodoc import sco_formations
cnx = ndb.GetDBConnexion()
# check duplicates
ues = do_ue_list(
@ -92,7 +103,7 @@ def do_ue_create(context, args, REQUEST):
sco_news.add(
context,
REQUEST,
typ=NEWS_FORM,
typ=sco_news.NEWS_FORM,
object=args["formation_id"],
text="Modification de la formation %(acronyme)s" % F,
)
@ -100,7 +111,10 @@ def do_ue_create(context, args, REQUEST):
def do_ue_delete(context, ue_id, delete_validations=False, REQUEST=None, force=False):
"delete UE and attached matieres (but not modules (it should ?))"
"delete UE and attached matieres (but not modules)"
from app.scodoc import sco_formations
from app.scodoc import sco_parcours_dut
cnx = ndb.GetDBConnexion()
log("do_ue_delete: ue_id=%s, delete_validations=%s" % (ue_id, delete_validations))
# check
@ -108,7 +122,7 @@ def do_ue_delete(context, ue_id, delete_validations=False, REQUEST=None, force=F
if not ue:
raise ScoValueError("UE inexistante !")
ue = ue[0]
if sco_edit_ue.ue_is_locked(context, ue["ue_id"]):
if ue_is_locked(context, ue["ue_id"]):
raise ScoLockedFormError()
# Il y a-t-il des etudiants ayant validé cette UE ?
# si oui, propose de supprimer les validations
@ -158,7 +172,7 @@ def do_ue_delete(context, ue_id, delete_validations=False, REQUEST=None, force=F
sco_news.add(
context,
REQUEST,
typ=NEWS_FORM,
typ=sco_news.NEWS_FORM,
object=ue["formation_id"],
text="Modification de la formation %(acronyme)s" % F,
)
@ -178,6 +192,8 @@ def ue_create(context, formation_id=None, REQUEST=None):
def ue_edit(context, ue_id=None, create=False, formation_id=None, REQUEST=None):
"""Modification ou creation d'une UE"""
from app.scodoc import sco_formations
create = int(create)
if not create:
U = do_ue_list(context, args={"ue_id": ue_id})
@ -419,6 +435,9 @@ def ue_list(context, formation_id=None, msg="", REQUEST=None):
"""Liste des matières et modules d'une formation, avec liens pour
editer (si non verrouillée).
"""
from app.scodoc import sco_formations
from app.scodoc import sco_formsemestre_validation
authuser = REQUEST.AUTHENTICATED_USER
F = sco_formations.formation_list(context, args={"formation_id": formation_id})
@ -816,6 +835,8 @@ def ue_sharing_code(context, ue_code=None, ue_id=None, hide_ue_id=None):
"""HTML list of UE sharing this code
Either ue_code or ue_id may be specified.
"""
from app.scodoc import sco_formations
if ue_id:
ue = do_ue_list(context, args={"ue_id": ue_id})[0]
if not ue_code:
@ -946,6 +967,8 @@ def ue_is_locked(context, ue_id):
# ---- Table recap formation
def formation_table_recap(context, formation_id, format="html", REQUEST=None):
"""Table recapitulant formation."""
from app.scodoc import sco_formations
F = sco_formations.formation_list(context, args={"formation_id": formation_id})
if not F:
raise ScoValueError("invalid formation_id")

View File

@ -38,11 +38,13 @@ import traceback
import icalendar
import pprint
import sco_utils as scu
from notes_log import log
import sco_formsemestre
import sco_groups
import sco_groups_view
import app.scodoc.sco_utils as scu
from app.scodoc.notes_log import log
from app.scodoc import html_sco_header
from app.scodoc import sco_formsemestre
from app.scodoc import sco_groups
from app.scodoc import sco_groups_view
from app.scodoc import sco_preferences
def formsemestre_get_ics_url(context, sem):
@ -52,7 +54,9 @@ def formsemestre_get_ics_url(context, sem):
Par exemple:
https://example.fr/agenda/{sem[etapes][0]}
"""
ics_url_tmpl = sco_preferences.get_preference(context, "edt_sem_ics_url", sem["formsemestre_id"])
ics_url_tmpl = sco_preferences.get_preference(
context, "edt_sem_ics_url", sem["formsemestre_id"]
)
if not ics_url_tmpl:
return None
try:
@ -163,7 +167,8 @@ def experimental_calendar(context, group_id=None, formsemestre_id=None, REQUEST=
"""experimental page"""
return "\n".join(
[
html_sco_header.sco_header(context,
html_sco_header.sco_header(
context,
REQUEST,
javascripts=[
"libjs/purl.js",

View File

@ -30,8 +30,8 @@
# codes anciens déplacés de ZEntreprise
import datetime
import sco_utils as scu
import notesdb as ndb
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from notesdb import ScoDocCursor, EditableTable, DateISOtoDMY, DateDMYtoISO

View File

@ -77,15 +77,10 @@
import re
import sco_utils as scu
from notes_log import log
import sco_formsemestre
import notes_table
import sco_groups
import sco_groups_view
import sco_archives
import sco_apogee_csv
from sco_exceptions import ScoValueError
import app.scodoc.sco_utils as scu
from app.scodoc import sco_archives
from app.scodoc import sco_apogee_csv
from app.scodoc.sco_exceptions import ScoValueError
class ApoCSVArchiver(sco_archives.BaseArchiver):
@ -365,12 +360,12 @@ def apo_csv_retreive_etuds_by_nip(context, semset, nips):
Tests:
from debug import *
import sco_groups
import sco_groups_view
import sco_formsemestre
from sco_etape_apogee import *
from sco_apogee_csv import *
from sco_semset import *
from app.scodoc import sco_groups
from app.scodoc import sco_groups_view
from app.scodoc import sco_formsemestre
from app.scodoc.sco_etape_apogee import *
from app.scodoc.sco_apogee_csv import *
from app.scodoc.sco_semset import *
context = go_dept(app, 'RT').Notes
csv_data = open('/opt/misc/VDTRT_V1RT.TXT').read()
@ -413,7 +408,7 @@ self=e
col_id='apoL_c0129'
# --
import sco_portal_apogee
from app.scodoc import sco_portal_apogee
context = go_dept(app, 'GEA').Notes
#csv_data = sco_portal_apogee.get_maquette_apogee(context, etape='V1GE', annee_scolaire=2015)
csv_data = open('/tmp/V1GE.txt').read()
@ -424,12 +419,12 @@ apo_data = sco_apogee_csv.ApoData(csv_data, periode=1)
# les elements inconnus:
from debug import *
import sco_groups
import sco_groups_view
import sco_formsemestre
from sco_etape_apogee import *
from sco_apogee_csv import *
from sco_semset import *
from app.scodoc import sco_groups
from app.scodoc import sco_groups_view
from app.scodoc import sco_formsemestre
from app.scodoc.sco_etape_apogee import *
from app.scodoc.sco_apogee_csv import *
from app.scodoc.sco_semset import *
context = go_dept(app, 'RT').Notes
csv_data = open('/opt/misc/V2RT.csv').read()
@ -447,12 +442,12 @@ for e in apo_data.etuds:
# ------
# test export jury intermediaire
from debug import *
import sco_groups
import sco_groups_view
import sco_formsemestre
from sco_etape_apogee import *
from sco_apogee_csv import *
from sco_semset import *
from app.scodoc import sco_groups
from app.scodoc import sco_groups_view
from app.scodoc import sco_formsemestre
from app.scodoc.sco_etape_apogee import *
from app.scodoc.sco_apogee_csv import *
from app.scodoc.sco_semset import *
context = go_dept(app, 'CJ').Notes
csv_data = open('/opt/scodoc/var/scodoc/archives/apo_csv/CJ/2016-1/2017-03-06-21-46-32/V1CJ.csv').read()

View File

@ -31,19 +31,23 @@
from cStringIO import StringIO
from zipfile import ZipFile
import sco_utils as scu
from notes_log import log
import sco_formsemestre
import sco_formsemestre_status
import notes_table
from gen_tables import GenTable
import sco_semset
import sco_etape_apogee
import sco_apogee_csv
import sco_portal_apogee
from sco_apogee_csv import APO_PORTAL_ENCODING, APO_INPUT_ENCODING
import sco_archives
from sco_exceptions import ScoValueError
import app.scodoc.sco_utils as scu
from app.scodoc.notes_log import log
from app.scodoc import html_sco_header
from app.scodoc import notes_table
from app.scodoc import sco_apogee_csv
from app.scodoc import sco_archives
from app.scodoc import sco_etape_apogee
from app.scodoc import sco_formations
from app.scodoc import sco_formsemestre
from app.scodoc import sco_formsemestre_status
from app.scodoc import sco_portal_apogee
from app.scodoc import sco_preferences
from app.scodoc import sco_semset
from app.scodoc import sco_etud
from app.scodoc.gen_tables import GenTable
from app.scodoc.sco_apogee_csv import APO_PORTAL_ENCODING, APO_INPUT_ENCODING
from app.scodoc.sco_exceptions import ScoValueError
def apo_semset_maq_status(
@ -342,7 +346,10 @@ def apo_semset_maq_status(
if missing:
formation_ids = {sem["formation_id"] for sem in semset.sems}
formations = [sco_formations.formation_list(context, formation_id=i)[0] for i in formation_ids]
formations = [
sco_formations.formation_list(context, formation_id=i)[0]
for i in formation_ids
]
# log('formations=%s' % formations)
H.append(
'<div class="apo_csv_status_missing_elems"><span class="fontred">Elements Apogée absents dans ScoDoc: </span><span class="apo_elems fontred">%s</span>'
@ -498,7 +505,7 @@ def view_apo_etuds(context, semset_id, title="", nips=[], format="html", REQUEST
etuds = sco_etape_apogee.apo_csv_retreive_etuds_by_nip(context, semset, nips)
# Ils sont parfois dans ScoDoc même si pas dans le semestre: essaie de les retrouver
for etud in etuds.values():
etud_sco = scolars.get_etud_info(code_nip=etud["nip"], filled=True)
etud_sco = sco_etud.get_etud_info(code_nip=etud["nip"], filled=True)
if etud_sco:
e = etud_sco[0]
etud["inscriptions_scodoc"] = ", ".join(
@ -529,12 +536,12 @@ def view_scodoc_etuds(
if type(etudids) != type([]):
etudids = [etudids]
etuds = [
scolars.get_etud_info(etudid=etudid, filled=True)[0] for etudid in etudids
sco_etud.get_etud_info(etudid=etudid, filled=True)[0] for etudid in etudids
]
elif nips is not None:
if type(nips) != type([]):
nips = [nips]
etuds = [scolars.get_etud_info(code_nip=nip, filled=True)[0] for nip in nips]
etuds = [sco_etud.get_etud_info(code_nip=nip, filled=True)[0] for nip in nips]
else:
raise ValueError("etudid or NIP must be specified")
@ -752,7 +759,7 @@ def view_apo_csv(context, etape_apo="", semset_id="", format="html", REQUEST=Non
e["in_scodoc_str"] = {True: "oui", False: "non"}[e["in_scodoc"]]
if e["in_scodoc"]:
e["_in_scodoc_str_target"] = "ficheEtud?code_nip=" + e["nip"]
e.update(scolars.get_etud_info(code_nip=e["nip"], filled=True)[0])
e.update(sco_etud.get_etud_info(code_nip=e["nip"], filled=True)[0])
e["_nom_td_attrs"] = 'id="%s" class="etudinfo"' % (e["etudid"],)
e["_prenom_td_attrs"] = 'id="pre-%s" class="etudinfo"' % (e["etudid"],)
else:

View File

@ -92,10 +92,10 @@ Le filtrage s'effctue sur la date et non plus sur la parité du semestre (1-3/2-
import json
from sco_portal_apogee import get_inscrits_etape
from notes_log import log
from sco_utils import annee_scolaire_debut
from gen_tables import GenTable
from app.scodoc.sco_portal_apogee import get_inscrits_etape
from app.scodoc.notes_log import log
from app.scodoc.sco_utils import annee_scolaire_debut
from app.scodoc.gen_tables import GenTable
COL_PREFIX = "COL_"

View File

@ -27,54 +27,45 @@
""" Accès donnees etudiants
"""
# Ancien module "scolars"
import time
import mails
import sco_utils as scu
from sco_utils import SCO_ENCODING
import notesdb as ndb
from sco_exceptions import ScoGenError, ScoValueError
from notesdb import (
EditableTable,
ScoDocCursor,
DateDMYtoISO,
DateISOtoDMY,
int_null_is_null,
)
from notes_log import log
from TrivialFormulator import TrivialFormulator
import safehtml
from scolog import logdb
# from notes_table import *
import sco_news
# XXXXXXXXX HACK: zope 2.7.7 bug turaround ?
import locale
locale.setlocale(locale.LC_ALL, ("en_US", SCO_ENCODING))
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.header import Header
from email.mime.base import MIMEBase
abbrvmonthsnames = [
from app.scodoc import mails
import app.scodoc.sco_utils as scu
from app.scodoc.sco_utils import SCO_ENCODING
import app.scodoc.notesdb as ndb
from app.scodoc.sco_exceptions import ScoGenError, ScoValueError
from app.scodoc.notes_log import log
from app.scodoc.TrivialFormulator import TrivialFormulator
from app.scodoc import safehtml
from app.scodoc import sco_formsemestre
from app.scodoc import sco_preferences
from app.scodoc.scolog import logdb
MONTH_NAMES_ABBREV = [
"Jan ",
"Fev ",
"Fév ",
"Mars",
"Avr ",
"Mai ",
"Juin",
"Jul ",
"Aout",
"Août",
"Sept",
"Oct ",
"Nov ",
"Dec ",
"Déc ",
]
monthsnames = [
MONTH_NAMES = [
"janvier",
"février",
"mars",
@ -82,7 +73,7 @@ monthsnames = [
"mai",
"juin",
"juillet",
"aout",
"août",
"septembre",
"octobre",
"novembre",
@ -252,7 +243,7 @@ def pivot_year(y):
return y
_identiteEditor = EditableTable(
_identiteEditor = ndb.EditableTable(
"identite",
"etudid",
(
@ -277,9 +268,9 @@ _identiteEditor = EditableTable(
"nom": force_uppercase,
"prenom": force_uppercase,
"civilite": input_civilite,
"date_naissance": DateDMYtoISO,
"date_naissance": ndb.DateDMYtoISO,
},
output_formators={"date_naissance": DateISOtoDMY},
output_formators={"date_naissance": ndb.DateISOtoDMY},
convert_null_outputs_to_empty=True,
allow_set_id=True, # car on specifie le code Apogee a la creation
)
@ -320,7 +311,7 @@ def check_nom_prenom(cnx, nom="", prenom="", etudid=None):
if scu.FORBIDDEN_CHARS_EXP.search(nom) or scu.FORBIDDEN_CHARS_EXP.search(prenom):
return False, 0
# Now count homonyms:
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
req = "select etudid from identite where lower(nom) ~ %(nom)s and lower(prenom) ~ %(prenom)s"
if etudid:
req += " and etudid <> %(etudid)s"
@ -400,7 +391,7 @@ def identite_edit(cnx, args, context=None, REQUEST=None):
# Notification du changement par e-mail:
if notify_to:
etud = getEtudInfo(context, etudid=args["etudid"], filled=True)[0]
etud = get_etud_info(etudid=args["etudid"], filled=True)[0]
after = identite_list(cnx, {"etudid": args["etudid"]})[0]
notify_etud_change(
context,
@ -467,7 +458,7 @@ def notify_etud_change(context, email_addr, etud, before, after, subject):
# Note: la table adresse n'est pas dans dans la table "identite"
# car on prevoit plusieurs adresses par etudiant (ie domicile, entreprise)
_adresseEditor = EditableTable(
_adresseEditor = ndb.EditableTable(
"adresse",
"adresse_id",
(
@ -514,7 +505,7 @@ def adresse_edit(cnx, args, context=None):
# Notification du changement par e-mail:
if notify_to:
etud = getEtudInfo(context, etudid=args["etudid"], filled=True)[0]
etud = get_etud_info(etudid=args["etudid"], filled=True)[0]
after = adresse_list(cnx, {"etudid": args["etudid"]})[0]
notify_etud_change(
context,
@ -536,7 +527,7 @@ def getEmail(cnx, etudid):
# ---------
_admissionEditor = EditableTable(
_admissionEditor = ndb.EditableTable(
"admissions",
"adm_id",
(
@ -572,8 +563,8 @@ _admissionEditor = EditableTable(
"bac": force_uppercase,
"specialite": force_uppercase,
"annee_bac": pivot_year,
"classement": int_null_is_null,
"apb_classsment_gr": int_null_is_null,
"classement": ndb.int_null_is_null,
"apb_classement_gr": ndb.int_null_is_null,
},
output_formators={"type_admission": lambda x: x or scu.TYPE_ADMISSION_DEFAULT},
convert_null_outputs_to_empty=True,
@ -663,10 +654,10 @@ def get_etud_info(etudid=False, code_nip=False, filled=False, REQUEST=None):
return []
cnx = ndb.GetDBConnexion()
args = make_etud_args(etudid=etudid, code_nip=code_nip, REQUEST=REQUEST)
etud = scolars.etudident_list(cnx, args=args)
etud = etudident_list(cnx, args=args)
if filled:
fillEtudsInfo(context, etud)
fill_etuds_info(etud)
return etud
@ -679,6 +670,8 @@ def create_etud(context, cnx, args={}, REQUEST=None):
Returns:
etud, l'étudiant créé.
"""
from app.scodoc import sco_news
# creation d'un etudiant
etudid = etudident_create(cnx, args, context=context, REQUEST=REQUEST)
# crée une adresse vide (chaque etudiant doit etre dans la table "adresse" !)
@ -710,7 +703,7 @@ def create_etud(context, cnx, args={}, REQUEST=None):
msg="creation initiale",
)
etud = etudident_list(cnx, {"etudid": etudid})[0]
fillEtudsInfo(context, [etud])
fill_etuds_info([etud])
etud["url"] = "ficheEtud?etudid=%(etudid)s" % etud
sco_news.add(
context,
@ -724,7 +717,7 @@ def create_etud(context, cnx, args={}, REQUEST=None):
# ---------- "EVENTS"
_scolar_eventsEditor = EditableTable(
_scolar_eventsEditor = ndb.EditableTable(
"scolar_events",
"event_id",
(
@ -738,8 +731,8 @@ _scolar_eventsEditor = EditableTable(
),
sortkey="event_date",
convert_null_outputs_to_empty=True,
output_formators={"event_date": DateISOtoDMY},
input_formators={"event_date": DateDMYtoISO},
output_formators={"event_date": ndb.DateISOtoDMY},
input_formators={"event_date": ndb.DateDMYtoISO},
)
# scolar_events_create = _scolar_eventsEditor.create
@ -754,7 +747,7 @@ def scolar_events_create(cnx, args):
# --------
_etud_annotationsEditor = EditableTable(
_etud_annotationsEditor = ndb.EditableTable(
"etud_annotations",
"id",
(
@ -768,7 +761,7 @@ _etud_annotationsEditor = EditableTable(
),
sortkey="date desc",
convert_null_outputs_to_empty=True,
output_formators={"comment": safehtml.HTML2SafeHTML, "date": DateISOtoDMY},
output_formators={"comment": safehtml.HTML2SafeHTML, "date": ndb.DateISOtoDMY},
)
@ -792,7 +785,7 @@ def add_annotations_to_etud_list(context, etuds):
# -------- APPRECIATIONS (sur bulletins) -------------------
# Les appreciations sont dans la table postgres notes_appreciations
_appreciationsEditor = EditableTable(
_appreciationsEditor = ndb.EditableTable(
"notes_appreciations",
"id",
(
@ -807,7 +800,7 @@ _appreciationsEditor = EditableTable(
),
sortkey="date desc",
convert_null_outputs_to_empty=True,
output_formators={"comment": safehtml.HTML2SafeHTML, "date": DateISOtoDMY},
output_formators={"comment": safehtml.HTML2SafeHTML, "date": ndb.DateISOtoDMY},
)
appreciations_create = _appreciationsEditor.create
@ -903,11 +896,14 @@ def list_scolog(context, etudid):
return cursor.dictfetchall()
def fillEtudsInfo(context, etuds):
def fill_etuds_info(etuds):
"""etuds est une liste d'etudiants (mappings)
Pour chaque etudiant, ajoute ou formatte les champs
-> informations pour fiche etudiant ou listes diverses
"""
from app.scodoc import sco_formsemestre_inscriptions
context = None # XXX en attendant la suppression du context ScoDoc7
cnx = ndb.GetDBConnexion()
# open('/tmp/t','w').write( str(etuds) )
for etud in etuds:
@ -921,12 +917,14 @@ def fillEtudsInfo(context, etuds):
else:
adr = adrs[0]
if len(adrs) > 1:
log("fillEtudsInfo: etudid=%s a %d adresses" % (etudid, len(adrs)))
log("fill_etuds_info: etudid=%s a %d adresses" % (etudid, len(adrs)))
etud.update(adr)
format_etud_ident(etud)
# Semestres dans lesquel il est inscrit
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context, {"etudid": etudid})
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, {"etudid": etudid}
)
etud["ins"] = ins
sems = []
cursem = None # semestre "courant" ou il est inscrit
@ -1020,7 +1018,7 @@ def descr_situation_etud(context, etudid, ne=""):
if r["etat"] == "I":
situation = "inscrit%s en %s" % (ne, sem["titremois"])
# Cherche la date d'inscription dans scolar_events:
events = scolars.scolar_events_list(
events = scolar_events_list(
cnx,
args={
"etudid": etudid,
@ -1040,7 +1038,7 @@ def descr_situation_etud(context, etudid, ne=""):
else:
situation = "démission de %s" % sem["titremois"]
# Cherche la date de demission dans scolar_events:
events = scolars.scolar_events_list(
events = scolar_events_list(
cnx,
args={
"etudid": etudid,

View File

@ -32,21 +32,25 @@ import urllib
import operator
import datetime
from notes_log import log, logCallStack
import sco_utils as scu
import notesdb as ndb
from notesdb import ScoDocCursor
from sco_exceptions import AccessDenied, ScoValueError
import VERSION
from gen_tables import GenTable
from TrivialFormulator import TrivialFormulator
import sco_news
import sco_formsemestre
import sco_moduleimpl
import sco_groups
import sco_abs
import sco_evaluations
import sco_saisie_notes
from app.scodoc.notes_log import log, logCallStack
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from app.scodoc.sco_exceptions import AccessDenied, ScoValueError
from app.scodoc import VERSION
from app.scodoc.gen_tables import GenTable
from app.scodoc.TrivialFormulator import TrivialFormulator
from app.scodoc import html_sco_header
from app.scodoc import sco_abs
from app.scodoc import sco_core
from app.scodoc import sco_edit_module
from app.scodoc import sco_edit_ue
from app.scodoc import sco_formsemestre
from app.scodoc import sco_groups
from app.scodoc import sco_moduleimpl
from app.scodoc import sco_news
from app.scodoc import sco_permissions_check
from app.scodoc import sco_preferences
# --------------------------------------------------------------------
#
@ -170,7 +174,7 @@ def do_evaluation_list_in_formsemestre(context, formsemestre_id):
mods = sco_moduleimpl.do_moduleimpl_list(context, formsemestre_id=formsemestre_id)
evals = []
for mod in mods:
evals += sco_evaluations.do_evaluation_list(
evals += do_evaluation_list(
context, args={"moduleimpl_id": mod["moduleimpl_id"]}
)
return evals
@ -201,7 +205,7 @@ def do_evaluation_delete(context, REQUEST, evaluation_id):
if not the_evals:
raise ValueError("evaluation inexistante !")
NotesDB = context._notes_getall(evaluation_id) # { etudid : value }
NotesDB = do_evaluation_get_all_notes(context, evaluation_id) # { etudid : value }
notes = [x["value"] for x in NotesDB.values()]
if notes:
raise ScoValueError(
@ -251,7 +255,7 @@ def do_evaluation_etat(
context, evaluation_id, getallstudents=True
)
)
NotesDB = context._notes_getall(evaluation_id) # { etudid : value }
NotesDB = do_evaluation_get_all_notes(context, evaluation_id) # { etudid : value }
notes = [x["value"] for x in NotesDB.values()]
nb_abs = len([x for x in notes if x is None])
nb_neutre = len([x for x in notes if x == scu.NOTES_NEUTRALISE])
@ -458,7 +462,7 @@ def do_evaluation_list_in_sem(context, formsemestre_id):
"""
req = "select E.* from notes_evaluation E, notes_moduleimpl MI where MI.formsemestre_id = %(formsemestre_id)s and MI.moduleimpl_id = E.moduleimpl_id order by moduleimpl_id, numero desc, jour desc, heure_debut desc"
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(req, {"formsemestre_id": formsemestre_id})
res = cursor.dictfetchall()
# etat de chaque evaluation:
@ -469,15 +473,44 @@ def do_evaluation_list_in_sem(context, formsemestre_id):
return res
# remplacé par nt.get_sem_evaluation_etat_list()
#
# def formsemestre_evaluations_list(context, formsemestre_id):
# """Liste (non triée) des evals pour ce semestre"""
# req = "select E.* from notes_evaluation E, notes_moduleimpl MI where MI.formsemestre_id = %(formsemestre_id)s and MI.moduleimpl_id = E.moduleimpl_id"
# cnx = ndb.GetDBConnexion()
# cursor = cnx.cursor(cursor_factory=ScoDocCursor)
# cursor.execute( req, { 'formsemestre_id' : formsemestre_id } )
# return cursor.dictfetchall()
# ancien _notes_getall
def do_evaluation_get_all_notes(
context, evaluation_id, table="notes_notes", filter_suppressed=True, by_uid=None
):
"""Toutes les notes pour une evaluation: { etudid : { 'value' : value, 'date' : date ... }}
Attention: inclut aussi les notes des étudiants qui ne sont plus inscrits au module.
"""
# log('do_evaluation_get_all_notes( e=%s fs=%s )' % (evaluation_id, filter_suppressed))
do_cache = (
filter_suppressed and table == "notes_notes" and (by_uid is None)
) # pas de cache pour (rares) appels via undo_notes ou specifiant un enseignant
if do_cache:
cache = sco_core.get_evaluations_cache(context)
r = cache.get(evaluation_id)
if r != None:
return r
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cond = " where evaluation_id=%(evaluation_id)s"
if by_uid:
cond += " and uid=%(by_uid)s"
cursor.execute(
"select * from " + table + cond,
{"evaluation_id": evaluation_id, "by_uid": by_uid},
)
res = cursor.dictfetchall()
d = {}
if filter_suppressed:
for x in res:
if x["value"] != scu.NOTES_SUPPRESS:
d[x["etudid"]] = x
else:
for x in res:
d[x["etudid"]] = x
if do_cache:
cache.set(evaluation_id, d)
return d
def _eval_etat(evals):
@ -601,7 +634,7 @@ def formsemestre_evaluations_cal(context, formsemestre_id, REQUEST=None):
e[2] = color_futur
CalHTML = sco_abs.YearTable(
context.Absences, year, events=events.values(), halfday=False, pad_width=None
context, year, events=events.values(), halfday=False, pad_width=None
)
H = [
@ -649,9 +682,11 @@ def evaluation_date_first_completion(context, evaluation_id):
# retire de insem ceux qui ne sont pas inscrits au module
# ins = [i for i in insem if i["etudid"] in insmodset]
notes = context._notes_getall(evaluation_id, filter_suppressed=False).values()
notes_log = context._notes_getall(
evaluation_id, filter_suppressed=False, table="notes_notes_log"
notes = do_evaluation_get_all_notes(
context, evaluation_id, filter_suppressed=False
).values()
notes_log = do_evaluation_get_all_notes(
context, evaluation_id, filter_suppressed=False, table="notes_notes_log"
).values()
date_premiere_note = {} # etudid : date
for note in notes + notes_log:
@ -853,6 +888,8 @@ def evaluation_describe(context, evaluation_id="", edit_in_place=True, REQUEST=N
"""HTML description of evaluation, for page headers
edit_in_place: allow in-place editing when permitted (not implemented)
"""
from app.scodoc import sco_saisie_notes
E = do_evaluation_list(context, {"evaluation_id": evaluation_id})[0]
moduleimpl_id = E["moduleimpl_id"]
M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=moduleimpl_id)[0]
@ -861,7 +898,7 @@ def evaluation_describe(context, evaluation_id="", edit_in_place=True, REQUEST=N
u = context.Users.user_info(M["responsable_id"])
resp = u["prenomnom"]
nomcomplet = u["nomcomplet"]
can_edit = sco_saisie_notes.can_edit_notes(
can_edit = sco_permissions_check.can_edit_notes(
context, REQUEST.AUTHENTICATED_USER, moduleimpl_id, allow_ens=False
)
@ -1038,9 +1075,7 @@ def evaluation_create_form(
if not readonly:
H = ["<h3>%svaluation en %s</h3>" % (action, mod_descr)]
else:
return sco_evaluations.evaluation_describe(
context, evaluation_id, REQUEST=REQUEST
)
return evaluation_describe(context, evaluation_id, REQUEST=REQUEST)
heures = ["%02dh%02d" % (h, m) for h in range(8, 19) for m in (0, 30)]
#

View File

@ -28,18 +28,17 @@
""" Excel file handling
"""
import time, datetime
from types import StringType, IntType, FloatType, LongType
from pyExcelerator import *
from notes_log import log
from scolog import logdb
import app.scodoc.sco_utils as scu
from app.scodoc import notesdb
from app.scodoc.notes_log import log
from app.scodoc.scolog import logdb
from app.scodoc.sco_exceptions import ScoValueError
from sco_exceptions import ScoValueError
import sco_utils as scu
import notesdb
import time, datetime
from types import StringType, IntType, FloatType, LongType
# colors, voir exemple format.py
COLOR_CODES = {

View File

@ -29,20 +29,20 @@
"""
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
import sco_parcours_dut
import sco_codes_parcours
from sco_codes_parcours import NO_SEMESTRE_ID
import sco_excel
from gen_tables import GenTable
import sco_pvjury
import html_sco_header
import VERSION
import app.scodoc.notesdb as ndb
import app.scodoc.sco_utils as scu
from app.scodoc.notes_log import log
from app.scodoc import html_sco_header
from app.scodoc import sco_bac
from app.scodoc import sco_codes_parcours
from app.scodoc import sco_core
from app.scodoc import sco_formations
from app.scodoc import sco_preferences
from app.scodoc import sco_pvjury
from app.scodoc import sco_etud
from app.scodoc import VERSION
from app.scodoc.gen_tables import GenTable
from app.scodoc.sco_codes_parcours import NO_SEMESTRE_ID
def _build_results_table(context, start_date=None, end_date=None, types_parcours=[]):
@ -62,8 +62,8 @@ def _build_results_table(context, start_date=None, end_date=None, types_parcours
semlist = [dpv["formsemestre"] for dpv in dpv_by_sem.values() if dpv]
semlist_parcours = []
for sem in semlist:
sem["formation"] = sco_formations.formation_list(context,
args={"formation_id": sem["formation_id"]}
sem["formation"] = sco_formations.formation_list(
context, args={"formation_id": sem["formation_id"]}
)[0]
sem["parcours"] = sco_codes_parcours.get_parcours_from_code(
sem["formation"]["type_parcours"]
@ -83,7 +83,7 @@ def _build_results_table(context, start_date=None, end_date=None, types_parcours
etudids = nt.get_etudids()
for etudid in etudids:
if etudid not in etuds_infos: # pas encore traité ?
etud = scolars.get_etud_info(etudid=etudid, filled=True)[0]
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
for sem in etud["sems"]: # le plus récent d'abord
if sem["formsemestre_id"] in formsemestre_ids_parcours:
etuds_infos[etudid] = {
@ -337,10 +337,10 @@ _DATE_FORM = """
"""
# /opt/scodoc/bin/zopectl debug
from debug import *
from sco_export_results import *
from app.scodoc.sco_export_results import *
context = go_dept(app, 'RT').Notes
etudid = 'EID27764'
etud = scolars.get_etud_info( etudid=etudid, filled=True)[0]
etud = sco_etud.get_etud_info( etudid=etudid, filled=True)[0]
start_date='2015-08-15'
end_date='2017-08-31'

View File

@ -27,19 +27,15 @@
"""Recherche d'étudiants
"""
from types import ListType
import xml.dom.minidom
import sco_utils as scu
import notesdb as ndb
from notes_log import log
from gen_tables import GenTable
import html_sco_header
import scolars
import sco_formsemestre
import sco_groups
from sco_permissions import ScoView
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from app.scodoc.gen_tables import GenTable
from app.scodoc import html_sco_header
from app.scodoc import sco_etud
from app.scodoc import sco_groups
from app.scodoc.sco_permissions import Permission
from app.scodoc import sco_preferences
def form_search_etud(
@ -110,7 +106,7 @@ def search_etud_in_dept(context, expnom="", REQUEST=None):
"""
dest_url = "ficheEtud"
if len(expnom) > 1:
etuds = scolars.get_etud_info(filled=1, etudid=expnom, REQUEST=REQUEST)
etuds = sco_etud.get_etud_info(filled=1, etudid=expnom, REQUEST=REQUEST)
if len(etuds) != 1:
if scu.is_valid_code_nip(expnom):
etuds = search_etuds_infos(context, code_nip=expnom, REQUEST=REQUEST)
@ -194,14 +190,14 @@ def search_etuds_infos(context, expnom=None, code_nip=None, REQUEST=None):
cnx = ndb.GetDBConnexion()
if expnom and not may_be_nip:
expnom = scu.strupper(expnom) # les noms dans la BD sont en uppercase
etuds = scolars.etudident_list(cnx, args={"nom": expnom}, test="~")
etuds = sco_etud.etudident_list(cnx, args={"nom": expnom}, test="~")
else:
code_nip = code_nip or expnom
if code_nip:
etuds = scolars.etudident_list(cnx, args={"code_nip": code_nip})
etuds = sco_etud.etudident_list(cnx, args={"code_nip": code_nip})
else:
etuds = []
scolars.fillEtudsInfo(context, etuds)
sco_etud.fill_etuds_info(etuds)
return etuds
@ -230,7 +226,7 @@ def search_etud_by_name(context, term, REQUEST=None):
data = [
{
"label": "%s %s %s"
% (x["code_nip"], x["nom"], scolars.format_prenom(x["prenom"])),
% (x["code_nip"], x["nom"], sco_etud.format_prenom(x["prenom"])),
"value": x["code_nip"],
}
for x in r
@ -244,7 +240,7 @@ def search_etud_by_name(context, term, REQUEST=None):
data = [
{
"label": "%s %s" % (x["nom"], scolars.format_prenom(x["prenom"])),
"label": "%s %s" % (x["nom"], sco_etud.format_prenom(x["prenom"])),
"value": x["etudid"],
}
for x in r

View File

@ -30,19 +30,21 @@
from operator import itemgetter
import xml.dom.minidom
import sco_utils as scu
import app.scodoc.sco_utils as scu
import notesdb as ndb
from notes_log import log
import sco_codes_parcours
import sco_formsemestre
import sco_tag_module
import sco_preferences
from gen_tables import GenTable
from sco_exceptions import ScoValueError
from sco_permissions import ScoChangeFormation
from sco_permissions import Permission
import VERSION
import app.scodoc.notesdb as ndb
from app.scodoc.notes_log import log
from app.scodoc import sco_codes_parcours
from app.scodoc import sco_formsemestre
from app.scodoc import sco_tag_module
from app.scodoc import sco_preferences
from app.scodoc.gen_tables import GenTable
from app.scodoc.sco_exceptions import ScoValueError
from app.scodoc.sco_permissions import Permission
from app.scodoc import VERSION
from app.scodoc import sco_edit_matiere
from app.scodoc import sco_edit_module
from app.scodoc import sco_edit_ue
_formationEditor = ndb.EditableTable(
"notes_formations",

View File

@ -29,14 +29,16 @@
"""
import time
import sco_utils as scu
import notesdb as ndb
from notes_log import log
from gen_tables import GenTable
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from app.scodoc.notes_log import log
from app.scodoc.gen_tables import GenTable
import sco_codes_parcours
from sco_codes_parcours import NO_SEMESTRE_ID
from sco_exceptions import ScoValueError
from app.scodoc import sco_codes_parcours
from app.scodoc.sco_codes_parcours import NO_SEMESTRE_ID
from app.scodoc import sco_core
from app.scodoc import sco_preferences
from app.scodoc.sco_exceptions import ScoValueError
_formsemestreEditor = ndb.EditableTable(
"notes_formsemestre",
@ -129,7 +131,7 @@ def formsemestre_enrich(context, sem):
"""Ajoute champs souvent utiles: titre + annee et dateord (pour tris)"""
# imports ici pour eviter refs circulaires
import sco_formsemestre_edit
import scolars
import sco_etud
from app.views import notes
F = notes.formation_list(context, args={"formation_id": sem["formation_id"]})[0]
@ -184,7 +186,7 @@ def formsemestre_enrich(context, sem):
sem["titreannee"] += "-" + annee_fin
sem["annee"] += "-" + annee_fin
# et les dates sous la forme "oct 2007 - fev 2008"
months = scolars.abbrvmonthsnames
months = sco_etud.MONTH_NAMES_ABBREV
if mois_debut:
mois_debut = months[int(mois_debut) - 1]
if mois_fin:

View File

@ -29,13 +29,13 @@
"""
import sco_utils as scu
import notesdb as ndb
from notes_log import log
from TrivialFormulator import TrivialFormulator, TF
import sco_formsemestre
import sco_formsemestre_status
import sco_edt_cal
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from app.scodoc.TrivialFormulator import TrivialFormulator
from app.scodoc import html_sco_header
from app.scodoc import htmlutils
from app.scodoc import sco_formsemestre
from app.scodoc import sco_edt_cal
_custommenuEditor = ndb.EditableTable(
"notes_formsemestre_custommenu",
@ -73,7 +73,7 @@ def formsemestre_custommenu_html(context, formsemestre_id):
"args": {"formsemestre_id": formsemestre_id},
}
)
return sco_formsemestre_status.htmlutils.make_menu("Liens", menu)
return htmlutils.make_menu("Liens", menu)
def formsemestre_custommenu_edit(context, formsemestre_id, REQUEST=None):

View File

@ -28,25 +28,31 @@
"""Form choix modules / responsables et creation formsemestre
"""
import notesdb as ndb
import sco_utils as scu
import sco_core
import sco_groups
from notes_log import log
from TrivialFormulator import TrivialFormulator, TF
import notes_table
from sco_exceptions import AccessDenied, ScoValueError
from sco_formsemestre import ApoEtapeVDI
from sco_permissions import Permission
import sco_codes_parcours
import sco_compute_moy
import sco_formsemestre
import sco_modalites
import sco_moduleimpl
import sco_parcours_dut
import sco_portal_apogee
import sco_preferences
import scolars
import app.scodoc.notesdb as ndb
import app.scodoc.sco_utils as scu
from app.scodoc import sco_core
from app.scodoc import sco_groups
from app.scodoc.notes_log import log
from app.scodoc.TrivialFormulator import TrivialFormulator, TF
from app.scodoc.sco_exceptions import AccessDenied, ScoValueError
from app.scodoc.sco_formsemestre import ApoEtapeVDI
from app.scodoc.sco_permissions import Permission
from app.scodoc import html_sco_header
from app.scodoc import sco_codes_parcours
from app.scodoc import sco_compute_moy
from app.scodoc import sco_edit_matiere
from app.scodoc import sco_edit_module
from app.scodoc import sco_edit_ue
from app.scodoc import sco_evaluations
from app.scodoc import sco_formations
from app.scodoc import sco_formsemestre
from app.scodoc import sco_modalites
from app.scodoc import sco_moduleimpl
from app.scodoc import sco_parcours_dut
from app.scodoc import sco_permissions_check
from app.scodoc import sco_portal_apogee
from app.scodoc import sco_preferences
from app.scodoc import sco_etud
def _default_sem_title(F):
@ -1219,11 +1225,11 @@ def _reassociate_moduleimpls(
mod["module_id"] = modules_old2new[mod["module_id"]]
sco_moduleimpl.do_moduleimpl_edit(context, mod, formsemestre_id=formsemestre_id)
# update decisions:
events = scolars.scolar_events_list(cnx, args={"formsemestre_id": formsemestre_id})
events = sco_etud.scolar_events_list(cnx, args={"formsemestre_id": formsemestre_id})
for e in events:
if e["ue_id"]:
e["ue_id"] = ues_old2new[e["ue_id"]]
scolars.scolar_events_edit(cnx, e)
sco_etud.scolar_events_edit(cnx, e)
validations = sco_parcours_dut.scolar_formsemestre_validation_list(
cnx, args={"formsemestre_id": formsemestre_id}
)
@ -1421,7 +1427,9 @@ def formsemestre_edit_options(context, formsemestre_id, target_url=None, REQUEST
(accessible par ScoImplement ou dir. etudes)
"""
log("formsemestre_edit_options")
ok, err = context._check_access_diretud(formsemestre_id, REQUEST)
ok, err = sco_permissions_check.check_access_diretud(
context, formsemestre_id, REQUEST
)
if not ok:
return err
return sco_preferences.SemPreferences(context, formsemestre_id).edit(
@ -1435,7 +1443,9 @@ def formsemestre_change_lock(
"""Change etat (verrouille si ouvert, déverrouille si fermé)
nota: etat (1 ouvert, 0 fermé)
"""
ok, err = context._check_access_diretud(formsemestre_id, REQUEST)
ok, err = sco_permissions_check.check_access_diretud(
context, formsemestre_id, REQUEST
)
if not ok:
return err
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
@ -1475,7 +1485,9 @@ def formsemestre_change_publication_bul(
context, formsemestre_id, REQUEST=None, dialog_confirmed=False
):
"""Change etat publication bulletins sur portail"""
ok, err = context._check_access_diretud(formsemestre_id, REQUEST)
ok, err = sco_permissions_check.check_access_diretud(
context, formsemestre_id, REQUEST
)
if not ok:
return err
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
@ -1515,8 +1527,12 @@ def formsemestre_change_publication_bul(
def formsemestre_edit_uecoefs(context, formsemestre_id, err_ue_id=None, REQUEST=None):
"""Changement manuel des coefficients des UE capitalisées."""
from app.scodoc import notes_table
context = context.Notes # si appele d'en haut, eg par exception ScoValueError
ok, err = context._check_access_diretud(formsemestre_id, REQUEST)
ok, err = sco_permissions_check.check_access_diretud(
context, formsemestre_id, REQUEST
)
if not ok:
return err
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)

View File

@ -31,29 +31,33 @@ On va créer/gérer des semestres de la même formation que le semestre ScoDoc
est inscrit l'étudiant, leur attribuer la modalité 'EXT'.
Ces semestres n'auront qu'un seul inscrit !
"""
import TrivialFormulator
import sco_formsemestre
import sco_formsemestre_inscriptions
import sco_formsemestre_edit
import sco_formsemestre_validation
import sco_parcours_dut
import notesdb as ndb
from sco_utils import log
import pprint
import time
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from app.scodoc.sco_utils import log
from app.scodoc.TrivialFormulator import TrivialFormulator, tf_error_message
from app.scodoc import html_sco_header
from app.scodoc import sco_core
from app.scodoc import sco_edit_ue
from app.scodoc import sco_formations
from app.scodoc import sco_formsemestre
from app.scodoc import sco_formsemestre_inscriptions
from app.scodoc import sco_formsemestre_validation
from app.scodoc import sco_parcours_dut
from app.scodoc import sco_etud
def formsemestre_ext_create(context, etudid, sem_params, REQUEST=None):
"""Crée un formsemestre exterieur et y inscrit l'étudiant.
sem_params: dict nécessaire à la création du formsemestre
"""
# Check args
_formation = sco_formations.formation_list(context,
args={"formation_id": sem_params["formation_id"]}
_formation = sco_formations.formation_list(
context, args={"formation_id": sem_params["formation_id"]}
)[0]
if etudid:
_etud = scolars.get_etud_info(etudid=etudid, filled=1)[0]
_etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0]
# Create formsemestre
sem_params["modalite"] = "EXT"
@ -75,7 +79,7 @@ def formsemestre_ext_create(context, etudid, sem_params, REQUEST=None):
def formsemestre_ext_create_form(context, etudid, formsemestre_id, REQUEST=None):
"""Formulaire creation/inscription à un semestre extérieur"""
etud = scolars.get_etud_info(etudid=etudid, filled=1)[0]
etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0]
H = [
html_sco_header.sco_header(context, REQUEST),
"""<h2>Enregistrement d'une inscription antérieure dans un autre établissement</h2>
@ -100,8 +104,8 @@ def formsemestre_ext_create_form(context, etudid, formsemestre_id, REQUEST=None)
# et seulement si pas inscrit au même semestre_id d'un semestre ordinaire ScoDoc.
# Les autres situations (eg redoublements en changeant d'établissement)
# doivent être gérées par les validations de semestres "antérieurs"
insem = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context,
args={"etudid": etudid, "etat": "I"}
insem = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, args={"etudid": etudid, "etat": "I"}
)
semlist = [
sco_formsemestre.get_formsemestre(context, i["formsemestre_id"]) for i in insem
@ -172,7 +176,7 @@ def formsemestre_ext_create_form(context, etudid, formsemestre_id, REQUEST=None)
),
]
tf = TrivialFormulator.TrivialFormulator(
tf = TrivialFormulator(
REQUEST.URL0,
REQUEST.form,
descr,
@ -214,7 +218,7 @@ def formsemestre_ext_edit_ue_validations(
mais pas enregistrée.
"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
etud = scolars.get_etud_info(etudid=etudid, filled=True)[0]
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
ue_list = _list_ue_with_coef_and_validations(context, sem, etudid)
descr = _ue_form_description(context, ue_list, REQUEST.form)
if REQUEST and REQUEST.method == "GET":
@ -223,7 +227,7 @@ def formsemestre_ext_edit_ue_validations(
}
else:
initvalues = {}
tf = TrivialFormulator.TrivialFormulator(
tf = TrivialFormulator(
REQUEST.URL0,
REQUEST.form,
descr,
@ -267,7 +271,7 @@ def _make_page(context, etud, sem, tf, message="", REQUEST=None):
page_title="Validation des UE d'un semestre extérieur",
javascripts=["js/formsemestre_ext_edit_ue_validations.js"],
),
TrivialFormulator.tf_error_message(message),
tf_error_message(message),
"""<p><b>%(nomprenom)s</b> est inscrit%(ne)s à ce semestre extérieur.</p>
<p>Voici les UE entregistrées avec leur notes et coefficients.
</p>

View File

@ -27,22 +27,25 @@
"""Opérations d'inscriptions aux semestres et modules
"""
import time
import sco_utils as scu
from notes_log import log
from sco_exceptions import ScoValueError
from sco_permissions import ScoEtudInscrit
from sco_codes_parcours import UE_STANDARD, UE_SPORT, UE_TYPE_NAME
import notesdb as ndb
from notesdb import ScoDocCursor, DateISOtoDMY, DateDMYtoISO
import app.scodoc.sco_utils as scu
from app.scodoc.notes_log import log
from app.scodoc.scolog import logdb
from app.scodoc.sco_exceptions import ScoValueError
from app.scodoc.sco_permissions import Permission
from app.scodoc.sco_codes_parcours import UE_STANDARD, UE_SPORT, UE_TYPE_NAME
import app.scodoc.notesdb as ndb
from app.scodoc.TrivialFormulator import TrivialFormulator, TF
from app.scodoc import sco_find_etud
from app.scodoc import sco_formsemestre
from app.scodoc import sco_moduleimpl
from app.scodoc import sco_groups
from app.scodoc import sco_etud
from app.scodoc import sco_core
from app.scodoc import sco_formsemestre_edit
from app.scodoc import html_sco_header
from TrivialFormulator import TrivialFormulator, TF
# from notes_table import *
import sco_find_etud
import sco_formsemestre
import sco_moduleimpl
import sco_groups
# --- Gestion des inscriptions aux semestres
_formsemestre_inscriptionEditor = ndb.EditableTable(
@ -75,7 +78,7 @@ def do_formsemestre_inscription_create(context, args, REQUEST, method=None):
#
r = _formsemestre_inscriptionEditor.create(cnx, args)
# Evenement
scolars.scolar_events_create(
sco_etud.scolar_events_create(
cnx,
args={
"etudid": args["etudid"],
@ -135,8 +138,8 @@ def do_formsemestre_desinscription(context, etudid, formsemestre_id, REQUEST=Non
"desinscription impossible: l'étudiant a une décision de jury (la supprimer avant si nécessaire)"
)
insem = do_formsemestre_inscription_list(context,
args={"formsemestre_id": formsemestre_id, "etudid": etudid}
insem = do_formsemestre_inscription_list(
context, args={"formsemestre_id": formsemestre_id, "etudid": etudid}
)
if not insem:
raise ScoValueError("%s n'est pas inscrit au semestre !" % etudid)
@ -160,8 +163,8 @@ def do_formsemestre_desinscription(context, etudid, formsemestre_id, REQUEST=Non
)
# --- Semestre extérieur
if sem["modalite"] == "EXT":
inscrits = do_formsemestre_inscription_list(context,
args={"formsemestre_id": formsemestre_id}
inscrits = do_formsemestre_inscription_list(
context, args={"formsemestre_id": formsemestre_id}
)
nbinscrits = len(inscrits)
if nbinscrits == 0:
@ -259,7 +262,7 @@ def formsemestre_inscription_with_modules_form(
"""Formulaire inscription de l'etud dans l'un des semestres existants.
Si only_ext, ne montre que les semestre extérieurs.
"""
etud = scolars.get_etud_info(etudid=etudid, filled=1)[0]
etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0]
H = [
html_sco_header.sco_header(context, REQUEST),
"<h2>Inscription de %s" % etud["nomprenom"],
@ -275,8 +278,8 @@ def formsemestre_inscription_with_modules_form(
)
F = html_sco_header.sco_footer(context, REQUEST)
sems = sco_formsemestre.do_formsemestre_list(context, args={"etat": "1"})
insem = do_formsemestre_inscription_list(context,
args={"etudid": etudid, "etat": "I"}
insem = do_formsemestre_inscription_list(
context, args={"etudid": etudid, "etat": "I"}
)
if sems:
H.append("<ul>")
@ -318,7 +321,7 @@ def formsemestre_inscription_with_modules(
if multiple_ok:
multiple_ok = int(multiple_ok)
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
etud = scolars.get_etud_info(etudid=etudid, filled=1)[0]
etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0]
H = [
html_sco_header.html_sem_header(
context,
@ -416,7 +419,7 @@ def formsemestre_inscription_option(context, etudid, formsemestre_id, REQUEST=No
if sem["etat"] != "1":
raise ScoValueError("Modification impossible: semestre verrouille")
etud = scolars.get_etud_info(etudid=etudid, filled=1)[0]
etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0]
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > get_etud_ue_status
@ -480,7 +483,7 @@ def formsemestre_inscription_option(context, etudid, formsemestre_id, REQUEST=No
sem_origin["formsemestre_id"],
etudid,
sem_origin["titreannee"],
DateISOtoDMY(ue_status["event_date"]),
ndb.DateISOtoDMY(ue_status["event_date"]),
)
descr.append(
(
@ -709,15 +712,15 @@ def est_inscrit_ailleurs(context, etudid, formsemestre_id):
temps que celui indiqué (par formsemestre_id).
Retourne la liste des semestres concernés (ou liste vide).
"""
etud = scolars.get_etud_info(etudid=etudid, filled=1)[0]
etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0]
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
debut_s = sem["dateord"]
fin_s = DateDMYtoISO(sem["date_fin"])
fin_s = ndb.DateDMYtoISO(sem["date_fin"])
r = []
for s in etud["sems"]:
if s["formsemestre_id"] != formsemestre_id:
debut = s["dateord"]
fin = DateDMYtoISO(s["date_fin"])
fin = ndb.DateDMYtoISO(s["date_fin"])
if debut < fin_s and fin > debut_s:
r.append(s) # intersection
return r
@ -754,7 +757,7 @@ def formsemestre_inscrits_ailleurs(context, formsemestre_id, REQUEST=None):
insd = list_inscrits_ailleurs(context, formsemestre_id)
# liste ordonnée par nom
etudlist = [
scolars.get_etud_info(etudid=etudid, filled=1)[0]
sco_etud.get_etud_info(etudid=etudid, filled=1)[0]
for etudid in insd.keys()
if insd[etudid]
]

View File

@ -28,33 +28,38 @@
"""Tableau de bord semestre
"""
import urllib
import cgi
# Rewritten from ancient DTML code
from flask import current_app
from notes_log import log
import sco_utils as scu
import notesdb as ndb
from sco_permissions import Permission
from sco_exceptions import ScoValueError
import VERSION
import htmlutils
from sco_formsemestre_custommenu import formsemestre_custommenu_html
from gen_tables import GenTable
import html_sco_header
import sco_archives
import sco_bulletins
import sco_codes_parcours
import sco_core
import sco_compute_moy
import sco_evaluations
import sco_formations
import sco_formsemestre
import sco_formsemestre_edit
import sco_groups
import sco_moduleimpl
import sco_formsemestre_inscriptions
import sco_permissions
import sco_preferences
from app.scodoc.notes_log import log
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from app.scodoc.sco_permissions import Permission
from app.scodoc.sco_exceptions import ScoValueError, ScoInvalidDateError
from app.scodoc import VERSION
from app.scodoc import html_sco_header
from app.scodoc import htmlutils
from app.scodoc import sco_abs
from app.scodoc import sco_archives
from app.scodoc import sco_bulletins
from app.scodoc import sco_codes_parcours
from app.scodoc import sco_compute_moy
from app.scodoc import sco_core
from app.scodoc import sco_edit_ue
from app.scodoc import sco_evaluations
from app.scodoc import sco_formations
from app.scodoc import sco_formsemestre
from app.scodoc import sco_formsemestre_edit
from app.scodoc import sco_formsemestre_inscriptions
from app.scodoc import sco_groups
from app.scodoc import sco_moduleimpl
from app.scodoc import sco_permissions_check
from app.scodoc import sco_preferences
from app.scodoc.gen_tables import GenTable
from app.scodoc.sco_formsemestre_custommenu import formsemestre_custommenu_html
# H = [ """<span class="barrenav"><ul class="nav">
@ -124,7 +129,7 @@ def defMenuStats(context, formsemestre_id):
},
{
"title": "Estimation du coût de la formation",
"endpoint": "notes.formsemestre_estim_cost?formsemestre_id",
"endpoint": "notes.formsemestre_estim_cost",
"args": {"formsemestre_id": formsemestre_id},
"enabled": True,
},
@ -162,9 +167,11 @@ def formsemestre_status_menubar(context, sem, REQUEST):
},
{
"title": "Modifier le semestre",
"endpoint": "notes.formsemestre_editwithmodules?formation_id=%(formation_id)s&formsemestre_id=%(formsemestre_id)s"
% sem,
"args": {"formsemestre_id": formsemestre_id},
"endpoint": "notes.formsemestre_editwithmodules",
"args": {
"formation_id": sem["formation_id"],
"formsemestre_id": formsemestre_id,
},
"enabled": (
authuser.has_permission(Permission.ScoImplement)
or (
@ -177,7 +184,7 @@ def formsemestre_status_menubar(context, sem, REQUEST):
},
{
"title": "Préférences du semestre",
"endpoint": "notes.formsemestre_edit_preferences",
"endpoint": "scolar.formsemestre_edit_preferences",
"args": {"formsemestre_id": formsemestre_id},
"enabled": (
authuser.has_permission(Permission.ScoImplement)
@ -292,27 +299,27 @@ def formsemestre_status_menubar(context, sem, REQUEST):
},
{
"title": "Importer des étudiants dans ce semestre (table Excel)",
"endpoint": "notes.form_students_import_excel",
"endpoint": "scolar.form_students_import_excel",
"args": {"formsemestre_id": formsemestre_id},
"enabled": authuser.has_permission(Permission.ScoEtudInscrit)
and (sem["etat"] == "1"),
},
{
"title": "Import/export des données admission",
"endpoint": "notes.form_students_import_infos_admissions",
"endpoint": "scolar.form_students_import_infos_admissions",
"args": {"formsemestre_id": formsemestre_id},
"enabled": authuser.has_permission(Permission.ScoView),
},
{
"title": "Resynchroniser données identité",
"endpoint": "notes.formsemestre_import_etud_admission",
"endpoint": "scolar.formsemestre_import_etud_admission",
"args": {"formsemestre_id": formsemestre_id},
"enabled": authuser.has_permission(Permission.ScoEtudChangeAdr)
and sco_preferences.get_preference(context, "portal_url"),
},
{
"title": "Exporter table des étudiants",
"endpoint": "notes.groups_view",
"endpoint": "scolar.groups_view",
"args": {
"format": "allxls",
"group_ids": sco_groups.get_default_group(
@ -330,14 +337,14 @@ def formsemestre_status_menubar(context, sem, REQUEST):
menuGroupes = [
{
"title": "Listes, photos, feuilles...",
"endpoint": "notes.groups_view",
"endpoint": "scolar.groups_view",
"args": {"formsemestre_id": formsemestre_id},
"enabled": True,
"helpmsg": "Accès aux listes des groupes d'étudiants",
},
{
"title": "Créer/modifier les partitions...",
"endpoint": "notes.editPartitionForm",
"endpoint": "scolar.editPartitionForm",
"args": {"formsemestre_id": formsemestre_id},
"enabled": sco_groups.can_change_groups(context, REQUEST, formsemestre_id),
},
@ -354,7 +361,7 @@ def formsemestre_status_menubar(context, sem, REQUEST):
submenu.append(
{
"title": "%s" % partition["partition_name"],
"endpoint": "notes.affectGroups",
"endpoint": "scolar.affectGroups",
"args": {"partition_id": partition["partition_id"]},
"enabled": enabled,
}
@ -422,7 +429,7 @@ def formsemestre_status_menubar(context, sem, REQUEST):
"hidebac": 1,
"pref_override": 0,
},
"enabled": sco_permissions.can_validate_sem(
"enabled": sco_permissions_check.can_validate_sem(
context, REQUEST, formsemestre_id
),
},
@ -430,7 +437,9 @@ def formsemestre_status_menubar(context, sem, REQUEST):
"title": "Editer les PV et archiver les résultats",
"endpoint": "notes.formsemestre_archive",
"args": {"formsemestre_id": formsemestre_id},
"enabled": sco_permissions.can_edit_pv(context, REQUEST, formsemestre_id),
"enabled": sco_permissions_check.can_edit_pv(
context, REQUEST, formsemestre_id
),
},
{
"title": "Documents archivés",

View File

@ -29,22 +29,28 @@
"""
import urllib, time, datetime
import notesdb as ndb
import sco_utils as scu
from notes_log import log
from scolog import logdb
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
import sco_parcours_dut
import sco_codes_parcours
from sco_codes_parcours import *
import sco_pvjury
import sco_photos
import app.scodoc.notesdb as ndb
import app.scodoc.sco_utils as scu
from app.scodoc.notes_log import log
from app.scodoc.scolog import logdb
from app.scodoc.TrivialFormulator import TrivialFormulator, tf_error_message
from app.scodoc.sco_exceptions import ScoValueError
from app.scodoc.sco_abs import getAbsSemEtud
from app.scodoc.sco_codes_parcours import *
from app.scodoc import html_sco_header
from app.scodoc import sco_codes_parcours
from app.scodoc import sco_core
from app.scodoc import sco_edit_ue
from app.scodoc import sco_etud
from app.scodoc import sco_formsemestre
from app.scodoc import sco_formsemestre_edit
from app.scodoc import sco_formsemestre_inscriptions
from app.scodoc import sco_formsemestre_status
from app.scodoc import sco_parcours_dut
from app.scodoc import sco_photos
from app.scodoc import sco_preferences
from app.scodoc import sco_pvjury
# ------------------------------------------------------------------------------------
def formsemestre_validation_etud_form(
@ -91,7 +97,7 @@ def formsemestre_validation_etud_form(
if readonly:
check = True
etud = scolars.get_etud_info(etudid=etudid, filled=True)[0]
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
Se = sco_parcours_dut.SituationEtudParcours(context, etud, formsemestre_id)
if Se.sem["etat"] != "1":
raise ScoValueError("validation: semestre verrouille")
@ -108,13 +114,13 @@ def formsemestre_validation_etud_form(
Footer = ["<p>"]
# Navigation suivant/precedent
if etud_index_prev != None:
etud_p = scolars.get_etud_info(etudid=T[etud_index_prev][-1], filled=True)[0]
etud_p = sco_etud.get_etud_info(etudid=T[etud_index_prev][-1], filled=True)[0]
Footer.append(
'<span><a href="formsemestre_validation_etud_form?formsemestre_id=%s&etud_index=%s">Etud. précédent (%s)</a></span>'
% (formsemestre_id, etud_index_prev, etud_p["nomprenom"])
)
if etud_index_next != None:
etud_n = scolars.get_etud_info(etudid=T[etud_index_next][-1], filled=True)[0]
etud_n = sco_etud.get_etud_info(etudid=T[etud_index_next][-1], filled=True)[0]
Footer.append(
'<span style="padding-left: 50px;"><a href="formsemestre_validation_etud_form?formsemestre_id=%s&etud_index=%s">Etud. suivant (%s)</a></span>'
% (formsemestre_id, etud_index_next, etud_n["nomprenom"])
@ -333,22 +339,22 @@ def formsemestre_validation_etud(
REQUEST=None,
):
"""Enregistre validation"""
etud = scolars.get_etud_info(etudid=etudid, filled=True)[0]
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
Se = sco_parcours_dut.SituationEtudParcours(context, etud, formsemestre_id)
# retrouve la decision correspondant au code:
choices = Se.get_possible_choices(assiduite=True)
choices += Se.get_possible_choices(assiduite=False)
found = False
selected_choice = None
for choice in choices:
if choice.codechoice == codechoice:
found = True
selected_choice = choice
break
if not found:
if not selected_choice:
raise ValueError("code choix invalide ! (%s)" % codechoice)
#
Se.valide_decision(choice, REQUEST) # enregistre
Se.valide_decision(selected_choice, REQUEST) # enregistre
return _redirect_valid_choice(
formsemestre_id, etudid, Se, choice, desturl, sortcol, REQUEST
formsemestre_id, etudid, Se, selected_choice, desturl, sortcol, REQUEST
)
@ -368,7 +374,7 @@ def formsemestre_validation_etud_manu(
"""Enregistre validation"""
if assidu:
assidu = 1
etud = scolars.get_etud_info(etudid=etudid, filled=True)[0]
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
Se = sco_parcours_dut.SituationEtudParcours(context, etud, formsemestre_id)
if code_etat in Se.parcours.UNUSED_CODES:
raise ScoValueError("code decision invalide dans ce parcours")
@ -862,10 +868,10 @@ def do_formsemestre_validation_auto(context, formsemestre_id, REQUEST):
nb_valid = 0
conflicts = [] # liste des etudiants avec decision differente déjà saisie
for etudid in etudids:
etud = scolars.get_etud_info(etudid=etudid, filled=True)[0]
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
Se = sco_parcours_dut.SituationEtudParcours(context, etud, formsemestre_id)
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context,
{"etudid": etudid, "formsemestre_id": formsemestre_id}
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, {"etudid": etudid, "formsemestre_id": formsemestre_id}
)[0]
# Conditions pour validation automatique:
@ -964,10 +970,10 @@ def formsemestre_fix_validation_ues(context, formsemestre_id, REQUEST=None):
modifs = [] # liste d'étudiants modifiés
cnx = context.GetDBConnexion(autocommit=False)
for etudid in etudids:
etud = scolars.get_etud_info(etudid=etudid, filled=True)[0]
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
Se = sco_parcours_dut.SituationEtudParcours(context, etud, formsemestre_id)
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context,
{"etudid": etudid, "formsemestre_id": formsemestre_id}
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, {"etudid": etudid, "formsemestre_id": formsemestre_id}
)[0]
decision_sem = nt.get_etud_decision_sem(etudid)
if not decision_sem:
@ -1071,9 +1077,13 @@ def formsemestre_validate_previous_ue(context, formsemestre_id, etudid, REQUEST=
"""Form. saisie UE validée hors ScoDoc
(pour étudiants arrivant avec un UE antérieurement validée).
"""
etud = scolars.get_etud_info(etudid=etudid, filled=True)[0]
from app.scodoc import sco_formations
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
Fo = sco_formations.formation_list(context, args={"formation_id": sem["formation_id"]})[0]
Fo = sco_formations.formation_list(
context, args={"formation_id": sem["formation_id"]}
)[0]
H = [
html_sco_header.sco_header(

View File

@ -29,14 +29,10 @@
"""
import operator
import traceback
from types import FloatType, IntType, LongType, StringType
import sco_utils as scu
from notes_log import log
class NoteVector:
class NoteVector(object):
"""Vecteur de notes (ou coefficients) utilisé pour les formules définies par l'utilisateur.
Les éléments sont accessibles soit par index v[i], soit par leur nom v['nom'] s'il en ont un.
Les éléments sont toujours numériques (float). Les valeurs non numériques ('NI', ...) sont

View File

@ -43,17 +43,18 @@ import operator
import jaxml
import xml.dom.minidom
import sco_utils as scu
import notesdb as ndb
from notes_log import log
from scolog import logdb
from TrivialFormulator import TrivialFormulator, TF
import sco_formsemestre
import scolars
import sco_parcours_dut
import sco_codes_parcours
from sco_permissions import ScoEtudChangeGroups
from sco_exceptions import ScoException, AccessDenied, ScoValueError
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from app.scodoc.notes_log import log
from app.scodoc.scolog import logdb
from app.scodoc import html_sco_header
from app.scodoc import sco_codes_parcours
from app.scodoc import sco_core
from app.scodoc import sco_etud
from app.scodoc import sco_formsemestre
from app.scodoc.sco_exceptions import ScoException, AccessDenied, ScoValueError
from app.scodoc.sco_permissions import Permission
from app.scodoc.TrivialFormulator import TrivialFormulator
def can_change_groups(context, REQUEST, formsemestre_id):
@ -244,7 +245,7 @@ def get_group_members(context, group_id, etat=None):
r = ndb.SimpleDictFetch(context, req, {"group_id": group_id, "etat": etat})
for etud in r:
scolars.format_etud_ident(etud)
sco_etud.format_etud_ident(etud)
r.sort(key=operator.itemgetter("nom_disp", "prenom")) # tri selon nom_usuel ou nom
@ -285,7 +286,7 @@ def get_group_infos(context, group_id, etat=None): # was _getlisteetud
if t["etat"] == "I":
t["etath"] = "" # etudiant inscrit, ne l'indique pas dans la liste HTML
elif t["etat"] == "D":
events = scolars.scolar_events_list(
events = sco_etud.scolar_events_list(
cnx,
args={
"etudid": t["etudid"],
@ -469,14 +470,14 @@ def XMLgetGroupsInPartition(context, partition_id, REQUEST=None): # was XMLgetG
group_name=group["group_name"],
)
for e in get_group_members(context, group["group_id"]):
etud = scolars.get_etud_info(etudid=e["etudid"], filled=1)[0]
etud = sco_etud.get_etud_info(etudid=e["etudid"], filled=1)[0]
doc._push()
doc.etud(
etudid=e["etudid"],
civilite=etud["civilite_str"],
sexe=etud["civilite_str"], # compat
nom=scolars.format_nom(etud["nom"]),
prenom=scolars.format_prenom(etud["prenom"]),
nom=sco_etud.format_nom(etud["nom"]),
prenom=sco_etud.format_prenom(etud["prenom"]),
origin=comp_origin(etud, sem),
)
if e["etudid"] in etuds_set:
@ -494,13 +495,13 @@ def XMLgetGroupsInPartition(context, partition_id, REQUEST=None): # was XMLgetG
group_name="",
)
for etudid in etuds_set:
etud = scolars.get_etud_info(etudid=etudid, filled=1)[0]
etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0]
doc._push()
doc.etud(
etudid=etud["etudid"],
sexe=etud["civilite_str"],
nom=scolars.format_nom(etud["nom"]),
prenom=scolars.format_prenom(etud["prenom"]),
nom=sco_etud.format_nom(etud["nom"]),
prenom=sco_etud.format_prenom(etud["prenom"]),
origin=comp_origin(etud, sem),
)
doc._pop()
@ -1297,9 +1298,9 @@ def get_prev_moy(context, etudid, formsemestre_id):
"""Donne la derniere moyenne generale calculee pour cette étudiant,
ou 0 si on n'en trouve pas (nouvel inscrit,...).
"""
import sco_parcours_dut
from app.scodoc import sco_parcours_dut
info = scolars.get_etud_info(etudid=etudid, filled=True)
info = sco_etud.get_etud_info(etudid=etudid, filled=True)
if not info:
raise ScoValueError("etudiant invalide: etudid=%s" % etudid)
etud = info[0]
@ -1320,9 +1321,11 @@ def create_etapes_partition(context, formsemestre_id, partition_name="apo_etapes
Si la partition existe déjà, ses groupes sont mis à jour (les groupes devenant
vides ne sont pas supprimés).
"""
from app.scodoc import sco_formsemestre_inscriptions
log("create_etapes_partition(%s)" % formsemestre_id)
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context,
args={"formsemestre_id": formsemestre_id}
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, args={"formsemestre_id": formsemestre_id}
)
etapes = {i["etape"] for i in ins if i["etape"]}
partitions = get_partitions_list(context, formsemestre_id, with_default=False)

View File

@ -28,14 +28,9 @@
"""Formulaires gestion des groupes
"""
import re
import sco_utils as scu
import notesdb as ndb
from notes_log import log
import sco_formsemestre
import sco_groups
from sco_exceptions import AccessDenied
from app.scodoc import html_sco_header
from app.scodoc import sco_groups
from app.scodoc.sco_exceptions import AccessDenied
def affectGroups(context, partition_id, REQUEST=None):
@ -49,7 +44,8 @@ def affectGroups(context, partition_id, REQUEST=None):
raise AccessDenied("vous n'avez pas la permission d'effectuer cette opération")
H = [
html_sco_header.sco_header(context,
html_sco_header.sco_header(
context,
REQUEST,
page_title="Affectation aux groupes",
javascripts=["js/groupmgr.js"],

View File

@ -37,21 +37,20 @@ import time
import collections
import operator
import sco_utils as scu
from sco_permissions import ScoEtudInscrit, ScoEtudAddAnnotations, ScoAbsChange
from sco_exceptions import ScoValueError
import html_sco_header
from gen_tables import GenTable
import scolars
import sco_abs
import sco_excel
import sco_formsemestre
import sco_moduleimpl
import sco_groups
import sco_trombino
import sco_portal_apogee
import sco_parcours_dut
import sco_report
import app.scodoc.sco_utils as scu
from app.scodoc import html_sco_header
from app.scodoc import sco_abs
from app.scodoc import sco_excel
from app.scodoc import sco_formsemestre
from app.scodoc import sco_groups
from app.scodoc import sco_moduleimpl
from app.scodoc import sco_parcours_dut
from app.scodoc import sco_portal_apogee
from app.scodoc import sco_preferences
from app.scodoc import sco_etud
from app.scodoc.gen_tables import GenTable
from app.scodoc.sco_exceptions import ScoValueError
from app.scodoc.sco_permissions import Permission
JAVASCRIPTS = html_sco_header.BOOTSTRAP_MULTISELECT_JS + [
"js/etud_info.js",
@ -452,6 +451,8 @@ def groups_table(
format: csv, json, xml, xls, allxls, xlsappel, moodlecsv, pdf
Si with_codes, ajoute 4 colonnes avec les codes etudid, NIP, INE et etape
"""
from app.scodoc import sco_report
# log(
# "enter groups_table %s: %s"
# % (groups_infos.members[0]["nom"], groups_infos.members[0].get("etape", "-"))
@ -515,7 +516,7 @@ def groups_table(
sco_archives_etud.add_archives_info_to_etud_list(context, groups_infos.members)
columns_ids += ["etudarchive"]
if with_annotations:
scolars.add_annotations_to_etud_list(context, groups_infos.members)
sco_etud.add_annotations_to_etud_list(context, groups_infos.members)
columns_ids += ["annotations_str"]
if groups_infos.formsemestre["semestre_id"] >= 0:
@ -785,9 +786,9 @@ def groups_table(
# remplis infos lycee si on a que le code lycée
# et ajoute infos inscription
for m in groups_infos.members:
etud = scolars.get_etud_info(m["etudid"], filled=True)[0]
etud = sco_etud.get_etud_info(m["etudid"], filled=True)[0]
m.update(etud)
scolars.etud_add_lycee_infos(etud)
sco_etud.etud_add_lycee_infos(etud)
# et ajoute le parcours
Se = sco_parcours_dut.SituationEtudParcours(
context.Notes, etud, groups_infos.formsemestre_id
@ -873,6 +874,8 @@ def tab_absences_html(context, groups_infos, etat=None, REQUEST=None):
def tab_photos_html(context, groups_infos, etat=None, REQUEST=None):
"""contenu du tab "photos" """
from app.scodoc import sco_trombino
if not groups_infos.members:
return '<div class="tab-content"><h3>Aucun étudiant !</h3></div>'
@ -974,7 +977,7 @@ def export_groups_as_moodle_csv(context, formsemestre_id=None, REQUEST=None):
partition = sco_groups.get_partition(context, partition_id)
members = partitions_etud_groups[partition_id]
for etudid in members:
etud = scolars.get_etud_info(etudid=etudid, filled=True)[0]
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
group_name = members[etudid]["group_name"]
elts = [moodle_sem_name]
if partition["partition_name"]:

View File

@ -27,20 +27,16 @@
"""Import d'utilisateurs via fichier Excel
"""
import email
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.header import Header
import mails
import notesdb as ndb
import sco_utils as scu
from notes_log import log
from TrivialFormulator import TrivialFormulator, TF
import sco_news
import sco_excel
from sco_exceptions import AccessDenied, ScoValueError, ScoException
from app.scodoc import mails
import app.scodoc.sco_utils as scu
from app.scodoc.notes_log import log
from app.scodoc.sco_exceptions import AccessDenied, ScoValueError, ScoException
from app.scodoc import sco_excel
from app.scodoc import sco_preferences
TITLES = ("user_name", "nom", "prenom", "email", "roles", "dept")

View File

@ -30,18 +30,20 @@
"""
import datetime
import notesdb as ndb
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
import sco_formsemestre_inscriptions
import sco_formsemestre
import sco_groups
import scolars
from sco_exceptions import ScoValueError
import app.scodoc.notesdb as ndb
import app.scodoc.sco_utils as scu
from app.scodoc.notes_log import log
from app.scodoc.gen_tables import GenTable
from app.scodoc import html_sco_header
from app.scodoc import sco_codes_parcours
from app.scodoc import sco_preferences
from app.scodoc import sco_pvjury
from app.scodoc import sco_formsemestre
from app.scodoc import sco_formsemestre_inscriptions
from app.scodoc import sco_formations
from app.scodoc import sco_groups
from app.scodoc import sco_etud
from app.scodoc.sco_exceptions import ScoValueError
def list_authorized_etuds_by_sem(context, sem, delai=274):
@ -59,7 +61,7 @@ def list_authorized_etuds_by_sem(context, sem, delai=274):
for e in liste:
# Filtre ceux qui se sont déjà inscrit dans un semestre APRES le semestre src
auth_used = False # autorisation deja utilisée ?
etud = scolars.get_etud_info(etudid=e["etudid"], filled=True)[0]
etud = sco_etud.get_etud_info(etudid=e["etudid"], filled=True)[0]
for isem in etud["sems"]:
if ndb.DateDMYtoISO(isem["date_debut"]) >= ndb.DateDMYtoISO(
src["date_fin"]
@ -110,11 +112,13 @@ def list_inscrits(context, formsemestre_id, with_dems=False):
) # optimized
else:
args = {"formsemestre_id": formsemestre_id}
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context, args=args)
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, args=args
)
inscr = {}
for i in ins:
etudid = i["etudid"]
inscr[etudid] = scolars.get_etud_info(etudid=etudid, filled=True)[0]
inscr[etudid] = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
return inscr
@ -172,7 +176,7 @@ def do_inscrit(context, sem, etudids, REQUEST=None, inscrit_groupes=False):
# (mise en correspondance à partir du nom du groupe, sans tenir compte
# du nom de la partition: évidemment, cela ne marche pas si on a les
# même noms de groupes dans des partitions différentes)
etud = scolars.get_etud_info(etudid=etudid, filled=True)[0]
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
log("cherche groupes de %(nom)s" % etud)
# recherche le semestre origine (il serait plus propre de l'avoir conservé!)
@ -242,7 +246,9 @@ def list_source_sems(context, sem, delai=None):
if s["semestre_id"] == sco_codes_parcours.NO_SEMESTRE_ID:
continue
#
F = sco_formations.formation_list(context, args={"formation_id": s["formation_id"]})[0]
F = sco_formations.formation_list(
context, args={"formation_id": s["formation_id"]}
)[0]
parcours = sco_codes_parcours.get_parcours_from_code(F["type_parcours"])
if not parcours.ALLOW_SEM_SKIP:
if s["semestre_id"] < (sem["semestre_id"] - 1):
@ -569,7 +575,7 @@ def etuds_select_boxes(
c = " inscrailleurs"
else:
c = ""
scolars.format_etud_ident(etud)
sco_etud.format_etud_ident(etud)
if etud["etudid"]:
elink = (
"""<a class="discretelink %s" href="ficheEtud?etudid=%s">%s</a>"""

View File

@ -30,19 +30,26 @@
import urllib
from types import StringType
import sco_utils as scu
import notesdb as ndb
from notes_log import log
from TrivialFormulator import TrivialFormulator, TF
import sco_formsemestre
import sco_moduleimpl
import sco_groups
import sco_evaluations
import htmlutils
import sco_excel
from gen_tables import GenTable
from htmlutils import histogram_notes
import VERSION
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from app.scodoc.notes_log import log
from app.scodoc.TrivialFormulator import TrivialFormulator
from app.scodoc import htmlutils
from app.scodoc import html_sco_header
from app.scodoc import sco_abs
from app.scodoc import sco_core
from app.scodoc import sco_edit_module
from app.scodoc import sco_evaluations
from app.scodoc import sco_excel
from app.scodoc import sco_formsemestre
from app.scodoc import sco_formsemestre_inscriptions
from app.scodoc import sco_groups
from app.scodoc import sco_moduleimpl
from app.scodoc import sco_preferences
from app.scodoc import sco_etud
from app.scodoc import VERSION
from app.scodoc.gen_tables import GenTable
from app.scodoc.htmlutils import histogram_notes
def do_evaluation_listenotes(context, REQUEST):
@ -55,11 +62,15 @@ def do_evaluation_listenotes(context, REQUEST):
if REQUEST.form.has_key("evaluation_id"):
evaluation_id = REQUEST.form["evaluation_id"]
mode = "eval"
evals = sco_evaluations.do_evaluation_list(context, {"evaluation_id": evaluation_id})
evals = sco_evaluations.do_evaluation_list(
context, {"evaluation_id": evaluation_id}
)
if REQUEST.form.has_key("moduleimpl_id"):
moduleimpl_id = REQUEST.form["moduleimpl_id"]
mode = "module"
evals = sco_evaluations.do_evaluation_list(context, {"moduleimpl_id": moduleimpl_id})
evals = sco_evaluations.do_evaluation_list(
context, {"moduleimpl_id": moduleimpl_id}
)
if not mode:
raise ValueError("missing argument: evaluation or module")
if not evals:
@ -284,10 +295,10 @@ def _make_table_notes(
for etudid in etudids:
css_row_class = None
# infos identite etudiant
etud = scolars.get_etud_info(etudid=etudid, filled=1)[0]
etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0]
# infos inscription
inscr = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context,
{"etudid": etudid, "formsemestre_id": M["formsemestre_id"]}
inscr = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, {"etudid": etudid, "formsemestre_id": M["formsemestre_id"]}
)[0]
if inscr["etat"] == "I": # si inscrit, indique groupe
@ -540,7 +551,7 @@ def _add_eval_columns(
sum_notes = 0
notes = [] # liste des notes numeriques, pour calcul histogramme uniquement
evaluation_id = e["evaluation_id"]
NotesDB = context._notes_getall(evaluation_id)
NotesDB = sco_evaluations.do_evaluation_get_all_notes(context, evaluation_id)
for row in rows:
etudid = row["etudid"]
if NotesDB.has_key(etudid):
@ -717,17 +728,17 @@ def evaluation_check_absences(context, evaluation_id):
am, pm, demijournee = _eval_demijournee(E)
# Liste les absences à ce moment:
A = context.Absences.ListeAbsJour(ndb.DateDMYtoISO(E["jour"]), am=am, pm=pm)
A = sco_abs.ListeAbsJour(context, ndb.DateDMYtoISO(E["jour"]), am=am, pm=pm)
As = set([x["etudid"] for x in A]) # ensemble des etudiants absents
NJ = context.Absences.ListeAbsNonJustJour(ndb.DateDMYtoISO(E["jour"]), am=am, pm=pm)
NJ = sco_abs.ListeAbsNonJustJour(context, ndb.DateDMYtoISO(E["jour"]), am=am, pm=pm)
NJs = set([x["etudid"] for x in NJ]) # ensemble des etudiants absents non justifies
Just = context.Absences.ListeAbsJour(
ndb.DateDMYtoISO(E["jour"]), am=am, pm=pm, is_abs=None, is_just=True
Just = sco_abs.ListeAbsJour(
context, ndb.DateDMYtoISO(E["jour"]), am=am, pm=pm, is_abs=None, is_just=True
)
Justs = set([x["etudid"] for x in Just]) # ensemble des etudiants avec justif
# Les notes:
NotesDB = context._notes_getall(evaluation_id)
NotesDB = sco_evaluations.do_evaluation_get_all_notes(context, evaluation_id)
ValButAbs = [] # une note mais noté absent
AbsNonSignalee = [] # note ABS mais pas noté absent
ExcNonSignalee = [] # note EXC mais pas noté absent
@ -803,7 +814,7 @@ def evaluation_check_absences_html(
if not etudids and show_ok:
H.append("<li>aucun</li>")
for etudid in etudids:
etud = scolars.get_etud_info(etudid=etudid, filled=True)[0]
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
H.append(
'<li><a class="discretelink" href="ficheEtud?etudid=%(etudid)s">%(nomprenom)s</a>'
% etud
@ -877,7 +888,9 @@ def formsemestre_check_absences_html(context, formsemestre_id, REQUEST=None):
context, formsemestre_id=formsemestre_id
)
for M in Mlist:
evals = sco_evaluations.do_evaluation_list(context, {"moduleimpl_id": M["moduleimpl_id"]})
evals = sco_evaluations.do_evaluation_list(
context, {"moduleimpl_id": M["moduleimpl_id"]}
)
if evals:
H.append(
'<div class="module_check_absences"><h2><a href="moduleimpl_status?moduleimpl_id=%s">%s: %s</a></h2>'

View File

@ -30,16 +30,14 @@
- suivi cohortes
"""
import tempfile, urllib, re
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
import app.scodoc.sco_utils as scu
from app.scodoc import html_sco_header
from app.scodoc import sco_formsemestre
from app.scodoc import sco_preferences
from app.scodoc import sco_report
from app.scodoc import sco_etud
from app.scodoc import VERSION
from app.scodoc.gen_tables import GenTable
def formsemestre_table_etuds_lycees(
@ -106,7 +104,7 @@ def scodoc_table_etuds_lycees(context, format="html", REQUEST=None):
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 = [sco_etud.etud_add_lycee_infos(e) for e in etuds]
etuds_by_lycee = scu.group_by_key(etuds, "codelycee")
#
if group_lycees:

View File

@ -33,11 +33,9 @@ Elle n'est pas utilisée pour les parcours, ni pour rien d'autre
(c'est donc un attribut "cosmétique").
"""
import notesdb as ndb
import sco_utils as scu
from notes_log import log
from TrivialFormulator import TrivialFormulator, TF
import sco_codes_parcours
import app.scodoc.notesdb as ndb
import app.scodoc.sco_utils as scu
from app.scodoc.notes_log import log
def list_formsemestres_modalites(context, sems):

View File

@ -28,24 +28,20 @@
"""Fonctions sur les moduleimpl
"""
# codes anciens déplacés de ZEntreprise
import datetime
import sco_utils as scu
import notesdb as ndb
from notesdb import ScoDocCursor, EditableTable, DateISOtoDMY, DateDMYtoISO
from sco_permissions import ScoImplement
from sco_exceptions import ScoValueError, AccessDenied
from notes_log import log
import scolog
import sco_edit_matiere
import sco_edit_module
import sco_edit_ue
import sco_formsemestre
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from app.scodoc.sco_permissions import Permission
from app.scodoc.sco_exceptions import ScoValueError, AccessDenied
from app.scodoc.notes_log import log
from app.scodoc import scolog
from app.scodoc import sco_formsemestre
from app.scodoc import sco_core
# --- Gestion des "Implémentations de Modules"
# Un "moduleimpl" correspond a la mise en oeuvre d'un module
# dans une formation spécifique, à une date spécifique.
_moduleimplEditor = EditableTable(
_moduleimplEditor = ndb.EditableTable(
"notes_moduleimpl",
"moduleimpl_id",
(
@ -57,7 +53,7 @@ _moduleimplEditor = EditableTable(
),
)
_modules_enseignantsEditor = EditableTable(
_modules_enseignantsEditor = ndb.EditableTable(
"notes_modules_enseignants",
"modules_enseignants_id",
("modules_enseignants_id", "moduleimpl_id", "ens_id"),
@ -78,7 +74,7 @@ def do_moduleimpl_delete(context, oid, formsemestre_id=None):
"delete moduleimpl (desinscrit tous les etudiants)"
cnx = ndb.GetDBConnexion()
# --- desinscription des etudiants
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
req = (
"DELETE FROM notes_moduleimpl_inscription WHERE moduleimpl_id=%(moduleimpl_id)s"
)
@ -106,7 +102,7 @@ def do_moduleimpl_list(
"list moduleimpls"
args = locals()
cnx = ndb.GetDBConnexion()
modimpls = _moduleimplEditor.list(cnx, args) # *args, **kw)
modimpls = _moduleimplEditor.list(cnx, args)
# Ajoute la liste des enseignants
for mo in modimpls:
mo["ens"] = do_ens_list(context, args={"moduleimpl_id": mo["moduleimpl_id"]})
@ -130,10 +126,21 @@ def do_moduleimpl_withmodule_list(
Attention: Cette fonction fait partie de l'API ScoDoc 7 et est publiée.
"""
from app.scodoc import sco_edit_ue
from app.scodoc import sco_edit_matiere
from app.scodoc import sco_edit_module
args = locals()
del args["context"]
del args["REQUEST"]
modimpls = do_moduleimpl_list(context, **args)
modimpls = do_moduleimpl_list(
context,
**{
"moduleimpl_id": moduleimpl_id,
"formsemestre_id": formsemestre_id,
"module_id": module_id,
}
)
for mo in modimpls:
mo["module"] = sco_edit_module.do_module_list(
context, args={"module_id": mo["module_id"]}
@ -174,7 +181,7 @@ def do_moduleimpl_listeetuds(context, moduleimpl_id):
"retourne liste des etudids inscrits a ce module"
req = "select distinct Im.etudid from notes_moduleimpl_inscription Im, notes_formsemestre_inscription Isem, notes_moduleimpl M where Isem.etudid=Im.etudid and Im.moduleimpl_id=M.moduleimpl_id and M.moduleimpl_id = %(moduleimpl_id)s"
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(req, {"moduleimpl_id": moduleimpl_id})
res = cursor.fetchall()
return [x[0] for x in res]
@ -184,7 +191,7 @@ def do_moduleimpl_inscrit_tout_semestre(context, moduleimpl_id, formsemestre_id)
"inscrit tous les etudiants inscrit au semestre a ce module"
# UNUSED
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
req = """INSERT INTO notes_moduleimpl_inscription
(moduleimpl_id, etudid)
SELECT %(moduleimpl_id)s, I.etudid
@ -195,7 +202,7 @@ def do_moduleimpl_inscrit_tout_semestre(context, moduleimpl_id, formsemestre_id)
# --- Inscriptions aux modules
_moduleimpl_inscriptionEditor = EditableTable(
_moduleimpl_inscriptionEditor = ndb.EditableTable(
"notes_moduleimpl_inscription",
"moduleimpl_inscription_id",
("moduleimpl_inscription_id", "etudid", "moduleimpl_id"),
@ -237,6 +244,8 @@ def do_moduleimpl_inscrit_etuds(
"""Inscrit les etudiants (liste d'etudids) a ce module.
Si reset, desinscrit tous les autres.
"""
from app.scodoc import sco_formsemestre_inscriptions
# Verifie qu'ils sont tous bien inscrits au semestre
for etudid in etudids:
insem = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
@ -248,7 +257,7 @@ def do_moduleimpl_inscrit_etuds(
# Desinscriptions
if reset:
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"delete from notes_moduleimpl_inscription where moduleimpl_id = %(moduleimpl_id)s",
{"moduleimpl_id": moduleimpl_id},

View File

@ -29,16 +29,22 @@
"""
import notesdb as ndb
import sco_utils as scu
from notes_log import log
from scolog import logdb
import sco_formsemestre
import sco_moduleimpl
import sco_groups
import htmlutils
from sco_permissions import ScoEtudInscrit
from sco_exceptions import ScoValueError
import app.scodoc.notesdb as ndb
import app.scodoc.sco_utils as scu
from app.scodoc.notes_log import log
from app.scodoc.scolog import logdb
from app.scodoc import html_sco_header
from app.scodoc import htmlutils
from app.scodoc import sco_core
from app.scodoc import sco_edit_module
from app.scodoc import sco_edit_ue
from app.scodoc import sco_formsemestre
from app.scodoc import sco_formsemestre_inscriptions
from app.scodoc import sco_groups
from app.scodoc import sco_moduleimpl
from app.scodoc import sco_etud
from app.scodoc.sco_exceptions import ScoValueError
from app.scodoc.sco_permissions import Permission
def moduleimpl_inscriptions_edit(
@ -87,7 +93,7 @@ def moduleimpl_inscriptions_edit(
# Liste des inscrits à ce semestre
inscrits = context.Notes.do_formsemestre_inscription_listinscrits(formsemestre_id)
for ins in inscrits:
etuds_info = scolars.get_etud_info(etudid=ins["etudid"], filled=1)
etuds_info = sco_etud.get_etud_info(etudid=ins["etudid"], filled=1)
if not etuds_info:
log(
"moduleimpl_inscriptions_edit: incoherency for etudid=%s !"
@ -238,8 +244,8 @@ def moduleimpl_inscriptions_stats(context, formsemestre_id, REQUEST=None):
authuser = REQUEST.AUTHENTICATED_USER
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
inscrits = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context,
args={"formsemestre_id": formsemestre_id}
inscrits = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, args={"formsemestre_id": formsemestre_id}
)
set_all = set([x["etudid"] for x in inscrits])
partitions, partitions_etud_groups = sco_groups.get_formsemestre_groups(
@ -334,7 +340,10 @@ def moduleimpl_inscriptions_stats(context, formsemestre_id, REQUEST=None):
UECaps = get_etuds_with_capitalized_ue(context, formsemestre_id)
if UECaps:
H.append('<h3>Etudiants avec UEs capitalisées:</h3><ul class="ue_inscr_list">')
ues = [sco_edit_ue.do_ue_list(context, {"ue_id": ue_id})[0] for ue_id in UECaps.keys()]
ues = [
sco_edit_ue.do_ue_list(context, {"ue_id": ue_id})[0]
for ue_id in UECaps.keys()
]
ues.sort(key=lambda u: u["numero"])
for ue in ues:
H.append(
@ -342,7 +351,7 @@ def moduleimpl_inscriptions_stats(context, formsemestre_id, REQUEST=None):
)
H.append("<ul>")
for info in UECaps[ue["ue_id"]]:
etud = scolars.get_etud_info(etudid=info["etudid"], filled=True)[0]
etud = sco_etud.get_etud_info(etudid=info["etudid"], filled=True)[0]
H.append(
'<li class="etud"><a class="discretelink" href="ficheEtud?etudid=%(etudid)s">%(nomprenom)s</a>'
% etud
@ -446,7 +455,7 @@ def _fmt_etud_set(context, ins, max_list_size=7):
return "%d étudiants" % len(ins)
etuds = []
for etudid in ins:
etuds.append(scolars.get_etud_info(etudid=etudid, filled=True)[0])
etuds.append(sco_etud.get_etud_info(etudid=etudid, filled=True)[0])
etuds.sort(lambda x, y: cmp(x["nom"], y["nom"]))
return ", ".join(
[
@ -465,8 +474,8 @@ def get_etuds_with_capitalized_ue(context, formsemestre_id):
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > get_ues, get_etud_ue_status
inscrits = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context,
args={"formsemestre_id": formsemestre_id}
inscrits = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, args={"formsemestre_id": formsemestre_id}
)
ues = nt.get_ues()
for ue in ues:
@ -544,8 +553,8 @@ def do_etud_desinscrit_ue(context, etudid, formsemestre_id, ue_id, REQUEST=None)
def do_etud_inscrit_ue(context, etudid, formsemestre_id, ue_id, REQUEST=None):
"""Incrit l'etudiant de tous les modules de cette UE dans ce semestre."""
# Verifie qu'il est bien inscrit au semestre
insem = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context,
args={"formsemestre_id": formsemestre_id, "etudid": etudid}
insem = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, args={"formsemestre_id": formsemestre_id, "etudid": etudid}
)
if not insem:
raise ScoValueError("%s n'est pas inscrit au semestre !" % etudid)

View File

@ -28,31 +28,25 @@
"""Tableau de bord module
"""
import time
import urllib
import sco_utils as scu
from sco_utils import (
EVALUATION_NORMALE,
EVALUATION_RATTRAPAGE,
EVALUATION_SESSION2,
)
from sco_permissions import ScoEtudInscrit, ScoAbsChange
from notes_log import log
from TrivialFormulator import TrivialFormulator, TF
import app.scodoc.sco_utils as scu
from app.scodoc.sco_permissions import Permission
# from notes_table import *
import sco_groups
import sco_evaluations
import htmlutils
import sco_excel
from gen_tables import GenTable
from htmlutils import histogram_notes
import sco_moduleimpl
import sco_formsemestre
import sco_formsemestre_status
import htmlutils
import sco_saisie_notes
import sco_compute_moy
import sco_abs
from app.scodoc import html_sco_header
from app.scodoc import htmlutils
from app.scodoc import sco_abs
from app.scodoc import sco_compute_moy
from app.scodoc import sco_core
from app.scodoc import sco_edit_module
from app.scodoc import sco_evaluations
from app.scodoc import sco_formations
from app.scodoc import sco_formsemestre
from app.scodoc import sco_formsemestre_status
from app.scodoc import sco_groups
from app.scodoc import sco_moduleimpl
from app.scodoc import sco_permissions_check
from app.scodoc import sco_saisie_notes
# ported from old DTML code in oct 2009
@ -67,7 +61,7 @@ def moduleimpl_evaluation_menu(context, evaluation_id, nbnotes=0, REQUEST=None):
group_id = sco_groups.get_default_group(context, modimpl["formsemestre_id"])
if (
sco_saisie_notes.can_edit_notes(
sco_permissions_check.can_edit_notes(
context, REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"], allow_ens=False
)
and nbnotes != 0
@ -83,7 +77,7 @@ def moduleimpl_evaluation_menu(context, evaluation_id, nbnotes=0, REQUEST=None):
"args": {
"evaluation_id": evaluation_id,
},
"enabled": sco_saisie_notes.can_edit_notes(
"enabled": sco_permissions_check.can_edit_notes(
context, REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"]
),
},
@ -93,7 +87,7 @@ def moduleimpl_evaluation_menu(context, evaluation_id, nbnotes=0, REQUEST=None):
"args": {
"evaluation_id": evaluation_id,
},
"enabled": sco_saisie_notes.can_edit_notes(
"enabled": sco_permissions_check.can_edit_notes(
context, REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"], allow_ens=False
),
},
@ -104,7 +98,7 @@ def moduleimpl_evaluation_menu(context, evaluation_id, nbnotes=0, REQUEST=None):
"evaluation_id": evaluation_id,
},
"enabled": nbnotes == 0
and sco_saisie_notes.can_edit_notes(
and sco_permissions_check.can_edit_notes(
context, REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"], allow_ens=False
),
},
@ -114,7 +108,7 @@ def moduleimpl_evaluation_menu(context, evaluation_id, nbnotes=0, REQUEST=None):
"args": {
"evaluation_id": evaluation_id,
},
"enabled": sco_saisie_notes.can_edit_notes(
"enabled": sco_permissions_check.can_edit_notes(
context, REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"], allow_ens=False
),
},
@ -133,14 +127,17 @@ def moduleimpl_evaluation_menu(context, evaluation_id, nbnotes=0, REQUEST=None):
"evaluation_id": evaluation_id,
},
"enabled": nbnotes == 0
and sco_saisie_notes.can_edit_notes(
and sco_permissions_check.can_edit_notes(
context, REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"]
),
},
{
"title": "Absences ce jour",
"endpoint": "absences.EtatAbsencesDate?date=%s&group_ids=%s"
% (endpointlib.quote(E["jour"], safe=""), group_id),
"endpoint": "absences.EtatAbsencesDate",
"args": {
"date": urllib.quote(E["jour"], safe=""),
"group_ids": group_id,
},
"enabled": E["jour"],
},
{
@ -163,7 +160,9 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No
formsemestre_id = M["formsemestre_id"]
Mod = sco_edit_module.do_module_list(context, args={"module_id": M["module_id"]})[0]
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
F = sco_formations.formation_list(context, args={"formation_id": sem["formation_id"]})[0]
F = sco_formations.formation_list(
context, args={"formation_id": sem["formation_id"]}
)[0]
ModInscrits = sco_moduleimpl.do_moduleimpl_inscription_list(
context, moduleimpl_id=M["moduleimpl_id"]
)
@ -171,16 +170,20 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No
nt = sco_core.get_notes_cache(
context,
).get_NotesTable(context, formsemestre_id)
ModEvals = sco_evaluations.do_evaluation_list(context, {"moduleimpl_id": moduleimpl_id})
ModEvals = sco_evaluations.do_evaluation_list(
context, {"moduleimpl_id": moduleimpl_id}
)
ModEvals.sort(
key=lambda x: (x["numero"], x["jour"], x["heure_debut"]), reverse=True
) # la plus RECENTE en tête
#
caneditevals = sco_saisie_notes.can_edit_notes(
caneditevals = sco_permissions_check.can_edit_notes(
context, authuser, moduleimpl_id, allow_ens=sem["ens_can_edit_eval"]
)
caneditnotes = sco_saisie_notes.can_edit_notes(context, authuser, moduleimpl_id)
caneditnotes = sco_permissions_check.can_edit_notes(
context, authuser, moduleimpl_id
)
arrow_up, arrow_down, arrow_none = sco_groups.getArrowIconsTags(context, REQUEST)
#
H = [
@ -281,7 +284,7 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No
# Adapté à partir d'une suggestion de DS (Le Havre)
# Liens saisies absences seulement si permission et date courante dans le semestre
if authuser.has_permission(
ScoAbsChange, context
Permission.ScoAbsChange
) and sco_formsemestre.sem_est_courant(context, sem):
datelundi = sco_abs.ddmmyyyy(time.strftime("%d/%m/%Y")).prev_monday()
group_id = sco_groups.get_default_group(context, formsemestre_id)
@ -366,7 +369,10 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No
partition_id=partition_id,
select_first_partition=True,
)
if eval["evaluation_type"] in (EVALUATION_RATTRAPAGE, EVALUATION_SESSION2):
if eval["evaluation_type"] in (
scu.EVALUATION_RATTRAPAGE,
scu.EVALUATION_SESSION2,
):
tr_class = "mievr mievr_rattr"
else:
tr_class = "mievr"
@ -385,11 +391,11 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No
% eval
)
H.append("&nbsp;&nbsp;&nbsp; <em>%(description)s</em>" % eval)
if eval["evaluation_type"] == EVALUATION_RATTRAPAGE:
if eval["evaluation_type"] == scu.EVALUATION_RATTRAPAGE:
H.append(
"""<span class="mievr_rattr" title="remplace si meilleure note">rattrapage</span>"""
)
elif eval["evaluation_type"] == EVALUATION_SESSION2:
elif eval["evaluation_type"] == scu.EVALUATION_SESSION2:
H.append(
"""<span class="mievr_rattr" title="remplace autres notes">session 2</span>"""
)

View File

@ -27,23 +27,24 @@
"""Gestions des "nouvelles"
"""
import PyRSS2Gen # pylint: disable=import-error
from cStringIO import StringIO
import datetime, re
import datetime
import re
import time
from stripogram import html2text, html2safehtml
from cStringIO import StringIO
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.header import Header
from stripogram import html2text
import PyRSS2Gen # pylint: disable=import-error
import notesdb as ndb
from notes_log import log
import mails
import scolars
from sco_utils import SCO_ENCODING, SCO_ANNONCES_WEBSITE
import sco_formsemestre
import sco_moduleimpl
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from app.scodoc.notes_log import log
from app.scodoc import mails
from app.scodoc.sco_utils import SCO_ENCODING, SCO_ANNONCES_WEBSITE
from app.scodoc import sco_formsemestre
from app.scodoc import sco_moduleimpl
from app.scodoc import sco_preferences
_scolar_news_editor = ndb.EditableTable(
"scolar_news",
@ -109,6 +110,7 @@ def scolar_news_summary(context, n=5):
"""Return last n news.
News are "compressed", ie redondant events are joined.
"""
from app.scodoc import sco_etud
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
@ -140,7 +142,7 @@ def scolar_news_summary(context, n=5):
n[k] = _scolar_news_editor.output_formators[k](n[k])
# date resumee
j, m = n["date"].split("/")[:2]
mois = scolars.abbrvmonthsnames[int(m) - 1]
mois = sco_etud.MONTH_NAMES_ABBREV[int(m) - 1]
n["formatted_date"] = "%s %s %s" % (j, mois, n["hm"])
# indication semestre si ajout notes:
infos = _get_formsemestre_infos_from_news(context, n)

View File

@ -31,31 +31,26 @@
"""
import sco_utils as scu
import notesdb as ndb
from notes_log import log
import scolars
import sco_bac
import sco_photos
import sco_groups
import sco_formsemestre
from scolars import format_telephone, format_pays, make_etud_args
import sco_formsemestre_status
import htmlutils
import html_sco_header
from sco_bulletins import etud_descr_situation_semestre
import sco_parcours_dut
import sco_codes_parcours
from sco_formsemestre_validation import formsemestre_recap_parcours_table
import sco_archives_etud
import sco_report
from sco_permissions import (
ScoEtudChangeGroups,
ScoEtudInscrit,
ScoImplement,
ScoEtudChangeAdr,
)
from sco_exceptions import ScoValueError
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from app.scodoc.notes_log import log
from app.scodoc import html_sco_header
from app.scodoc import htmlutils
from app.scodoc import sco_archives_etud
from app.scodoc import sco_bac
from app.scodoc import sco_codes_parcours
from app.scodoc import sco_formsemestre
from app.scodoc import sco_formsemestre_status
from app.scodoc import sco_groups
from app.scodoc import sco_parcours_dut
from app.scodoc import sco_permissions_check
from app.scodoc import sco_photos
from app.scodoc import sco_report
from app.scodoc import sco_etud
from app.scodoc.sco_bulletins import etud_descr_situation_semestre
from app.scodoc.sco_exceptions import ScoValueError
from app.scodoc.sco_formsemestre_validation import formsemestre_recap_parcours_table
from app.scodoc.sco_permissions import Permission
def _menuScolarite(context, authuser, sem, etudid):
@ -67,7 +62,7 @@ def _menuScolarite(context, authuser, sem, etudid):
lockicon = scu.icontag("lock32_img", title="verrouillé", border="0")
return lockicon # no menu
if not authuser.has_permission(
ScoEtudInscrit, context
Permission.ScoEtudInscrit
) and not authuser.has_permission(Permission.ScoEtudChangeGroups):
return "" # no menu
ins = sem["ins"]
@ -147,14 +142,14 @@ def ficheEtud(context, etudid=None, REQUEST=None):
# la sidebar est differente s'il y a ou pas un etudid
# voir html_sidebar.sidebar()
REQUEST.form["etudid"] = etudid
args = make_etud_args(etudid=etudid, REQUEST=REQUEST)
etuds = scolars.etudident_list(cnx, args)
args = sco_etud.make_etud_args(etudid=etudid, REQUEST=REQUEST)
etuds = sco_etud.etudident_list(cnx, args)
if not etuds:
log("ficheEtud: etudid=%s REQUEST.form=%s" % (etudid, REQUEST.form))
raise ScoValueError("Etudiant inexistant !")
etud = etuds[0]
etudid = etud["etudid"]
scolars.fillEtudsInfo(context, [etud])
sco_etud.fill_etuds_info([etud])
#
info = etud
info["ScoURL"] = scu.ScoURL()
@ -172,7 +167,7 @@ def ficheEtud(context, etudid=None, REQUEST=None):
):
info["domicile"] = "<em>inconnue</em>"
if info["paysdomicile"]:
pays = format_pays(info["paysdomicile"])
pays = sco_etud.format_pays(info["paysdomicile"])
if pays:
info["paysdomicile"] = "(%s)" % pays
else:
@ -273,9 +268,9 @@ def ficheEtud(context, etudid=None, REQUEST=None):
# Liste des annotations
alist = []
annos = scolars.etud_annotations_list(cnx, args={"etudid": etudid})
annos = sco_etud.etud_annotations_list(cnx, args={"etudid": etudid})
for a in annos:
if not sco_permissions.can_suppress_annotation(context, a["id"], REQUEST):
if not sco_permissions_check.can_suppress_annotation(context, a["id"], REQUEST):
a["dellink"] = ""
else:
a[
@ -351,7 +346,7 @@ def ficheEtud(context, etudid=None, REQUEST=None):
# Devenir de l'étudiant:
has_debouche = True # info['debouche']
if sco_permissions.can_edit_suivi(context, REQUEST):
if sco_permissions_check.can_edit_suivi(context, REQUEST):
suivi_readonly = "0"
link_add_suivi = """<li class="adddebouche">
<a id="adddebouchelink" class="stdlink" href="#">ajouter une ligne</a>
@ -496,7 +491,7 @@ def menus_etud(context, REQUEST=None):
return ""
authuser = REQUEST.AUTHENTICATED_USER
etud = scolars.get_etud_info(filled=1, REQUEST=REQUEST)[0]
etud = sco_etud.get_etud_info(filled=1, REQUEST=REQUEST)[0]
menuEtud = [
{
@ -550,7 +545,7 @@ def etud_info_html(context, etudid, with_photo="1", REQUEST=None, debug=False):
# log('etud_info_html: formsemestre_id=%s' % formsemestre_id)
with_photo = int(with_photo)
etud = scolars.get_etud_info(filled=1, REQUEST=REQUEST)[0]
etud = sco_etud.get_etud_info(filled=1, REQUEST=REQUEST)[0]
photo_html = sco_photos.etud_photo_html(
context, etud, title="fiche de " + etud["nom"], REQUEST=REQUEST
)

View File

@ -29,13 +29,14 @@
"""
from types import FloatType
import sco_utils as scu
import notesdb as ndb
from notes_log import log
from scolog import logdb
import sco_formsemestre
from sco_codes_parcours import (
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from app.scodoc.notes_log import log
from app.scodoc.scolog import logdb
from app.scodoc import sco_core
from app.scodoc import sco_formsemestre
from app.scodoc import sco_formations
from app.scodoc.sco_codes_parcours import (
CMP,
ADC,
ADJ,
@ -58,8 +59,8 @@ from sco_codes_parcours import (
code_semestre_attente,
code_semestre_validant,
)
from dutrules import DUTRules # regles generees a partir du CSV
from sco_exceptions import ScoValueError
from app.scodoc.dutrules import DUTRules # regles generees a partir du CSV
from app.scodoc.sco_exceptions import ScoValueError
class DecisionSem:
@ -120,7 +121,7 @@ class SituationEtudParcoursGeneric:
def __init__(self, context, etud, formsemestre_id, nt):
"""
etud: dict filled by fillEtudsInfo()
etud: dict filled by fill_etuds_info()
"""
self.context = context
self.etud = etud
@ -295,7 +296,7 @@ class SituationEtudParcoursGeneric:
sem["semestre_id"] == n1
and sem["formation_code"] == self.formation["formation_code"]
):
nt = self.sco_core.get_notes_cache(context).get_NotesTable(
nt = sco_core.get_notes_cache(self.context).get_NotesTable(
self.context, sem["formsemestre_id"]
) # > get_etud_decision_sem
decision = nt.get_etud_decision_sem(self.etudid)
@ -311,7 +312,7 @@ class SituationEtudParcoursGeneric:
sont validés. En sortie, sem_idx_set contient ceux qui n'ont pas été validés."""
for sem in self.get_semestres():
if sem["formation_code"] == self.formation["formation_code"]:
nt = self.sco_core.get_notes_cache(context).get_NotesTable(
nt = sco_core.get_notes_cache(self.context).get_NotesTable(
self.context, sem["formsemestre_id"]
) # > get_etud_decision_sem
decision = nt.get_etud_decision_sem(self.etudid)
@ -322,14 +323,14 @@ class SituationEtudParcoursGeneric:
return not sem_idx_set
def _comp_semestres(self):
# etud['sems'] est trie par date decroissante (voir fillEtudsInfo)
# etud['sems'] est trie par date decroissante (voir fill_etuds_info)
sems = self.etud["sems"][:] # copy
sems.reverse()
# Nb max d'UE et acronymes
ue_acros = {} # acronyme ue : 1
nb_max_ue = 0
for sem in sems:
nt = self.sco_core.get_notes_cache(context).get_NotesTable(
nt = sco_core.get_notes_cache(self.context).get_NotesTable(
self.context, sem["formsemestre_id"]
) # > get_ues
ues = nt.get_ues(filter_sport=True)
@ -339,8 +340,8 @@ class SituationEtudParcoursGeneric:
if nb_ue > nb_max_ue:
nb_max_ue = nb_ue
# add formation_code to each sem:
sem["formation_code"] = self.sco_formations.formation_list(context,
args={"formation_id": sem["formation_id"]}
sem["formation_code"] = sco_formations.formation_list(
self.context, args={"formation_id": sem["formation_id"]}
)[0]["formation_code"]
# si sem peut servir à compenser le semestre courant, positionne
# can_compensate
@ -399,7 +400,7 @@ class SituationEtudParcoursGeneric:
if not sem:
code = "" # non inscrit à ce semestre
else:
nt = self.sco_core.get_notes_cache(context).get_NotesTable(
nt = sco_core.get_notes_cache(self.context).get_NotesTable(
self.context, sem["formsemestre_id"]
) # > get_etud_decision_sem
decision = nt.get_etud_decision_sem(self.etudid)
@ -471,7 +472,7 @@ class SituationEtudParcoursGeneric:
# Verifications basiques:
# ?
# Code etat du semestre precedent:
nt = self.sco_core.get_notes_cache(context).get_NotesTable(
nt = sco_core.get_notes_cache(self.context).get_NotesTable(
self.context, prev["formsemestre_id"]
) # > get_etud_decision_sem, get_etud_moy_gen, etud_check_conditions_ues
self.prev_decision = nt.get_etud_decision_sem(self.etudid)
@ -530,7 +531,7 @@ class SituationEtudParcoursGeneric:
sem["formation_code"] == self.formation["formation_code"]
and sem["semestre_id"] == s
):
nt = self.sco_core.get_notes_cache(context).get_NotesTable(
nt = sco_core.get_notes_cache(self.context).get_NotesTable(
self.context, sem["formsemestre_id"]
) # > get_etud_decision_sem
decision = nt.get_etud_decision_sem(self.etudid)
@ -629,8 +630,8 @@ class SituationEtudParcoursGeneric:
REQUEST=REQUEST,
)
self.sco_core.inval_cache(
context, formsemestre_id=self.prev["formsemestre_id"]
sco_core.inval_cache(
self.context, formsemestre_id=self.prev["formsemestre_id"]
) # > modif decisions jury (sem, UE)
# -- supprime autorisations venant de ce formsemestre
@ -659,17 +660,18 @@ class SituationEtudParcoursGeneric:
except:
cnx.rollback()
raise
self.sco_core.inval_cache(
context, formsemestre_id=self.formsemestre_id
sco_core.inval_cache(
self.context, formsemestre_id=self.formsemestre_id
) # > modif decisions jury et autorisations inscription
if decision.formsemestre_id_utilise_pour_compenser:
# inval aussi le semestre utilisé pour compenser:
self.sco_core.inval_cache(
context, formsemestre_id=decision.formsemestre_id_utilise_pour_compenser
sco_core.inval_cache(
self.context,
formsemestre_id=decision.formsemestre_id_utilise_pour_compenser,
) # > modif decision jury
for formsemestre_id in to_invalidate:
self.sco_core.inval_cache(
context, formsemestre_id=formsemestre_id
sco_core.inval_cache(
self.context, formsemestre_id=formsemestre_id
) # > modif decision jury
@ -1098,7 +1100,9 @@ def list_formsemestre_utilisateurs_uecap(context, formsemestre_id):
semestre): meme code formation, meme semestre_id, date posterieure"""
cnx = ndb.GetDBConnexion()
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
F = sco_formations.formation_list(context, args={"formation_id": sem["formation_id"]})[0]
F = sco_formations.formation_list(
context, args={"formation_id": sem["formation_id"]}
)[0]
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"""select sem.formsemestre_id

View File

@ -52,12 +52,17 @@ from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY
from reportlab.lib import styles
from reportlab.lib.pagesizes import letter, A4, landscape
import sco_utils as scu
from sco_utils import CONFIG, SCO_ENCODING, SCODOC_LOGOS_DIR, LOGOS_IMAGES_ALLOWED_TYPES
from notes_log import log
from sco_exceptions import ScoGenError
import app.scodoc.sco_utils as scu
from app.scodoc.sco_utils import (
CONFIG,
SCO_ENCODING,
SCODOC_LOGOS_DIR,
LOGOS_IMAGES_ALLOWED_TYPES,
)
from app.scodoc.notes_log import log
from app.scodoc.sco_exceptions import ScoGenError
from SuppressAccents import suppression_diacritics
import VERSION
from app.scodoc import VERSION
from VERSION import SCOVERSION, SCONAME
PAGE_HEIGHT = defaultPageSize[1]

View File

@ -57,67 +57,3 @@ class Permission:
Permission.init_permissions()
import notesdb as ndb
import scolars
import sco_formsemestre
def can_suppress_annotation(context, annotation_id, REQUEST):
"""True if current user can suppress this annotation
Seuls l'auteur de l'annotation et le chef de dept peuvent supprimer
une annotation.
"""
cnx = ndb.GetDBConnexion()
annos = scolars.etud_annotations_list(cnx, args={"id": annotation_id})
if len(annos) != 1:
raise ScoValueError("annotation inexistante !")
anno = annos[0]
authuser = REQUEST.AUTHENTICATED_USER
# note: les anciennes installations n'ont pas le role ScoEtudSupprAnnotations
# c'est pourquoi on teste aussi ScoEtudInscrit (normalement détenue par le chef)
return (
(str(authuser) == anno["zope_authenticated_user"])
or authuser.has_permission(Permission.ScoEtudSupprAnnotations)
or authuser.has_permission(Permission.ScoEtudInscrit)
)
def can_edit_suivi(context, REQUEST=None):
"""Vrai si l'utilisateur peut modifier les informations de suivi sur la page etud" """
authuser = REQUEST.AUTHENTICATED_USER
return authuser.has_permission(Permission.ScoEtudChangeAdr)
def can_validate_sem(context, REQUEST, formsemestre_id):
"Vrai si utilisateur peut saisir decision de jury dans ce semestre"
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
if sem["etat"] != "1":
return False # semestre verrouillé
return is_chef_or_diretud(context, REQUEST, sem)
def can_edit_pv(context, REQUEST, formsemestre_id):
"Vrai si utilisateur peut editer un PV de jury de ce semestre"
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
if is_chef_or_diretud(context, REQUEST, sem):
return True
# Autorise les secrétariats, repérés via la permission ScoEtudChangeAdr
# (ceci nous évite d'ajouter une permission Zope aux installations existantes)
authuser = REQUEST.AUTHENTICATED_USER
return authuser.has_permission(Permission.ScoEtudChangeAdr)
def is_chef_or_diretud(context, REQUEST, sem):
"Vrai si utilisateur est admin, chef dept ou responsable du semestre"
authuser = REQUEST.AUTHENTICATED_USER
if authuser.has_permission(Permission.ScoImplement):
return True # admin, chef dept
uid = str(authuser)
if uid in sem["responsables"]:
return True
return False

View File

@ -0,0 +1,139 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
"""Functions checking permissions for some common operations
"""
import app.scodoc.notesdb as ndb
from app.scodoc.sco_permissions import Permission
from app.scodoc import html_sco_header
from app.scodoc import sco_etud
from app.scodoc import sco_exceptions
from app.scodoc import sco_formsemestre
from app.scodoc import sco_moduleimpl
from app.scodoc import sco_parcours_dut
def can_edit_notes(context, authuser, moduleimpl_id, allow_ens=True):
"""True if authuser can enter or edit notes in this module.
If allow_ens, grant access to all ens in this module
Si des décisions de jury ont déjà été saisies dans ce semestre,
seul le directeur des études peut saisir des notes (et il ne devrait pas).
"""
uid = str(authuser)
M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=moduleimpl_id)[0]
sem = sco_formsemestre.get_formsemestre(context, M["formsemestre_id"])
if sem["etat"] != "1":
return False # semestre verrouillé
if sco_parcours_dut.formsemestre_has_decisions(context, sem["formsemestre_id"]):
# il y a des décisions de jury dans ce semestre !
return (
authuser.has_permission(Permission.ScoEditAllNotes)
or uid in sem["responsables"]
)
else:
if (
(not authuser.has_permission(Permission.ScoEditAllNotes))
and uid != M["responsable_id"]
and uid not in sem["responsables"]
):
# enseignant (chargé de TD) ?
if allow_ens:
for ens in M["ens"]:
if ens["ens_id"] == uid:
return True
return False
else:
return True
def can_suppress_annotation(context, annotation_id, REQUEST):
"""True if current user can suppress this annotation
Seuls l'auteur de l'annotation et le chef de dept peuvent supprimer
une annotation.
"""
cnx = ndb.GetDBConnexion()
annos = sco_etud.etud_annotations_list(cnx, args={"id": annotation_id})
if len(annos) != 1:
raise sco_exceptions.ScoValueError("annotation inexistante !")
anno = annos[0]
authuser = REQUEST.AUTHENTICATED_USER
# note: les anciennes installations n'ont pas le role ScoEtudSupprAnnotations
# c'est pourquoi on teste aussi ScoEtudInscrit (normalement détenue par le chef)
return (
(str(authuser) == anno["zope_authenticated_user"])
or authuser.has_permission(Permission.ScoEtudSupprAnnotations)
or authuser.has_permission(Permission.ScoEtudInscrit)
)
def can_edit_suivi(context, REQUEST=None):
"""Vrai si l'utilisateur peut modifier les informations de suivi sur la page etud" """
authuser = REQUEST.AUTHENTICATED_USER
return authuser.has_permission(Permission.ScoEtudChangeAdr)
def can_validate_sem(context, REQUEST, formsemestre_id):
"Vrai si utilisateur peut saisir decision de jury dans ce semestre"
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
if sem["etat"] != "1":
return False # semestre verrouillé
return is_chef_or_diretud(context, REQUEST, sem)
def can_edit_pv(context, REQUEST, formsemestre_id):
"Vrai si utilisateur peut editer un PV de jury de ce semestre"
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
if is_chef_or_diretud(context, REQUEST, sem):
return True
# Autorise les secrétariats, repérés via la permission ScoEtudChangeAdr
# (ceci nous évite d'ajouter une permission Zope aux installations existantes)
authuser = REQUEST.AUTHENTICATED_USER
return authuser.has_permission(Permission.ScoEtudChangeAdr)
def is_chef_or_diretud(context, REQUEST, sem):
"Vrai si utilisateur est admin, chef dept ou responsable du semestre"
authuser = REQUEST.AUTHENTICATED_USER
if authuser.has_permission(Permission.ScoImplement):
return True # admin, chef dept
uid = str(authuser)
if uid in sem["responsables"]:
return True
return False
def check_access_diretud(
context, formsemestre_id, REQUEST, required_permission=Permission.ScoImplement
):
"""Check if access granted: responsable or ScoImplement
Return True|False, HTML_error_page
"""
authuser = REQUEST.AUTHENTICATED_USER
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
header = html_sco_header.sco_header(
context, page_title="Accès interdit", REQUEST=REQUEST
)
footer = html_sco_header.sco_footer(context, REQUEST)
if (str(authuser) not in sem["responsables"]) and not authuser.has_permission(
required_permission
):
return (
False,
"\n".join(
[
header,
"<h2>Opération non autorisée pour %s</h2>" % authuser,
"<p>Responsable de ce semestre : <b>%s</b></p>"
% ", ".join(sem["responsables"]),
footer,
]
),
)
else:
return True, ""

View File

@ -54,17 +54,18 @@ from cStringIO import StringIO
import glob
from config import Config
from sco_utils import CONFIG, SCO_SRC_DIR
import notesdb as ndb
from notes_log import log
import scolars
import sco_portal_apogee
from scolog import logdb
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from app.scodoc.notes_log import log
from app.scodoc.scolog import logdb
from app.scodoc import sco_portal_apogee
from app.scodoc import sco_preferences
from app.scodoc import sco_etud
# Full paths on server's filesystem. Something like "/opt/scodoc/var/scodoc/photos"
PHOTO_DIR = os.path.join(Config.INSTANCE_HOME, "var", "scodoc", "photos")
ICONS_DIR = os.path.join(SCO_SRC_DIR, "app", "static", "icons")
ICONS_DIR = os.path.join(scu.SCO_SRC_DIR, "app", "static", "icons")
UNKNOWN_IMAGE_PATH = os.path.join(ICONS_DIR, "unknown.jpg")
UNKNOWN_IMAGE_URL = "get_photo_image?etudid=" # with empty etudid => unknown face image
IMAGE_EXT = ".jpg"
@ -104,7 +105,7 @@ def etud_photo_url(context, etud, size="small", fast=False, REQUEST=None):
if not new_path:
# copy failed, can we use external url ?
# nb: rarement utile, car le portail est rarement accessible sans authentification
if CONFIG.PUBLISH_PORTAL_PHOTO_URL:
if scu.CONFIG.PUBLISH_PORTAL_PHOTO_URL:
photo_url = ext_url
else:
photo_url = UNKNOWN_IMAGE_URL
@ -118,7 +119,7 @@ def get_photo_image(context, etudid=None, size="small", REQUEST=None):
if not etudid:
filename = UNKNOWN_IMAGE_PATH
else:
etud = scolars.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST)[0]
etud = sco_etud.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST)[0]
filename = photo_pathname(context, etud, size=size)
if not filename:
filename = UNKNOWN_IMAGE_PATH
@ -173,7 +174,7 @@ def etud_photo_html(
"""
if not etud:
if etudid:
etud = scolars.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST)[0]
etud = sco_etud.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST)[0]
else:
raise ValueError("etud_photo_html: either etud or etudid must be specified")
photo_url = etud_photo_url(context, etud, size=size, REQUEST=REQUEST)
@ -247,7 +248,7 @@ def store_photo(context, etud, data, REQUEST=None):
etud["foto"] = None
cnx = ndb.GetDBConnexion()
scolars.identite_edit_nocheck(cnx, etud)
sco_etud.identite_edit_nocheck(cnx, etud)
cnx.commit()
#
if REQUEST:
@ -263,7 +264,7 @@ def suppress_photo(context, etud, REQUEST=None):
# 1- remove ref. from database
etud["photo_filename"] = None
cnx = ndb.GetDBConnexion()
scolars.identite_edit_nocheck(cnx, etud)
sco_etud.identite_edit_nocheck(cnx, etud)
cnx.commit()
# 2- erase images files
if rel_path:
@ -341,7 +342,7 @@ def copy_portal_photo_to_fs(context, etud, REQUEST=None):
"""Copy the photo from portal (distant website) to local fs.
Returns rel. path or None if copy failed, with a diagnotic message
"""
scolars.format_etud_ident(etud)
sco_etud.format_etud_ident(etud)
url = photo_portal_url(context, etud)
if not url:
return None, "%(nomprenom)s: pas de code NIP" % etud

View File

@ -33,20 +33,25 @@ Contribution M. Salomon, UFC / IUT DE BELFORT-MONTBÉLIARD, 2016
import urllib
import random
import sco_utils as scu
import notesdb as ndb
from notes_log import log
import scolars
import sco_formsemestre
import sco_moduleimpl
import sco_groups
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
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from app.scodoc.notes_log import log
from app.scodoc import html_sco_header
from app.scodoc import sco_edit_module
from app.scodoc import sco_evaluations
from app.scodoc import sco_excel
from app.scodoc import sco_formsemestre
from app.scodoc import sco_formsemestre_inscriptions
from app.scodoc import sco_groups
from app.scodoc import sco_moduleimpl
from app.scodoc import sco_permissions_check
from app.scodoc import sco_preferences
from app.scodoc import sco_saisie_notes
from app.scodoc import sco_etud
from app.scodoc import VERSION
from app.scodoc.gen_tables import GenTable
from app.scodoc.sco_excel import *
from app.scodoc.TrivialFormulator import TrivialFormulator
def do_placement_selectetuds(context, REQUEST):
@ -240,7 +245,7 @@ def do_placement(context, REQUEST):
# Check access
# (admin, respformation, and responsable_id)
if not sco_saisie_notes.can_edit_notes(context, authuser, E["moduleimpl_id"]):
if not sco_permissions_check.can_edit_notes(context, authuser, E["moduleimpl_id"]):
return (
"<h2>Génération du placement impossible pour %s</h2>" % authusername
+ """<p>(vérifiez que le semestre n'est pas verrouillé et que vous
@ -294,12 +299,12 @@ def do_placement(context, REQUEST):
listetud = [] # liste de couples (nom,prenom)
for etudid in etudids:
# infos identite etudiant (xxx sous-optimal: 1/select par etudiant)
ident = scolars.etudident_list(cnx, {"etudid": etudid})[
ident = sco_etud.etudident_list(cnx, {"etudid": etudid})[
0
] # XXX utiliser ZScolar (parent)
# infos inscription
inscr = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context,
{"etudid": etudid, "formsemestre_id": M["formsemestre_id"]}
inscr = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, {"etudid": etudid, "formsemestre_id": M["formsemestre_id"]}
)[0]
if inscr["etat"] != "D":
nom = scu.strupper(ident["nom"])
@ -395,7 +400,9 @@ def do_placement(context, REQUEST):
def placement_eval_selectetuds(context, evaluation_id, REQUEST=None):
"""Dialogue placement etudiants: choix methode et localisation"""
evals = sco_evaluations.do_evaluation_list(context, {"evaluation_id": evaluation_id})
evals = sco_evaluations.do_evaluation_list(
context, {"evaluation_id": evaluation_id}
)
if not evals:
raise ScoValueError("invalid evaluation_id")
theeval = evals[0]

View File

@ -35,11 +35,10 @@ import xml.sax.saxutils
import xml.dom.minidom
import datetime
import sco_utils as scu
from sco_utils import SCO_ENCODING
from sco_permissions import ScoEtudInscrit
from sco_exceptions import ScoValueError
from notes_log import log
import app.scodoc.sco_utils as scu
from app.scodoc.notes_log import log
from app.scodoc.sco_exceptions import ScoValueError
from app.scodoc import sco_preferences
SCO_CACHE_ETAPE_FILENAME = os.path.join(scu.SCO_TMP_DIR, "last_etapes.xml")
@ -247,7 +246,9 @@ def xml_to_list_of_dicts(doc, req=None):
if e.nodeType == e.ELEMENT_NODE:
childs = e.childNodes
if len(childs):
d[str(e.nodeName)] = childs[0].nodeValue.encode(SCO_ENCODING)
d[str(e.nodeName)] = childs[0].nodeValue.encode(
scu.SCO_ENCODING
)
infos.append(d)
except:
log("*** invalid XML response from Etudiant Web Service")
@ -260,7 +261,7 @@ def xml_to_list_of_dicts(doc, req=None):
def get_infos_apogee_allaccents(context, nom, prenom):
"essai recup infos avec differents codages des accents"
if nom:
unom = unicode(nom, SCO_ENCODING)
unom = unicode(nom, scu.SCO_ENCODING)
nom_noaccents = str(scu.suppression_diacritics(unom))
nom_utf8 = unom.encode("utf-8")
else:
@ -268,7 +269,7 @@ def get_infos_apogee_allaccents(context, nom, prenom):
nom_utf8 = nom
if prenom:
uprenom = unicode(prenom, SCO_ENCODING)
uprenom = unicode(prenom, scu.SCO_ENCODING)
prenom_noaccents = str(scu.suppression_diacritics(uprenom))
prenom_utf8 = uprenom.encode("utf-8")
else:
@ -336,7 +337,7 @@ def get_etud_apogee(context, code_nip):
def get_default_etapes(context):
"""Liste par défaut, lue du fichier de config"""
filename = SCO_TOOLS_DIR + "/default-etapes.txt"
filename = scu.SCO_TOOLS_DIR + "/default-etapes.txt"
log("get_default_etapes: reading %s" % filename)
f = open(filename)
etapes = {}
@ -366,7 +367,7 @@ def _parse_etapes_from_xml(context, doc):
# Ancien format XML avec des sections par departement:
for d in dom.childNodes[0].childNodes:
if d.nodeType == d.ELEMENT_NODE:
dept = d.nodeName.encode(SCO_ENCODING)
dept = d.nodeName.encode(scu.SCO_ENCODING)
_xml_list_codes(infos, dept, d.childNodes)
else:
# Toutes les étapes:
@ -415,8 +416,8 @@ def get_etapes_apogee(context):
def _xml_list_codes(target_dict, dept, nodes):
for e in nodes:
if e.nodeType == e.ELEMENT_NODE:
intitule = e.childNodes[0].nodeValue.encode(SCO_ENCODING)
code = e.attributes["code"].value.encode(SCO_ENCODING)
intitule = e.childNodes[0].nodeValue.encode(scu.SCO_ENCODING)
code = e.attributes["code"].value.encode(scu.SCO_ENCODING)
if target_dict.has_key(dept):
target_dict[dept][code] = intitule
else:

View File

@ -31,14 +31,16 @@ Recapitule tous les semestres validés dans une feuille excel.
"""
import collections
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
import app.scodoc.sco_utils as scu
from app.scodoc import sco_abs
from app.scodoc import sco_core
from app.scodoc import sco_formsemestre
from app.scodoc import sco_groups
from app.scodoc import sco_preferences
from app.scodoc import sco_etud
from app.scodoc import VERSION
from app.scodoc.gen_tables import GenTable
from app.scodoc.sco_codes_parcours import code_semestre_validant, code_semestre_attente
def etud_get_poursuite_info(context, sem, etud):
@ -158,7 +160,7 @@ def _getEtudInfoGroupes(context, group_ids, etat=None):
for group_id in group_ids:
members = sco_groups.get_group_members(context, group_id, etat=etat)
for m in members:
etud = scolars.get_etud_info(etudid=m["etudid"], filled=True)[0]
etud = sco_etud.get_etud_info(etudid=m["etudid"], filled=True)[0]
etuds.append(etud)
return etuds

File diff suppressed because it is too large Load Diff

View File

@ -29,17 +29,17 @@
"""
import time
import sco_utils as scu
from notes_log import log
import notes_table
import sco_groups
import sco_excel
import sco_formsemestre
import sco_parcours_dut
import sco_codes_parcours
from scolars import format_nom, format_prenom, format_civilite, format_lycee
from sco_abs import getAbsSemEtud
import VERSION
import app.scodoc.sco_utils as scu
from app.scodoc import sco_groups
from app.scodoc import sco_core
from app.scodoc import sco_excel
from app.scodoc import sco_formsemestre
from app.scodoc import sco_parcours_dut
from app.scodoc import sco_codes_parcours
from app.scodoc.sco_abs import getAbsSemEtud
from app.scodoc import VERSION
from app.scodoc import sco_etud
from app.scodoc import sco_preferences
def feuille_preparation_jury(context, formsemestre_id, REQUEST):
@ -71,7 +71,7 @@ def feuille_preparation_jury(context, formsemestre_id, REQUEST):
nbabs = {}
nbabsjust = {}
for etudid in etudids:
info = scolars.get_etud_info(etudid=etudid, filled=True)
info = sco_etud.get_etud_info(etudid=etudid, filled=True)
if not info:
continue # should not occur...
etud = info[0]
@ -230,8 +230,8 @@ def feuille_preparation_jury(context, formsemestre_id, REQUEST):
l += [
etudid,
etud["civilite_str"],
format_nom(etud["nom"]),
format_prenom(etud["prenom"]),
sco_etud.format_nom(etud["nom"]),
sco_etud.format_prenom(etud["prenom"]),
etud["date_naissance"],
etud["bac"],
etud["specialite"],

View File

@ -26,29 +26,8 @@
##############################################################################
"""Edition des PV de jury
"""
import time
from reportlab.platypus import Paragraph
from reportlab.lib import styles
import sco_utils as scu
import notesdb as ndb
from notes_log import log
import scolars
import sco_formsemestre
import sco_groups
import sco_groups_view
import sco_parcours_dut
import sco_codes_parcours
from sco_codes_parcours import NO_SEMESTRE_ID
import sco_excel
from TrivialFormulator import TrivialFormulator
from gen_tables import GenTable
import sco_pvpdf
import sco_pdf
from sco_pdf import PDFLOCK
"""PV Jury IUTV 2006: on détaillait 8 cas:
PV Jury IUTV 2006: on détaillait 8 cas:
Jury de semestre n
On a 8 types de décisions:
Passages:
@ -67,6 +46,31 @@ Jury de semestre n
8. non validation de Sn-1 et Sn et non redoublement
"""
import time
from reportlab.platypus import Paragraph
from reportlab.lib import styles
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from app.scodoc.notes_log import log
from app.scodoc import html_sco_header
from app.scodoc import sco_codes_parcours
from app.scodoc import sco_core
from app.scodoc import sco_edit_ue
from app.scodoc import sco_formations
from app.scodoc import sco_formsemestre
from app.scodoc import sco_groups
from app.scodoc import sco_groups_view
from app.scodoc import sco_parcours_dut
from app.scodoc import sco_pdf
from app.scodoc import sco_preferences
from app.scodoc import sco_pvpdf
from app.scodoc import sco_etud
from app.scodoc.gen_tables import GenTable
from app.scodoc.sco_codes_parcours import NO_SEMESTRE_ID
from app.scodoc.sco_pdf import PDFLOCK
from app.scodoc.TrivialFormulator import TrivialFormulator
def _descr_decisions_ues(context, nt, etudid, decisions_ue, decision_sem):
"""Liste des UE validées dans ce semestre"""
@ -87,7 +91,6 @@ def _descr_decisions_ues(context, nt, etudid, decisions_ue, decision_sem):
uelist.append(ue)
except:
log("descr_decisions_ues: ue_id=%s decisions_ue=%s" % (ue_id, decisions_ue))
pass
# Les UE capitalisées dans d'autres semestres:
for ue in nt.ue_capitalisees[etudid]:
try:
@ -226,7 +229,7 @@ def dict_pvjury(
L = []
D = {} # même chose que L, mais { etudid : dec }
for etudid in etudids:
etud = scolars.get_etud_info(etudid=etudid, filled=True)[0]
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
Se = sco_parcours_dut.SituationEtudParcours(context, etud, formsemestre_id)
semestre_non_terminal = semestre_non_terminal or Se.semestre_non_terminal
d = {}
@ -327,7 +330,7 @@ def dict_pvjury(
max_date = date
# Code semestre precedent
if with_prev: # optionnel car un peu long...
info = scolars.get_etud_info(etudid=etudid, filled=True)
info = sco_etud.get_etud_info(etudid=etudid, filled=True)
if not info:
continue # should not occur
etud = info[0]
@ -353,9 +356,9 @@ def dict_pvjury(
"formsemestre": sem,
"has_prev": has_prev,
"semestre_non_terminal": semestre_non_terminal,
"formation": sco_formations.formation_list(context, args={"formation_id": sem["formation_id"]})[
0
],
"formation": sco_formations.formation_list(
context, args={"formation_id": sem["formation_id"]}
)[0],
"decisions": L,
"decisions_dict": D,
}
@ -427,7 +430,7 @@ def pvjury_table(
lines = []
for e in dpv["decisions"]:
scolars.format_etud_ident(e["identite"])
sco_etud.format_etud_ident(e["identite"])
l = {
"etudid": e["identite"]["etudid"],
"code_nip": e["identite"]["code_nip"],
@ -614,7 +617,7 @@ def formsemestre_pvjury_pdf(
groups_infos = None
if etudid:
# PV pour ce seul étudiant:
etud = scolars.get_etud_info(etudid=etudid, filled=1)[0]
etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0]
etuddescr = '<a class="discretelink" href="ficheEtud?etudid=%s">%s</a>' % (
etudid,
etud["nomprenom"],

View File

@ -42,16 +42,16 @@ from reportlab.lib.pagesizes import A4, landscape
from reportlab.lib import styles
from reportlab.lib.colors import Color
import sco_utils as scu
import sco_pdf
from sco_pdf import SU
import sco_formsemestre
import sco_pvjury
import sco_codes_parcours
from sco_pdf import PDFLOCK
import sco_preferences
import sco_bulletins_pdf
import VERSION
import app.scodoc.sco_utils as scu
from app.scodoc import sco_bulletins_pdf
from app.scodoc import sco_codes_parcours
from app.scodoc import sco_formsemestre
from app.scodoc import sco_pdf
from app.scodoc import sco_preferences
from app.scodoc import sco_etud
from app.scodoc import VERSION
from app.scodoc.sco_pdf import PDFLOCK
from app.scodoc.sco_pdf import SU
LOGO_FOOTER_ASPECT = scu.CONFIG.LOGO_FOOTER_ASPECT # XXX A AUTOMATISER
LOGO_FOOTER_HEIGHT = scu.CONFIG.LOGO_FOOTER_HEIGHT * mm
@ -337,6 +337,7 @@ def pdf_lettres_individuelles(
(tous ceux du semestre, ou la liste indiquée par etudids)
Renvoie pdf data ou chaine vide si aucun etudiant avec décision de jury.
"""
from app.scodoc import sco_pvjury
dpv = sco_pvjury.dict_pvjury(
context, formsemestre_id, etudids=etudids, with_prev=True
@ -345,7 +346,7 @@ def pdf_lettres_individuelles(
return ""
# Ajoute infos sur etudiants
etuds = [x["identite"] for x in dpv["decisions"]]
scolars.fillEtudsInfo(context, etuds)
sco_etud.fill_etuds_info(etuds)
#
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
prefs = sco_preferences.SemPreferences(context, formsemestre_id)
@ -357,7 +358,7 @@ def pdf_lettres_individuelles(
"htab2": "1cm",
}
# copie preferences
for name in sco_preferences.PREFS_NAMES:
for name in sco_preferences.get_base_preferences(context).prefs_name:
params[name] = sco_preferences.get_preference(
context, name, sem["formsemestre_id"]
)
@ -367,7 +368,7 @@ def pdf_lettres_individuelles(
npages = 0
for e in dpv["decisions"]:
if e["decision_sem"]: # decision prise
etud = scolars.get_etud_info(e["identite"]["etudid"], filled=True)[0]
etud = sco_etud.get_etud_info(e["identite"]["etudid"], filled=True)[0]
params["nomEtud"] = etud["nomprenom"]
bookmarks[npages + 1] = scu.suppress_accents(etud["nomprenom"])
objects += pdf_lettre_individuelle(
@ -705,6 +706,8 @@ def _pvjury_pdf_type(
"""Doc PDF récapitulant les décisions de jury pour un type de jury (passage ou delivrance)
dpv: result of dict_pvjury
"""
from app.scodoc import sco_pvjury
# Jury de diplome si sem. terminal OU que l'on demande les diplomés d'un semestre antérieur
diplome = (not dpv["semestre_non_terminal"]) or only_diplome

Some files were not shown because too many files have changed in this diff Show More