forked from ScoDoc/ScoDoc
formules d'UE: affichage pour suppression
This commit is contained in:
parent
bb40532ca6
commit
ce5e379d29
@ -22,6 +22,7 @@ from app.models.etudiants import Identite
|
|||||||
from app.scodoc import sco_codes_parcours
|
from app.scodoc import sco_codes_parcours
|
||||||
from app.scodoc import sco_preferences
|
from app.scodoc import sco_preferences
|
||||||
from app.scodoc.sco_vdi import ApoEtapeVDI
|
from app.scodoc.sco_vdi import ApoEtapeVDI
|
||||||
|
from app.scodoc.sco_permissions import Permission
|
||||||
|
|
||||||
|
|
||||||
class FormSemestre(db.Model):
|
class FormSemestre(db.Model):
|
||||||
@ -177,6 +178,16 @@ class FormSemestre(db.Model):
|
|||||||
)
|
)
|
||||||
return modimpls
|
return modimpls
|
||||||
|
|
||||||
|
def can_be_edited_by(self, user):
|
||||||
|
"""Vrai si user peut modifier ce semestre"""
|
||||||
|
if not user.has_permission(Permission.ScoImplement): # pas chef
|
||||||
|
if not self.resp_can_edit or user.id not in [
|
||||||
|
resp.id for resp in self.responsables
|
||||||
|
]:
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
def est_courant(self) -> bool:
|
def est_courant(self) -> bool:
|
||||||
"""Vrai si la date actuelle (now) est dans le semestre
|
"""Vrai si la date actuelle (now) est dans le semestre
|
||||||
(les dates de début et fin sont incluses)
|
(les dates de début et fin sont incluses)
|
||||||
@ -425,7 +436,7 @@ class FormSemestreUECoef(db.Model):
|
|||||||
|
|
||||||
|
|
||||||
class FormSemestreUEComputationExpr(db.Model):
|
class FormSemestreUEComputationExpr(db.Model):
|
||||||
"""Formules utilisateurs pour calcul moyenne UE"""
|
"""Formules utilisateurs pour calcul moyenne UE (désactivées en 9.2+)."""
|
||||||
|
|
||||||
__tablename__ = "notes_formsemestre_ue_computation_expr"
|
__tablename__ = "notes_formsemestre_ue_computation_expr"
|
||||||
__table_args__ = (db.UniqueConstraint("formsemestre_id", "ue_id"),)
|
__table_args__ = (db.UniqueConstraint("formsemestre_id", "ue_id"),)
|
||||||
|
@ -1152,30 +1152,19 @@ def formsemestre_tableau_modules(
|
|||||||
f"""<tr class="formsemestre_status_ue"><td colspan="4">
|
f"""<tr class="formsemestre_status_ue"><td colspan="4">
|
||||||
<span class="status_ue_acro">{ue["acronyme"]}</span>
|
<span class="status_ue_acro">{ue["acronyme"]}</span>
|
||||||
<span class="status_ue_title">{titre}</span>
|
<span class="status_ue_title">{titre}</span>
|
||||||
</td><td>"""
|
</td><td colspan="2">"""
|
||||||
)
|
)
|
||||||
if can_edit:
|
|
||||||
H.append(
|
|
||||||
' <a href="edit_ue_expr?formsemestre_id=%s&ue_id=%s">'
|
|
||||||
% (formsemestre_id, ue["ue_id"])
|
|
||||||
)
|
|
||||||
H.append(
|
|
||||||
scu.icontag(
|
|
||||||
"formula",
|
|
||||||
title="Mode calcul moyenne d'UE",
|
|
||||||
style="vertical-align:middle",
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if can_edit:
|
|
||||||
H.append("</a>")
|
|
||||||
|
|
||||||
expr = sco_compute_moy.get_ue_expression(
|
expr = sco_compute_moy.get_ue_expression(
|
||||||
formsemestre_id, ue["ue_id"], html_quote=True
|
formsemestre_id, ue["ue_id"], html_quote=True
|
||||||
)
|
)
|
||||||
if expr:
|
if expr:
|
||||||
H.append(
|
H.append(
|
||||||
""" <span class="formula" title="mode de calcul de la moyenne d'UE">%s</span>"""
|
f""" <span class="formula" title="mode de calcul de la moyenne d'UE">{expr}</span>
|
||||||
% expr
|
<span class="warning">formule inutilisée en 9.2: <a href="{
|
||||||
|
url_for("notes.delete_ue_expr", scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre_id, ue_id=ue["ue_id"] )
|
||||||
|
}
|
||||||
|
">supprimer</a></span>"""
|
||||||
)
|
)
|
||||||
|
|
||||||
H.append("</td></tr>")
|
H.append("</td></tr>")
|
||||||
|
@ -30,23 +30,19 @@ Module notes: issu de ScoDoc7 / ZNotes.py
|
|||||||
|
|
||||||
Emmanuel Viennet, 2021
|
Emmanuel Viennet, 2021
|
||||||
"""
|
"""
|
||||||
import sys
|
|
||||||
import time
|
|
||||||
import datetime
|
|
||||||
import pprint
|
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
from xml.etree import ElementTree
|
from xml.etree import ElementTree
|
||||||
|
|
||||||
import flask
|
import flask
|
||||||
from flask import url_for, jsonify, render_template
|
from flask import flash, jsonify, render_template, url_for
|
||||||
from flask import current_app, g, request
|
from flask import current_app, g, request
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
from werkzeug.utils import redirect
|
from werkzeug.utils import redirect
|
||||||
from app.models.formsemestre import FormSemestre
|
from app.models.formsemestre import FormSemestre
|
||||||
|
from app.models.formsemestre import FormSemestreUEComputationExpr
|
||||||
from app.models.ues import UniteEns
|
from app.models.ues import UniteEns
|
||||||
|
|
||||||
from config import Config
|
|
||||||
|
|
||||||
from app import api
|
from app import api
|
||||||
from app import db
|
from app import db
|
||||||
from app import models
|
from app import models
|
||||||
@ -1245,75 +1241,27 @@ def view_module_abs(moduleimpl_id, format="html"):
|
|||||||
return "\n".join(H) + tab.html() + html_sco_header.sco_footer()
|
return "\n".join(H) + tab.html() + html_sco_header.sco_footer()
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/edit_ue_expr", methods=["GET", "POST"])
|
@bp.route("/delete_ue_expr/<int:formsemestre_id>/<int:ue_id>", methods=["GET", "POST"])
|
||||||
@scodoc
|
@scodoc
|
||||||
@permission_required(Permission.ScoView)
|
def delete_ue_expr(formsemestre_id: int, ue_id: int):
|
||||||
@scodoc7func
|
"""Efface une expression de calcul d'UE"""
|
||||||
def edit_ue_expr(formsemestre_id, ue_id):
|
formsemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||||
"""Edition formule calcul moyenne UE"""
|
if not formsemestre.can_be_edited_by(current_user):
|
||||||
# Check access
|
|
||||||
sem = sco_formsemestre_edit.can_edit_sem(formsemestre_id)
|
|
||||||
if not sem:
|
|
||||||
raise AccessDenied("vous n'avez pas le droit d'effectuer cette opération")
|
raise AccessDenied("vous n'avez pas le droit d'effectuer cette opération")
|
||||||
cnx = ndb.GetDBConnexion()
|
expr = FormSemestreUEComputationExpr.query.filter_by(
|
||||||
#
|
formsemestre_id=formsemestre_id, ue_id=ue_id
|
||||||
ue = sco_edit_ue.ue_list({"ue_id": ue_id})[0]
|
).first()
|
||||||
H = [
|
if expr is not None:
|
||||||
html_sco_header.html_sem_header(
|
db.session.delete(expr)
|
||||||
"Modification règle de calcul de l'UE %s (%s)"
|
db.session.commit()
|
||||||
% (ue["acronyme"], ue["titre"]),
|
flash("formule supprimée")
|
||||||
),
|
|
||||||
_EXPR_HELP % {"target": "de l'UE", "objs": "modules", "ordre": ""},
|
|
||||||
]
|
|
||||||
el = sco_compute_moy.formsemestre_ue_computation_expr_list(
|
|
||||||
cnx, {"formsemestre_id": formsemestre_id, "ue_id": ue_id}
|
|
||||||
)
|
|
||||||
if el:
|
|
||||||
initvalues = el[0]
|
|
||||||
else:
|
|
||||||
initvalues = {}
|
|
||||||
form = [
|
|
||||||
("ue_id", {"input_type": "hidden"}),
|
|
||||||
("formsemestre_id", {"input_type": "hidden"}),
|
|
||||||
(
|
|
||||||
"computation_expr",
|
|
||||||
{
|
|
||||||
"title": "Formule de calcul",
|
|
||||||
"input_type": "textarea",
|
|
||||||
"rows": 4,
|
|
||||||
"cols": 60,
|
|
||||||
"explanation": "formule de calcul (expérimental)",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
]
|
|
||||||
tf = TrivialFormulator(
|
|
||||||
request.base_url,
|
|
||||||
scu.get_request_args(),
|
|
||||||
form,
|
|
||||||
submitlabel="Modifier formule de calcul",
|
|
||||||
cancelbutton="Annuler",
|
|
||||||
initvalues=initvalues,
|
|
||||||
)
|
|
||||||
if tf[0] == 0:
|
|
||||||
return "\n".join(H) + tf[1] + html_sco_header.sco_footer()
|
|
||||||
elif tf[0] == -1:
|
|
||||||
return flask.redirect(
|
return flask.redirect(
|
||||||
"formsemestre_status?formsemestre_id=" + str(formsemestre_id)
|
url_for(
|
||||||
|
"notes.formsemestre_status",
|
||||||
|
scodoc_dept=g.scodoc_dept,
|
||||||
|
formsemestre_id=formsemestre_id,
|
||||||
|
head_message="formule supprimée",
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
if el:
|
|
||||||
el[0]["computation_expr"] = tf[2]["computation_expr"]
|
|
||||||
sco_compute_moy.formsemestre_ue_computation_expr_edit(cnx, el[0])
|
|
||||||
else:
|
|
||||||
sco_compute_moy.formsemestre_ue_computation_expr_create(cnx, tf[2])
|
|
||||||
|
|
||||||
sco_cache.invalidate_formsemestre(
|
|
||||||
formsemestre_id=formsemestre_id
|
|
||||||
) # > modif regle calcul
|
|
||||||
return flask.redirect(
|
|
||||||
"formsemestre_status?formsemestre_id="
|
|
||||||
+ str(formsemestre_id)
|
|
||||||
+ "&head_message=règle%20de%20calcul%20modifiée"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user