forked from ScoDoc/ScoDoc
Fix: modif groupes parcours + some code cosmetic
This commit is contained in:
parent
42f0cb8e76
commit
28b29b9654
@ -580,7 +580,7 @@ class FormSemestre(db.Model):
|
||||
)
|
||||
db.session.add(partition)
|
||||
db.session.flush() # pour avoir un id
|
||||
flash(f"Partition Parcours créée.")
|
||||
flash("Partition Parcours créée.")
|
||||
|
||||
for parcour in self.parcours:
|
||||
if parcour.code:
|
||||
|
@ -128,17 +128,26 @@ def _build_menu_stats(formsemestre_id):
|
||||
]
|
||||
|
||||
|
||||
def formsemestre_status_menubar(sem):
|
||||
def formsemestre_status_menubar(formsemestre: FormSemestre) -> str:
|
||||
"""HTML to render menubar"""
|
||||
formsemestre_id = sem["formsemestre_id"]
|
||||
if int(sem["etat"]):
|
||||
formsemestre_id = formsemestre.id
|
||||
if formsemestre.etat:
|
||||
change_lock_msg = "Verrouiller"
|
||||
else:
|
||||
change_lock_msg = "Déverrouiller"
|
||||
|
||||
F = sco_formations.formation_list(args={"formation_id": sem["formation_id"]})[0]
|
||||
formation = formsemestre.formation
|
||||
|
||||
menuSemestre = [
|
||||
# L'utilisateur est-il resp. du semestre ?
|
||||
is_responsable = current_user.id in (u.id for u in formsemestre.responsables)
|
||||
# A le droit de changer le semestre (déverrouiller, préférences bul., ...):
|
||||
has_perm_change_sem = current_user.has_permission(Permission.ScoImplement) or (
|
||||
formsemestre.resp_can_edit and is_responsable
|
||||
)
|
||||
# Peut modifier le semestre (si n'est pas verrouillé):
|
||||
can_modify_sem = has_perm_change_sem and formsemestre.etat
|
||||
|
||||
menu_semestre = [
|
||||
{
|
||||
"title": "Tableau de bord",
|
||||
"endpoint": "notes.formsemestre_status",
|
||||
@ -147,11 +156,11 @@ def formsemestre_status_menubar(sem):
|
||||
"helpmsg": "Tableau de bord du semestre",
|
||||
},
|
||||
{
|
||||
"title": "Voir la formation %(acronyme)s (v%(version)s)" % F,
|
||||
"title": f"Voir la formation {formation.acronyme} (v{formation.version})",
|
||||
"endpoint": "notes.ue_table",
|
||||
"args": {
|
||||
"formation_id": sem["formation_id"],
|
||||
"semestre_idx": sem["semestre_id"],
|
||||
"formation_id": formation.id,
|
||||
"semestre_idx": formsemestre.semestre_id,
|
||||
},
|
||||
"enabled": True,
|
||||
"helpmsg": "Tableau de bord du semestre",
|
||||
@ -160,41 +169,31 @@ def formsemestre_status_menubar(sem):
|
||||
"title": "Modifier le semestre",
|
||||
"endpoint": "notes.formsemestre_editwithmodules",
|
||||
"args": {
|
||||
"formation_id": sem["formation_id"],
|
||||
"formation_id": formation.id,
|
||||
"formsemestre_id": formsemestre_id,
|
||||
},
|
||||
"enabled": (
|
||||
current_user.has_permission(Permission.ScoImplement)
|
||||
or (current_user.id in sem["responsables"] and sem["resp_can_edit"])
|
||||
)
|
||||
and (sem["etat"]),
|
||||
"enabled": can_modify_sem,
|
||||
"helpmsg": "Modifie le contenu du semestre (modules)",
|
||||
},
|
||||
{
|
||||
"title": "Préférences du semestre",
|
||||
"endpoint": "scolar.formsemestre_edit_preferences",
|
||||
"args": {"formsemestre_id": formsemestre_id},
|
||||
"enabled": (
|
||||
current_user.has_permission(Permission.ScoImplement)
|
||||
or (current_user.id in sem["responsables"] and sem["resp_can_edit"])
|
||||
)
|
||||
and (sem["etat"]),
|
||||
"enabled": can_modify_sem,
|
||||
"helpmsg": "Préférences du semestre",
|
||||
},
|
||||
{
|
||||
"title": "Réglages bulletins",
|
||||
"endpoint": "notes.formsemestre_edit_options",
|
||||
"args": {"formsemestre_id": formsemestre_id},
|
||||
"enabled": (current_user.id in sem["responsables"])
|
||||
or current_user.has_permission(Permission.ScoImplement),
|
||||
"enabled": has_perm_change_sem,
|
||||
"helpmsg": "Change les options",
|
||||
},
|
||||
{
|
||||
"title": change_lock_msg,
|
||||
"endpoint": "notes.formsemestre_change_lock",
|
||||
"args": {"formsemestre_id": formsemestre_id},
|
||||
"enabled": (current_user.id in sem["responsables"])
|
||||
or current_user.has_permission(Permission.ScoImplement),
|
||||
"enabled": has_perm_change_sem,
|
||||
"helpmsg": "",
|
||||
},
|
||||
{
|
||||
@ -230,7 +229,7 @@ def formsemestre_status_menubar(sem):
|
||||
"endpoint": "notes.formsemestre_associate_new_version",
|
||||
"args": {"formsemestre_id": formsemestre_id},
|
||||
"enabled": current_user.has_permission(Permission.ScoChangeFormation)
|
||||
and (sem["etat"]),
|
||||
and formsemestre.etat,
|
||||
"helpmsg": "",
|
||||
},
|
||||
{
|
||||
@ -243,7 +242,7 @@ def formsemestre_status_menubar(sem):
|
||||
]
|
||||
# debug :
|
||||
if current_app.config["ENV"] == "development":
|
||||
menuSemestre.append(
|
||||
menu_semestre.append(
|
||||
{
|
||||
"title": "Vérifier l'intégrité",
|
||||
"endpoint": "notes.check_sem_integrity",
|
||||
@ -252,20 +251,20 @@ def formsemestre_status_menubar(sem):
|
||||
}
|
||||
)
|
||||
|
||||
menuInscriptions = [
|
||||
menu_inscriptions = [
|
||||
{
|
||||
"title": "Voir les inscriptions aux modules",
|
||||
"endpoint": "notes.moduleimpl_inscriptions_stats",
|
||||
"args": {"formsemestre_id": formsemestre_id},
|
||||
}
|
||||
]
|
||||
menuInscriptions += [
|
||||
menu_inscriptions += [
|
||||
{
|
||||
"title": "Passage des étudiants depuis d'autres semestres",
|
||||
"endpoint": "notes.formsemestre_inscr_passage",
|
||||
"args": {"formsemestre_id": formsemestre_id},
|
||||
"enabled": current_user.has_permission(Permission.ScoEtudInscrit)
|
||||
and (sem["etat"]),
|
||||
and formsemestre.etat,
|
||||
},
|
||||
{
|
||||
"title": "Synchroniser avec étape Apogée",
|
||||
@ -273,21 +272,21 @@ def formsemestre_status_menubar(sem):
|
||||
"args": {"formsemestre_id": formsemestre_id},
|
||||
"enabled": current_user.has_permission(Permission.ScoView)
|
||||
and sco_preferences.get_preference("portal_url")
|
||||
and (sem["etat"]),
|
||||
and formsemestre.etat,
|
||||
},
|
||||
{
|
||||
"title": "Inscrire un étudiant",
|
||||
"endpoint": "notes.formsemestre_inscription_with_modules_etud",
|
||||
"args": {"formsemestre_id": formsemestre_id},
|
||||
"enabled": current_user.has_permission(Permission.ScoEtudInscrit)
|
||||
and (sem["etat"]),
|
||||
and formsemestre.etat,
|
||||
},
|
||||
{
|
||||
"title": "Importer des étudiants dans ce semestre (table Excel)",
|
||||
"endpoint": "scolar.form_students_import_excel",
|
||||
"args": {"formsemestre_id": formsemestre_id},
|
||||
"enabled": current_user.has_permission(Permission.ScoEtudInscrit)
|
||||
and (sem["etat"]),
|
||||
and formsemestre.etat,
|
||||
},
|
||||
{
|
||||
"title": "Import/export des données admission",
|
||||
@ -319,7 +318,7 @@ def formsemestre_status_menubar(sem):
|
||||
},
|
||||
]
|
||||
|
||||
menuGroupes = [
|
||||
menu_groupes = [
|
||||
{
|
||||
"title": "Listes, photos, feuilles...",
|
||||
"endpoint": "scolar.groups_view",
|
||||
@ -346,16 +345,16 @@ def formsemestre_status_menubar(sem):
|
||||
for partition in partitions:
|
||||
submenu.append(
|
||||
{
|
||||
"title": "%s" % partition["partition_name"],
|
||||
"title": str(partition["partition_name"]),
|
||||
"endpoint": "scolar.affect_groups",
|
||||
"args": {"partition_id": partition["partition_id"]},
|
||||
"enabled": enabled and partition["groups_editable"],
|
||||
"enabled": enabled,
|
||||
}
|
||||
)
|
||||
menuGroupes.append(
|
||||
menu_groupes.append(
|
||||
{"title": "Modifier les groupes", "submenu": submenu, "enabled": enabled}
|
||||
)
|
||||
menuGroupes.append(
|
||||
menu_groupes.append(
|
||||
{
|
||||
"title": "Expérimental: éditeur de partitions",
|
||||
"endpoint": "scolar.partition_editor",
|
||||
@ -367,7 +366,7 @@ def formsemestre_status_menubar(sem):
|
||||
},
|
||||
)
|
||||
|
||||
menuNotes = [
|
||||
menu_notes = [
|
||||
{
|
||||
"title": "Tableau des moyennes (et liens bulletins)",
|
||||
"endpoint": "notes.formsemestre_recapcomplet",
|
||||
@ -408,7 +407,7 @@ def formsemestre_status_menubar(sem):
|
||||
"args": {"formsemestre_id": formsemestre_id},
|
||||
},
|
||||
]
|
||||
menuJury = [
|
||||
menu_jury = [
|
||||
{
|
||||
"title": "Voir les décisions du jury",
|
||||
"endpoint": "notes.formsemestre_pvjury",
|
||||
@ -441,19 +440,17 @@ def formsemestre_status_menubar(sem):
|
||||
},
|
||||
]
|
||||
|
||||
menuStats = _build_menu_stats(formsemestre_id)
|
||||
menu_stats = _build_menu_stats(formsemestre_id)
|
||||
H = [
|
||||
# <table><tr><td>',
|
||||
'<ul id="sco_menu">',
|
||||
htmlutils.make_menu("Semestre", menuSemestre),
|
||||
htmlutils.make_menu("Inscriptions", menuInscriptions),
|
||||
htmlutils.make_menu("Groupes", menuGroupes),
|
||||
htmlutils.make_menu("Notes", menuNotes),
|
||||
htmlutils.make_menu("Jury", menuJury),
|
||||
htmlutils.make_menu("Statistiques", menuStats),
|
||||
htmlutils.make_menu("Semestre", menu_semestre),
|
||||
htmlutils.make_menu("Inscriptions", menu_inscriptions),
|
||||
htmlutils.make_menu("Groupes", menu_groupes),
|
||||
htmlutils.make_menu("Notes", menu_notes),
|
||||
htmlutils.make_menu("Jury", menu_jury),
|
||||
htmlutils.make_menu("Statistiques", menu_stats),
|
||||
formsemestre_custommenu_html(formsemestre_id),
|
||||
"</ul>",
|
||||
#'</td></tr></table>'
|
||||
]
|
||||
return "\n".join(H)
|
||||
|
||||
@ -536,7 +533,7 @@ def formsemestre_page_title(formsemestre_id=None):
|
||||
"formsemestre_page_title.html",
|
||||
formsemestre=formsemestre,
|
||||
scu=scu,
|
||||
sem_menu_bar=formsemestre_status_menubar(formsemestre.to_dict()),
|
||||
sem_menu_bar=formsemestre_status_menubar(formsemestre),
|
||||
)
|
||||
|
||||
return h
|
||||
@ -544,17 +541,14 @@ def formsemestre_page_title(formsemestre_id=None):
|
||||
|
||||
def fill_formsemestre(sem):
|
||||
"""Add some useful fields to help display formsemestres"""
|
||||
notes_url = scu.NotesURL()
|
||||
sem["notes_url"] = notes_url
|
||||
sem["notes_url"] = scu.NotesURL()
|
||||
formsemestre_id = sem["formsemestre_id"]
|
||||
if not sem["etat"]:
|
||||
sem[
|
||||
"locklink"
|
||||
] = """<a href="%s/formsemestre_change_lock?formsemestre_id=%s">%s</a>""" % (
|
||||
notes_url,
|
||||
sem["formsemestre_id"],
|
||||
scu.icontag("lock_img", border="0", title="Semestre verrouillé"),
|
||||
)
|
||||
] = f"""<a href="{url_for('notes.formsemestre_change_lock',
|
||||
scodoc_dept=g.scodoc_dept,formsemestre_id=formsemestre_id )
|
||||
}">{scu.icontag("lock_img", border="0", title="Semestre verrouillé")}</a>"""
|
||||
else:
|
||||
sem["locklink"] = ""
|
||||
if sco_preferences.get_preference("bul_display_publication", formsemestre_id):
|
||||
@ -562,21 +556,23 @@ def fill_formsemestre(sem):
|
||||
eyeicon = scu.icontag("hide_img", border="0", title="Bulletins NON publiés")
|
||||
else:
|
||||
eyeicon = scu.icontag("eye_img", border="0", title="Bulletins publiés")
|
||||
sem["eyelink"] = (
|
||||
"""<a href="%s/formsemestre_change_publication_bul?formsemestre_id=%s">%s</a>"""
|
||||
% (notes_url, sem["formsemestre_id"], eyeicon)
|
||||
)
|
||||
sem[
|
||||
"eyelink"
|
||||
] = f"""<a href="{
|
||||
url_for('notes.formsemestre_change_publication_bul',
|
||||
scodoc_dept=g.scodoc_dept,formsemestre_id=formsemestre_id)
|
||||
}">{eyeicon}</a>"""
|
||||
else:
|
||||
sem["eyelink"] = ""
|
||||
F = sco_formations.formation_list(args={"formation_id": sem["formation_id"]})[0]
|
||||
sem["formation"] = F
|
||||
parcours = sco_codes_parcours.get_parcours_from_code(F["type_parcours"])
|
||||
if sem["semestre_id"] != -1:
|
||||
sem["num_sem"] = ", %s %s" % (parcours.SESSION_NAME, sem["semestre_id"])
|
||||
sem["num_sem"] = f""", {parcours.SESSION_NAME} {sem["semestre_id"]}"""
|
||||
else:
|
||||
sem["num_sem"] = "" # formation sans semestres
|
||||
if sem["modalite"]:
|
||||
sem["modalitestr"] = " en %s" % sem["modalite"]
|
||||
sem["modalitestr"] = f""" en {sem["modalite"]}"""
|
||||
else:
|
||||
sem["modalitestr"] = ""
|
||||
|
||||
|
@ -94,7 +94,7 @@ class ScoData:
|
||||
else:
|
||||
self.sem = formsemestre
|
||||
self.sem_menu_bar = sco_formsemestre_status.formsemestre_status_menubar(
|
||||
self.sem.to_dict()
|
||||
self.sem
|
||||
)
|
||||
# --- Préférences
|
||||
# prefs fallback to global pref if sem is None:
|
||||
|
Loading…
Reference in New Issue
Block a user