forked from ScoDoc/ScoDoc
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 pydot
|
||||||
|
|
||||||
import app.scodoc.sco_utils as scu
|
import app.scodoc.sco_utils as scu
|
||||||
|
from app.models import NotesFormModalite
|
||||||
from app.scodoc import notesdb as ndb
|
from app.scodoc import notesdb as ndb
|
||||||
from app.scodoc import html_sco_header
|
from app.scodoc import html_sco_header
|
||||||
from app.scodoc import sco_codes_parcours
|
from app.scodoc import sco_codes_parcours
|
||||||
@ -1269,14 +1270,19 @@ def graph_parcours(
|
|||||||
return "", etuds, bacs, bacspecialites, annee_bacs, civilites, statuts
|
return "", etuds, bacs, bacspecialites, annee_bacs, civilites, statuts
|
||||||
edges = scu.DictDefault(
|
edges = scu.DictDefault(
|
||||||
defaultvalue=set()
|
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 = {}
|
sems = {}
|
||||||
effectifs = scu.DictDefault(defaultvalue=set()) # formsemestre_id : etud_set
|
effectifs = scu.DictDefault(defaultvalue=set()) # formsemestre_id : etud_set
|
||||||
decisions = scu.DictDefault(defaultvalue={}) # formsemestre_id : { code : nb_etud }
|
decisions = scu.DictDefault(defaultvalue={}) # formsemestre_id : { code : nb_etud }
|
||||||
isolated_nodes = []
|
isolated_nodes = [] # [ node_name_de_formsemestre_id, ... ]
|
||||||
connected_nodes = set()
|
connected_nodes = set() # { node_name_de_formsemestre_id }
|
||||||
diploma_nodes = []
|
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
|
nar_nodes = {} # formsemestre_id : noeud pour NAR
|
||||||
for etud in etuds:
|
for etud in etuds:
|
||||||
nxt = {}
|
nxt = {}
|
||||||
@ -1295,14 +1301,17 @@ def graph_parcours(
|
|||||||
):
|
):
|
||||||
# cas particulier du diplome puis poursuite etude
|
# cas particulier du diplome puis poursuite etude
|
||||||
edges[
|
edges[
|
||||||
("_dipl_" + s["formsemestre_id"], nxt["formsemestre_id"])
|
(
|
||||||
|
sem_node_name(s, "_dipl_"),
|
||||||
|
sem_node_name(nxt), # = "SEM{formsemestre_id}"
|
||||||
|
)
|
||||||
].add(etudid)
|
].add(etudid)
|
||||||
else:
|
else:
|
||||||
edges[(s["formsemestre_id"], nxt["formsemestre_id"])].add(etudid)
|
edges[(sem_node_name(s), sem_node_name(nxt))].add(etudid)
|
||||||
connected_nodes.add(s["formsemestre_id"])
|
connected_nodes.add(sem_node_name(s))
|
||||||
connected_nodes.add(nxt["formsemestre_id"])
|
connected_nodes.add(sem_node_name(nxt))
|
||||||
else:
|
else:
|
||||||
isolated_nodes.append(s["formsemestre_id"])
|
isolated_nodes.append(sem_node_name(s))
|
||||||
sems[s["formsemestre_id"]] = s
|
sems[s["formsemestre_id"]] = s
|
||||||
effectifs[s["formsemestre_id"]].add(etudid)
|
effectifs[s["formsemestre_id"]].add(etudid)
|
||||||
nxt = s
|
nxt = s
|
||||||
@ -1315,18 +1324,18 @@ def graph_parcours(
|
|||||||
dc[dec["code"]] = 1
|
dc[dec["code"]] = 1
|
||||||
# ajout noeud pour demissionnaires
|
# ajout noeud pour demissionnaires
|
||||||
if nt.get_etud_etat(etudid) == "D":
|
if nt.get_etud_etat(etudid) == "D":
|
||||||
nid = "_dem_" + s["formsemestre_id"]
|
nid = sem_node_name(s, "_dem_")
|
||||||
dem_nodes[s["formsemestre_id"]] = nid
|
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)
|
# ajout noeud pour NAR (seulement pour noeud de depart)
|
||||||
if (
|
if (
|
||||||
s["formsemestre_id"] == formsemestre_id
|
s["formsemestre_id"] == formsemestre_id
|
||||||
and dec
|
and dec
|
||||||
and dec["code"] == sco_codes_parcours.NAR
|
and dec["code"] == sco_codes_parcours.NAR
|
||||||
):
|
):
|
||||||
nid = "_nar_" + s["formsemestre_id"]
|
nid = sem_node_name(s, "_nar_")
|
||||||
nar_nodes[s["formsemestre_id"]] = nid
|
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
|
# si "terminal", ajoute noeud pour diplomes
|
||||||
if s["semestre_id"] == nt.parcours.NB_SEM:
|
if s["semestre_id"] == nt.parcours.NB_SEM:
|
||||||
@ -1335,8 +1344,8 @@ def graph_parcours(
|
|||||||
and code_semestre_validant(dec["code"])
|
and code_semestre_validant(dec["code"])
|
||||||
and nt.get_etud_etat(etudid) == "I"
|
and nt.get_etud_etat(etudid) == "I"
|
||||||
):
|
):
|
||||||
nid = "_dipl_" + s["formsemestre_id"]
|
nid = sem_node_name(s, "_dipl_")
|
||||||
edges[(s["formsemestre_id"], nid)].add(etudid)
|
edges[(sem_node_name(s), nid)].add(etudid)
|
||||||
diploma_nodes.append(nid)
|
diploma_nodes.append(nid)
|
||||||
#
|
#
|
||||||
g = scu.graph_from_edges(list(edges.keys()))
|
g = scu.graph_from_edges(list(edges.keys()))
|
||||||
@ -1350,12 +1359,12 @@ def graph_parcours(
|
|||||||
g.set_bgcolor("#fffff0") # ou 'transparent'
|
g.set_bgcolor("#fffff0") # ou 'transparent'
|
||||||
# titres des semestres:
|
# titres des semestres:
|
||||||
for s in sems.values():
|
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("s['formsemestre_id'] = %s" % s["formsemestre_id"])
|
||||||
log("n=%s" % n)
|
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()])
|
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"]
|
modalite = " " + s["modalite"]
|
||||||
else:
|
else:
|
||||||
modalite = ""
|
modalite = ""
|
||||||
@ -1373,9 +1382,9 @@ def graph_parcours(
|
|||||||
n.set_fontsize(8.0)
|
n.set_fontsize(8.0)
|
||||||
n.set_width(1.2)
|
n.set_width(1.2)
|
||||||
n.set_shape("box")
|
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
|
# 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")
|
n.set_color("green")
|
||||||
# demissions en rouge, octagonal
|
# demissions en rouge, octagonal
|
||||||
for nid in dem_nodes.values():
|
for nid in dem_nodes.values():
|
||||||
@ -1440,7 +1449,7 @@ def graph_parcours(
|
|||||||
)
|
)
|
||||||
|
|
||||||
def repl_title(m):
|
def repl_title(m):
|
||||||
fid = m.group("fid")
|
fid = int(m.group("fid"))
|
||||||
title = sems[fid]["titreannee"]
|
title = sems[fid]["titreannee"]
|
||||||
if decisions[fid]:
|
if decisions[fid]:
|
||||||
title += (
|
title += (
|
||||||
|
Loading…
Reference in New Issue
Block a user