Fix: éditions evaluation sur moduleimpl_status

This commit is contained in:
Emmanuel Viennet 2022-04-28 07:06:01 +02:00
parent 86ef24586d
commit f740ab8339

View File

@ -210,10 +210,17 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
) # la plus RECENTE en tête ) # la plus RECENTE en tête
# #
caneditevals = sco_permissions_check.can_edit_notes( sem_locked = not sem["etat"]
can_edit_evals = (
sco_permissions_check.can_edit_notes(
current_user, moduleimpl_id, allow_ens=sem["ens_can_edit_eval"] current_user, moduleimpl_id, allow_ens=sem["ens_can_edit_eval"]
) )
caneditnotes = sco_permissions_check.can_edit_notes(current_user, moduleimpl_id) and not sem_locked
)
can_edit_notes = (
sco_permissions_check.can_edit_notes(current_user, moduleimpl_id)
and not sem_locked
)
arrow_up, arrow_down, arrow_none = sco_groups.get_arrow_icons_tags() arrow_up, arrow_down, arrow_none = sco_groups.get_arrow_icons_tags()
# #
module_resp = User.query.get(M["responsable_id"]) module_resp = User.query.get(M["responsable_id"])
@ -264,7 +271,7 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
H.append("""Semestre: </td><td>%s""" % sem["semestre_id"]) H.append("""Semestre: </td><td>%s""" % sem["semestre_id"])
else: else:
H.append("""</td><td>""") H.append("""</td><td>""")
if not sem["etat"]: if sem_locked:
H.append(scu.icontag("lock32_img", title="verrouillé")) H.append(scu.icontag("lock32_img", title="verrouillé"))
H.append("""</td><td class="fichetitre2">""") H.append("""</td><td class="fichetitre2">""")
if modimpl.module.is_apc(): if modimpl.module.is_apc():
@ -385,13 +392,15 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
# -------- Tableau des evaluations # -------- Tableau des evaluations
top_table_links = "" top_table_links = ""
if sem["etat"]: # non verrouillé if can_edit_evals:
top_table_links = ( top_table_links = f"""<a class="stdlink" href="{
"""<a class="stdlink" href="evaluation_create?moduleimpl_id=%(moduleimpl_id)s">Créer nouvelle évaluation</a> url_for("notes.evaluation_create", scodoc_dept=g.scodoc_dept, moduleimpl_id=M['moduleimpl_id'])
<a class="stdlink" style="margin-left:2em;" href="module_evaluation_renumber?moduleimpl_id=%(moduleimpl_id)s&redirect=1">Trier par date</a> }">Créer nouvelle évaluation</a>
<a class="stdlink" style="margin-left:2em;" href="{
url_for("notes.module_evaluation_renumber", scodoc_dept=g.scodoc_dept, moduleimpl_id=M['moduleimpl_id'],
redirect=1)
}">Trier par date</a>
""" """
% M
)
if mod_evals: if mod_evals:
H.append( H.append(
'<div class="moduleimpl_evaluations_top_links">' '<div class="moduleimpl_evaluations_top_links">'
@ -451,14 +460,14 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
) )
# Fleches: # Fleches:
H.append('<span class="eval_arrows_chld">') H.append('<span class="eval_arrows_chld">')
if eval_index != (len(mod_evals) - 1) and caneditevals: if eval_index != (len(mod_evals) - 1) and can_edit_evals:
H.append( H.append(
'<a href="module_evaluation_move?evaluation_id=%s&after=0" class="aud">%s</a>' '<a href="module_evaluation_move?evaluation_id=%s&after=0" class="aud">%s</a>'
% (eval["evaluation_id"], arrow_up) % (eval["evaluation_id"], arrow_up)
) )
else: else:
H.append(arrow_none) H.append(arrow_none)
if (eval_index > 0) and caneditevals: if (eval_index > 0) and can_edit_evals:
H.append( H.append(
'<a href="module_evaluation_move?evaluation_id=%s&after=1" class="aud">%s</a>' '<a href="module_evaluation_move?evaluation_id=%s&after=1" class="aud">%s</a>'
% (eval["evaluation_id"], arrow_down) % (eval["evaluation_id"], arrow_down)
@ -487,7 +496,7 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
etat_descr = "il manque des notes" etat_descr = "il manque des notes"
else: else:
etat_txt = "" etat_txt = ""
if caneditevals and etat_txt: if can_edit_evals and etat_txt:
etat_txt = ( etat_txt = (
'<a href="evaluation_edit?evaluation_id=%s" title="%s">%s</a>' '<a href="evaluation_edit?evaluation_id=%s" title="%s">%s</a>'
% (eval["evaluation_id"], etat_descr, etat_txt) % (eval["evaluation_id"], etat_descr, etat_txt)
@ -496,7 +505,7 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
H.append("""</th></tr>""") H.append("""</th></tr>""")
H.append("""<tr class="%s"><td class="mievr">""" % tr_class) H.append("""<tr class="%s"><td class="mievr">""" % tr_class)
if caneditevals: if can_edit_evals:
H.append( H.append(
"""<a class="smallbutton" href="evaluation_edit?evaluation_id=%s">%s</a>""" """<a class="smallbutton" href="evaluation_edit?evaluation_id=%s">%s</a>"""
% ( % (
@ -506,7 +515,7 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
), ),
) )
) )
if caneditnotes: if can_edit_notes:
H.append( H.append(
"""<a class="smallbutton" href="saisie_notes?evaluation_id=%s">%s</a>""" """<a class="smallbutton" href="saisie_notes?evaluation_id=%s">%s</a>"""
% ( % (
@ -517,13 +526,13 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
) )
) )
if etat["nb_notes"] == 0: if etat["nb_notes"] == 0:
if caneditevals: if can_edit_evals:
H.append( H.append(
"""<a class="smallbutton" href="evaluation_delete?evaluation_id=%(evaluation_id)s">""" """<a class="smallbutton" href="evaluation_delete?evaluation_id=%(evaluation_id)s">"""
% eval % eval
) )
H.append(scu.icontag("delete_img", alt="supprimer", title="Supprimer")) H.append(scu.icontag("delete_img", alt="supprimer", title="Supprimer"))
if caneditevals: if can_edit_evals:
H.append("""</a>""") H.append("""</a>""")
elif etat["evalcomplete"]: elif etat["evalcomplete"]:
H.append( H.append(
@ -561,7 +570,7 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
else: else:
H.append("&nbsp;") H.append("&nbsp;")
H.append('</td><td class="mievr_menu">') H.append('</td><td class="mievr_menu">')
if caneditnotes: if can_edit_notes:
H.append( H.append(
moduleimpl_evaluation_menu( moduleimpl_evaluation_menu(
eval["evaluation_id"], eval["evaluation_id"],
@ -644,7 +653,7 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
H.append(""")""") H.append(""")""")
if gr_moyenne["group_id"] in etat["gr_incomplets"]: if gr_moyenne["group_id"] in etat["gr_incomplets"]:
H.append("""[<font color="red">""") H.append("""[<font color="red">""")
if caneditnotes: if can_edit_notes:
H.append( H.append(
"""<a class="redlink" href="saisie_notes?evaluation_id=%s&group_ids:list=%s">incomplet</a></font>]""" """<a class="redlink" href="saisie_notes?evaluation_id=%s&group_ids:list=%s">incomplet</a></font>]"""
% (eval["evaluation_id"], gr_moyenne["group_id"]) % (eval["evaluation_id"], gr_moyenne["group_id"])
@ -653,24 +662,24 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
H.append("""incomplet</font>]""") H.append("""incomplet</font>]""")
else: else:
H.append("""<span class="redboldtext">&nbsp; """) H.append("""<span class="redboldtext">&nbsp; """)
if caneditnotes: if can_edit_notes:
H.append( H.append(
"""<a class="redlink" href="saisie_notes?evaluation_id=%s&group_ids:list=%s">""" """<a class="redlink" href="saisie_notes?evaluation_id=%s&group_ids:list=%s">"""
% (eval["evaluation_id"], gr_moyenne["group_id"]) % (eval["evaluation_id"], gr_moyenne["group_id"])
) )
H.append("pas de notes") H.append("pas de notes")
if caneditnotes: if can_edit_notes:
H.append("""</a>""") H.append("""</a>""")
H.append("</span>") H.append("</span>")
H.append("""</td></tr>""") H.append("""</td></tr>""")
first_eval = False first_eval = False
# #
if caneditevals or not sem["etat"]:
H.append("""<tr><td colspan="8">""") H.append("""<tr><td colspan="8">""")
if not sem["etat"]: if sem_locked:
H.append("""%s semestre verrouillé""" % scu.icontag("lock32_img")) H.append(f"""{scu.icontag("lock32_img")} semestre verrouillé""")
else: elif can_edit_evals:
H.append(top_table_links) H.append(top_table_links)
H.append( H.append(