1
0
forked from ScoDoc/ScoDoc

WIP deplacé /static. Accueil fonctionnel.

This commit is contained in:
Emmanuel Viennet 2021-06-16 16:59:31 +02:00
parent f2e86622ae
commit be1d5d7a65
307 changed files with 260 additions and 196 deletions

View File

@ -30,7 +30,8 @@ moment = Moment()
def create_app(config_class=Config):
app = Flask(__name__)
app = Flask(__name__, static_url_path="/ScoDoc/static", static_folder="static")
app.logger.setLevel(logging.DEBUG)
app.config.from_object(config_class)
db.init_app(app)
migrate.init_app(app, db)

View File

@ -20,7 +20,9 @@ context = None
@bp.route("/")
@bp.route("/index")
def index():
return render_template("main/index.html", title=u"Essai Flask")
return render_template(
"main/index.html", title=u"Essai Flask", current_app=flask.current_app
)
@bp.route("/test_vue")

View File

@ -64,7 +64,7 @@ def standard_html_header():
<META name="LANG" content="fr">
<META name="DESCRIPTION" content="ScoDoc: gestion scolarite">
<link HREF="/ScoDoc/static/css/scodoc.css" rel="stylesheet" type="text/css"/>
<link href="/ScoDoc/static/css/scodoc.css" rel="stylesheet" type="text/css"/>
</head><body>%s""" % (
scu.SCO_ENCODING,

View File

@ -177,7 +177,7 @@ class NotesTable:
context, "use_ue_coefs", formsemestre_id
)
# Infos sur les etudiants
self.inscrlist = context.do_formsemestre_inscription_list(
self.inscrlist = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context,
args={"formsemestre_id": formsemestre_id}
)
# infos identite etudiant

View File

@ -376,7 +376,7 @@ def do_formsemestre_moyennes(context, nt, formsemestre_id):
liste des moduleimpls avec notes en attente.
"""
# sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
# inscr = context.do_formsemestre_inscription_list(
# inscr = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context,
# args={"formsemestre_id": formsemestre_id}
# )
# etudids = [x["etudid"] for x in inscr]

View File

@ -35,7 +35,9 @@ import sco_news
import sco_up_to_date
import sco_formsemestre
from gen_tables import GenTable
from sco_permissions import ScoEtudInscrit, ScoEditApo
from sco_permissions import Permission, ScoEtudInscrit, ScoEditApo
import html_sco_header
import sco_formsemestre_inscriptions
def index_html(context, REQUEST=None, showcodes=0, showsemtable=0):
@ -78,7 +80,9 @@ def index_html(context, REQUEST=None, showcodes=0, showsemtable=0):
sem["tmpcode"] = ""
# Nombre d'inscrits:
args = {"formsemestre_id": sem["formsemestre_id"]}
ins = context.Notes.do_formsemestre_inscription_list(args=args)
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, args=args
)
nb = len(ins) # nb etudiants
sem["nb_inscrits"] = nb
if nb > 0:

View File

@ -130,8 +130,9 @@ def formsemestre_enrich(context, sem):
# imports ici pour eviter refs circulaires
import sco_formsemestre_edit
import scolars
from app.views import notes
F = context.formation_list(args={"formation_id": sem["formation_id"]})[0]
F = notes.formation_list(context, args={"formation_id": sem["formation_id"]})[0]
parcours = sco_codes_parcours.get_parcours_from_code(F["type_parcours"])
# 'S1', 'S2', ... ou '' pour les monosemestres
if sem["semestre_id"] != NO_SEMESTRE_ID:

View File

