forked from ScoDoc/DocScoDoc
Fix SVG/pydot for numeric ids
This commit is contained in:
parent
a74986323f
commit
abb89640a7
@ -41,6 +41,7 @@ from flask import url_for, g
|
||||
import pydot
|
||||
|
||||
import app.scodoc.sco_utils as scu
|
||||
from app.models import NotesFormModalite
|
||||
from app.scodoc import notesdb as ndb
|
||||
from app.scodoc import html_sco_header
|
||||
from app.scodoc import sco_codes_parcours
|
||||
@ -1269,14 +1270,19 @@ def graph_parcours(
|
||||
return "", etuds, bacs, bacspecialites, annee_bacs, civilites, statuts
|
||||
edges = scu.DictDefault(
|
||||
defaultvalue=set()
|
||||
) # {(formsemestre_id_origin, formsemestre_id_dest) : etud_set}
|
||||
) # {("SEM"formsemestre_id_origin, "SEM"formsemestre_id_dest) : etud_set}
|
||||
|
||||
def sem_node_name(sem, prefix="SEM"):
|
||||
"pydot node name for this integer id"
|
||||
return prefix + str(sem["formsemestre_id"])
|
||||
|
||||
sems = {}
|
||||
effectifs = scu.DictDefault(defaultvalue=set()) # formsemestre_id : etud_set
|
||||
decisions = scu.DictDefault(defaultvalue={}) # formsemestre_id : { code : nb_etud }
|
||||
isolated_nodes = []
|
||||
connected_nodes = set()
|
||||
isolated_nodes = [] # [ node_name_de_formsemestre_id, ... ]
|
||||
connected_nodes = set() # { node_name_de_formsemestre_id }
|
||||
diploma_nodes = []
|
||||
dem_nodes = {} # formsemestre_id : noeud pour demissionnaires
|
||||
dem_nodes = {} # formsemestre_id : noeud (node name) pour demissionnaires
|
||||
nar_nodes = {} # formsemestre_id : noeud pour NAR
|
||||
for etud in etuds:
|
||||
nxt = {}
|
||||
@ -1295,14 +1301,17 @@ def graph_parcours(
|
||||
):
|
||||
# cas particulier du diplome puis poursuite etude
|
||||
edges[
|
||||
("_dipl_" + s["formsemestre_id"], nxt["formsemestre_id"])
|
||||
(
|
||||
sem_node_name(s, "_dipl_"),
|
||||
sem_node_name(nxt), # = "SEM{formsemestre_id}"
|
||||
)
|
||||
].add(etudid)
|
||||
else:
|
||||
edges[(s["formsemestre_id"], nxt["formsemestre_id"])].add(etudid)
|
||||
connected_nodes.add(s["formsemestre_id"])
|
||||
connected_nodes.add(nxt["formsemestre_id"])
|
||||
edges[(sem_node_name(s), sem_node_name(nxt))].add(etudid)
|
||||
connected_nodes.add(sem_node_name(s))
|
||||
connected_nodes.add(sem_node_name(nxt))
|
||||
else:
|
||||
isolated_nodes.append(s["formsemestre_id"])
|
||||
isolated_nodes.append(sem_node_name(s))
|
||||
sems[s["formsemestre_id"]] = s
|
||||
effectifs[s["formsemestre_id"]].add(etudid)
|
||||
nxt = s
|
||||
@ -1315,18 +1324,18 @@ def graph_parcours(
|
||||
dc[dec["code"]] = 1
|
||||
# ajout noeud pour demissionnaires
|
||||
if nt.get_etud_etat(etudid) == "D":
|
||||
nid = "_dem_" + s["formsemestre_id"]
|
||||
nid = sem_node_name(s, "_dem_")
|
||||
dem_nodes[s["formsemestre_id"]] = nid
|
||||
edges[(s["formsemestre_id"], nid)].add(etudid)
|
||||
edges[(sem_node_name(s), nid)].add(etudid)
|
||||
# ajout noeud pour NAR (seulement pour noeud de depart)
|
||||
if (
|
||||
s["formsemestre_id"] == formsemestre_id
|
||||
and dec
|
||||
and dec["code"] == sco_codes_parcours.NAR
|
||||
):
|
||||
nid = "_nar_" + s["formsemestre_id"]
|
||||
nid = sem_node_name(s, "_nar_")
|
||||
nar_nodes[s["formsemestre_id"]] = nid
|
||||
edges[(s["formsemestre_id"], nid)].add(etudid)
|
||||
edges[(sem_node_name(s), nid)].add(etudid)
|
||||
|
||||
# si "terminal", ajoute noeud pour diplomes
|
||||
if s["semestre_id"] == nt.parcours.NB_SEM:
|
||||
@ -1335,8 +1344,8 @@ def graph_parcours(
|
||||
and code_semestre_validant(dec["code"])
|
||||
and nt.get_etud_etat(etudid) == "I"
|
||||
):
|
||||
nid = "_dipl_" + s["formsemestre_id"]
|
||||
edges[(s["formsemestre_id"], nid)].add(etudid)
|
||||
nid = sem_node_name(s, "_dipl_")
|
||||
edges[(sem_node_name(s), nid)].add(etudid)
|
||||
diploma_nodes.append(nid)
|
||||
#
|
||||
g = scu.graph_from_edges(list(edges.keys()))
|
||||
@ -1350,12 +1359,12 @@ def graph_parcours(
|
||||
g.set_bgcolor("#fffff0") # ou 'transparent'
|
||||
# titres des semestres:
|
||||
for s in sems.values():
|
||||
n = g.get_node(s["formsemestre_id"])[0]
|
||||
n = g.get_node(sem_node_name(s))[0]
|
||||
log("s['formsemestre_id'] = %s" % s["formsemestre_id"])
|
||||
log("n=%s" % n)
|
||||
log("get=%s" % g.get_node(s["formsemestre_id"]))
|
||||
log("get=%s" % g.get_node(sem_node_name(s)))
|
||||
log("nodes names = %s" % [x.get_name() for x in g.get_node_list()])
|
||||
if s["modalite"] and s["modalite"] != "FI":
|
||||
if s["modalite"] and s["modalite"] != NotesFormModalite.DEFAULT_MODALITE:
|
||||
modalite = " " + s["modalite"]
|
||||
else:
|
||||
modalite = ""
|
||||
@ -1373,9 +1382,9 @@ def graph_parcours(
|
||||
n.set_fontsize(8.0)
|
||||
n.set_width(1.2)
|
||||
n.set_shape("box")
|
||||
n.set_URL("formsemestre_status?formsemestre_id=" + s["formsemestre_id"])
|
||||
n.set_URL(f"formsemestre_status?formsemestre_id={s['formsemestre_id']}")
|
||||
# semestre de depart en vert
|
||||
n = g.get_node(formsemestre_id)[0]
|
||||
n = g.get_node("SEM" + str(formsemestre_id))[0]
|
||||
n.set_color("green")
|
||||
# demissions en rouge, octagonal
|
||||
for nid in dem_nodes.values():
|
||||
@ -1440,7 +1449,7 @@ def graph_parcours(
|
||||
)
|
||||
|
||||
def repl_title(m):
|
||||
fid = m.group("fid")
|
||||
fid = int(m.group("fid"))
|
||||
title = sems[fid]["titreannee"]
|
||||
if decisions[fid]:
|
||||
title += (
|
||||
|
Loading…
Reference in New Issue
Block a user