@ -100,7 +100,7 @@ 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 = context.do_formsemestre_inscription_list(
insem = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context,
args={"etudid": etudid, "etat": "I"}
)
semlist = [

View File

@ -33,6 +33,7 @@ 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
from TrivialFormulator import TrivialFormulator, TF
@ -43,6 +44,145 @@ import sco_formsemestre
import sco_moduleimpl
import sco_groups
# --- Gestion des inscriptions aux semestres
_formsemestre_inscriptionEditor = ndb.EditableTable(
"notes_formsemestre_inscription",
"formsemestre_inscription_id",
("formsemestre_inscription_id", "etudid", "formsemestre_id", "etat", "etape"),
sortkey="formsemestre_id",
)
def do_formsemestre_inscription_list(context, *args, **kw):
"list formsemestre_inscriptions"
cnx = ndb.GetDBConnexion()
return _formsemestre_inscriptionEditor.list(cnx, *args, **kw)
def do_formsemestre_inscription_create(context, args, REQUEST, method=None):
"create a formsemestre_inscription (and sco event)"
cnx = ndb.GetDBConnexion()
log("do_formsemestre_inscription_create: args=%s" % str(args))
sems = sco_formsemestre.do_formsemestre_list(
context, {"formsemestre_id": args["formsemestre_id"]}
)
if len(sems) != 1:
raise ScoValueError("code de semestre invalide: %s" % args["formsemestre_id"])
sem = sems[0]
# check lock
if sem["etat"] != "1":
raise ScoValueError("inscription: semestre verrouille")
#
r = _formsemestre_inscriptionEditor.create(cnx, args)
# Evenement
scolars.scolar_events_create(
cnx,
args={
"etudid": args["etudid"],
"event_date": time.strftime("%d/%m/%Y"),
"formsemestre_id": args["formsemestre_id"],
"event_type": "INSCRIPTION",
},
)
# Log etudiant
logdb(
REQUEST,
cnx,
method=method,
etudid=args["etudid"],
msg="inscription en semestre %s" % args["formsemestre_id"],
commit=False,
)
#
sco_core.inval_cache(
context, formsemestre_id=args["formsemestre_id"]
) # > inscription au semestre
return r
def do_formsemestre_inscription_delete(context, oid, formsemestre_id=None):
"delete formsemestre_inscription"
cnx = ndb.GetDBConnexion()
_formsemestre_inscriptionEditor.delete(cnx, oid)
sco_core.inval_cache(
context, formsemestre_id=formsemestre_id
) # > desinscription du semestre
def do_formsemestre_inscription_edit(context, args=None, formsemestre_id=None):
"edit a formsemestre_inscription"
cnx = ndb.GetDBConnexion()
_formsemestre_inscriptionEditor.edit(cnx, args)
sco_core.inval_cache(
context, formsemestre_id=formsemestre_id
) # > modif inscription semestre (demission ?)
def do_formsemestre_desinscription(context, etudid, formsemestre_id, REQUEST=None):
"""Désinscription d'un étudiant.
Si semestre extérieur et dernier inscrit, suppression de ce semestre.
"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
# -- check lock
if sem["etat"] != "1":
raise ScoValueError("desinscription impossible: semestre verrouille")
# -- Si decisions de jury, desinscription interdite
nt = sco_core.get_notes_cache(context).get_NotesTable(context, formsemestre_id)
if nt.etud_has_decision(etudid):
raise ScoValueError(
"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}
)
if not insem:
raise ScoValueError("%s n'est pas inscrit au semestre !" % etudid)
insem = insem[0]
# -- desinscription de tous les modules
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"select moduleimpl_inscription_id from notes_moduleimpl_inscription Im, notes_moduleimpl M where Im.etudid=%(etudid)s and Im.moduleimpl_id = M.moduleimpl_id and M.formsemestre_id = %(formsemestre_id)s",
{"etudid": etudid, "formsemestre_id": formsemestre_id},
)
res = cursor.fetchall()
moduleimpl_inscription_ids = [x[0] for x in res]
for moduleimpl_inscription_id in moduleimpl_inscription_ids:
sco_moduleimpl.do_moduleimpl_inscription_delete(
context, moduleimpl_inscription_id, formsemestre_id=formsemestre_id
)
# -- desincription du semestre
do_formsemestre_inscription_delete(
context, insem["formsemestre_inscription_id"], formsemestre_id=formsemestre_id
)
# --- Semestre extérieur
if sem["modalite"] == "EXT":
inscrits = do_formsemestre_inscription_list(context,
args={"formsemestre_id": formsemestre_id}
)
nbinscrits = len(inscrits)
if nbinscrits == 0:
log(
"do_formsemestre_desinscription: suppression du semestre extérieur %s"
% formsemestre_id
)
sco_formsemestre_edit.do_formsemestre_delete(
context, formsemestre_id, REQUEST=REQUEST
)
if REQUEST:
logdb(
REQUEST,
cnx,
method="formsemestre_desinscription",
etudid=etudid,
msg="desinscription semestre %s" % formsemestre_id,
commit=False,
)
def do_formsemestre_inscription_with_modules(
context,
@ -61,7 +201,7 @@ def do_formsemestre_inscription_with_modules(
args = {"formsemestre_id": formsemestre_id, "etudid": etudid}
if etat is not None:
args["etat"] = etat
context.do_formsemestre_inscription_create(args, REQUEST, method=method)
do_formsemestre_inscription_create(context, args, REQUEST, method=method)
log(
"do_formsemestre_inscription_with_modules: etudid=%s formsemestre_id=%s"
% (etudid, formsemestre_id)
@ -135,7 +275,7 @@ 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 = context.do_formsemestre_inscription_list(
insem = do_formsemestre_inscription_list(context,
args={"etudid": etudid, "etat": "I"}
)
if sems:

View File

@ -579,7 +579,7 @@ def fill_formsemestre(context, sem, REQUEST=None):
sco_formsemestre.formsemestre_etape_apo_str(sem) or "Pas de code étape"
)
inscrits = context.Notes.do_formsemestre_inscription_list(
inscrits = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context,
args={"formsemestre_id": formsemestre_id}
)
sem["nbinscrits"] = len(inscrits)
@ -977,7 +977,7 @@ def formsemestre_status(context, formsemestre_id=None, REQUEST=None):
Mlist = sco_moduleimpl.do_moduleimpl_withmodule_list(
context, formsemestre_id=formsemestre_id
)
# inscrits = context.do_formsemestre_inscription_list(
# inscrits = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context,
# args={"formsemestre_id": formsemestre_id}
# )
prev_ue_id = None

View File

@ -864,7 +864,7 @@ def do_formsemestre_validation_auto(context, formsemestre_id, REQUEST):
for etudid in etudids:
etud = scolars.get_etud_info(etudid=etudid, filled=True)[0]
Se = sco_parcours_dut.SituationEtudParcours(context, etud, formsemestre_id)
ins = context.do_formsemestre_inscription_list(
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context,
{"etudid": etudid, "formsemestre_id": formsemestre_id}
)[0]
@ -966,7 +966,7 @@ def formsemestre_fix_validation_ues(context, formsemestre_id, REQUEST=None):
for etudid in etudids:
etud = scolars.get_etud_info(etudid=etudid, filled=True)[0]
Se = sco_parcours_dut.SituationEtudParcours(context, etud, formsemestre_id)
ins = context.do_formsemestre_inscription_list(
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context,
{"etudid": etudid, "formsemestre_id": formsemestre_id}
)[0]
decision_sem = nt.get_etud_decision_sem(etudid)

View File

@ -1321,7 +1321,7 @@ def create_etapes_partition(context, formsemestre_id, partition_name="apo_etapes
vides ne sont pas supprimés).
"""
log("create_etapes_partition(%s)" % formsemestre_id)
ins = context.do_formsemestre_inscription_list(
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context,
args={"formsemestre_id": formsemestre_id}
)
etapes = {i["etape"] for i in ins if i["etape"]}

View File

@ -110,7 +110,7 @@ def list_inscrits(context, formsemestre_id, with_dems=False):
) # optimized
else:
args = {"formsemestre_id": formsemestre_id}
ins = context.Notes.do_formsemestre_inscription_list(args=args)
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context, args=args)
inscr = {}
for i in ins:
etudid = i["etudid"]

View File

@ -286,7 +286,7 @@ def _make_table_notes(
# infos identite etudiant
etud = scolars.get_etud_info(etudid=etudid, filled=1)[0]
# infos inscription
inscr = context.do_formsemestre_inscription_list(
inscr = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context,
{"etudid": etudid, "formsemestre_id": M["formsemestre_id"]}
)[0]

View File

@ -232,7 +232,7 @@ def do_moduleimpl_inscrit_etuds(
"""
# Verifie qu'ils sont tous bien inscrits au semestre
for etudid in etudids:
insem = context.do_formsemestre_inscription_list(
insem = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context,
args={"formsemestre_id": formsemestre_id, "etudid": etudid}
)
if not insem:

View File

@ -238,7 +238,7 @@ def moduleimpl_inscriptions_stats(context, formsemestre_id, REQUEST=None):
authuser = REQUEST.AUTHENTICATED_USER
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
inscrits = context.do_formsemestre_inscription_list(
inscrits = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context,
args={"formsemestre_id": formsemestre_id}
)
set_all = set([x["etudid"] for x in inscrits])
@ -465,7 +465,7 @@ 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 = context.do_formsemestre_inscription_list(
inscrits = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context,
args={"formsemestre_id": formsemestre_id}
)
ues = nt.get_ues()
@ -544,7 +544,7 @@ 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 = context.do_formsemestre_inscription_list(
insem = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context,
args={"formsemestre_id": formsemestre_id, "etudid": etudid}
)
if not insem:

View File

@ -64,7 +64,7 @@ from scolog import logdb
# 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, "static", "icons")
ICONS_DIR = os.path.join(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"

View File

@ -298,7 +298,7 @@ def do_placement(context, REQUEST):
0
] # XXX utiliser ZScolar (parent)
# infos inscription
inscr = context.do_formsemestre_inscription_list(
inscr = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context,
{"etudid": etudid, "formsemestre_id": M["formsemestre_id"]}
)[0]
if inscr["etat"] != "D":

View File

@ -451,7 +451,7 @@ def table_suivi_cohorte(
logt("B: etuds sets")
sem["members"] = orig_set
for s in sems:
ins = context.do_formsemestre_inscription_list(
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context,
args={"formsemestre_id": s["formsemestre_id"]}
) # sans dems
inset = set([i["etudid"] for i in ins])

View File

@ -1006,7 +1006,7 @@ def _get_sorted_etuds(context, E, etudids, formsemestre_id):
scolars.format_etud_ident(e)
etuds.append(e)
# infos inscription dans ce semestre
e["inscr"] = context.do_formsemestre_inscription_list(
e["inscr"] = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context,
{"etudid": etudid, "formsemestre_id": formsemestre_id}
)[0]
# Groupes auxquels appartient cet étudiant:

View File

@ -770,7 +770,7 @@ def update_etape_formsemestre_inscription(context, ins, etud):
"""
if etud["etape"] != ins["etape"]:
ins["etape"] = etud["etape"]
context.do_formsemestre_inscription_edit(args=ins)
sco_formsemestre_inscriptions.do_formsemestre_inscription_edit(context, args=ins)
def formsemestre_import_etud_admission(
@ -783,7 +783,7 @@ def formsemestre_import_etud_admission(
N'affecte pas les etudiants inconnus sur le portail.
"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
ins = context.do_formsemestre_inscription_list({"formsemestre_id": formsemestre_id})
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context, {"formsemestre_id": formsemestre_id})
log(
"formsemestre_import_etud_admission: %s (%d etuds)"
% (formsemestre_id, len(ins))

View File

@ -234,7 +234,7 @@ if not os.path.exists(SCO_TMP_DIR):
# ----- Les logos: /opt/scodoc/var/scodoc/config/logos
SCODOC_LOGOS_DIR = os.path.join(SCODOC_CFG_DIR, "logos")
# Dans les sources:
# Racine projet: /.../ScoDoc/
SCO_SRC_DIR = os.path.join(Config.INSTANCE_HOME, "Products", "ScoDoc")
# - Les outils distribués
SCO_TOOLS_DIR = os.path.join(SCO_SRC_DIR, "config")
@ -820,7 +820,7 @@ def icontag(name, file_format="png", **attrs):
"""
if ("width" not in attrs) or ("height" not in attrs):
if name not in ICONSIZES:
img_file = SCO_SRC_DIR + "/static/icons/%s.%s" % (name, file_format)
img_file = SCO_SRC_DIR + "/app/static/icons/%s.%s" % (name, file_format)
im = PILImage.open(img_file)
width, height = im.size[0], im.size[1]
ICONSIZES[name] = (width, height) # cache

View File

@ -926,7 +926,7 @@ def fillEtudsInfo(context, etuds):
format_etud_ident(etud)
# Semestres dans lesquel il est inscrit
ins = context.Notes.do_formsemestre_inscription_list({"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

View File

Before

Width:  |  Height:  |  Size: 160 B

After

Width:  |  Height:  |  Size: 160 B

View File

Before

Width:  |  Height:  |  Size: 148 B

After

Width:  |  Height:  |  Size: 148 B

View File

Before

Width:  |  Height:  |  Size: 201 B

After

Width:  |  Height:  |  Size: 201 B

View File

Before

Width:  |  Height:  |  Size: 158 B

After

Width:  |  Height:  |  Size: 158 B

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