1
0
forked from ScoDoc/ScoDoc

Modifie refcomp_desassoc (#506)

This commit is contained in:
Emmanuel Viennet 2022-10-29 08:22:17 +02:00
parent 9db334dd65
commit b36e39cae8
5 changed files with 42 additions and 41 deletions

View File

@ -233,6 +233,21 @@ class Formation(db.Model):
.filter(ApcAnneeParcours.parcours_id == parcour.id) .filter(ApcAnneeParcours.parcours_id == parcour.id)
) )
def refcomp_desassoc(self):
"""Désassocie la formation de son ref. de compétence"""
self.referentiel_competence = None
db.session.add(self)
# Niveaux des UE
for ue in self.ues:
ue.niveau_competence = None
db.session.add(ue)
# Parcours et AC des modules
for mod in self.modules:
mod.parcours = []
mod.app_critiques = []
db.session.add(mod)
db.session.commit()
class Matiere(db.Model): class Matiere(db.Model):
"""Matières: regroupe les modules d'une UE """Matières: regroupe les modules d'une UE

View File

@ -66,7 +66,8 @@ class Module(db.Model):
super(Module, self).__init__(**kwargs) super(Module, self).__init__(**kwargs)
def __repr__(self): def __repr__(self):
return f"<Module{ModuleType(self.module_type or ModuleType.STANDARD).name} id={self.id} code={self.code!r} semestre_id={self.semestre_id}>" return f"""<Module{ModuleType(self.module_type or ModuleType.STANDARD).name
} id={self.id} code={self.code!r} semestre_id={self.semestre_id}>"""
def to_dict(self, convert_objects=False, with_matiere=False, with_ue=False) -> dict: def to_dict(self, convert_objects=False, with_matiere=False, with_ue=False) -> dict:
"""If convert_objects, convert all attributes to native types """If convert_objects, convert all attributes to native types

View File

@ -677,36 +677,34 @@ def _gen_form_saisie_groupe(
moduleimpl_id: optionnel, module concerné. moduleimpl_id: optionnel, module concerné.
""" """
H = [ H = [
""" f"""
<script type="text/javascript"> <script type="text/javascript">
$(function() { $(function() {{
$(".abs_form_table input").prop( "disabled", %s ); $(".abs_form_table input").prop( "disabled", {
}); "true" if (require_module and not moduleimpl_id) else "false"
function colorize(obj) { } );
if (obj.checked) { }});
function colorize(obj) {{
if (obj.checked) {{
obj.parentNode.className = 'absent'; obj.parentNode.className = 'absent';
} else { }} else {{
obj.parentNode.className = 'present'; obj.parentNode.className = 'present';
} }}
} }}
function on_toggled(obj, etudid, dat) { function on_toggled(obj, etudid, dat) {{
colorize(obj); colorize(obj);
if (obj.checked) { if (obj.checked) {{
ajaxFunction('add', etudid, dat); ajaxFunction('add', etudid, dat);
} else { }} else {{
ajaxFunction('remove', etudid, dat); ajaxFunction('remove', etudid, dat);
} }}
} }}
</script> </script>
<div id="AjaxDiv"></div> <div id="AjaxDiv"></div>
<br> <br>
<table rules="cols" frame="box" class="abs_form_table"> <table rules="cols" frame="box" class="abs_form_table">
<tr><th class="formabs_contetud">%d étudiants</th> <tr><th class="formabs_contetud">{len(etuds)} étudiants</th>
""" """
% (
"true" if (require_module and not moduleimpl_id) else "false",
len(etuds),
)
] ]
# Dates # Dates
odates = [datetime.date(*[int(x) for x in d.split("-")]) for d in dates] odates = [datetime.date(*[int(x) for x in d.split("-")]) for d in dates]
@ -720,16 +718,16 @@ def _gen_form_saisie_groupe(
noms_jours.append(jn[idx_jour]) noms_jours.append(jn[idx_jour])
for jour in noms_jours: for jour in noms_jours:
H.append( H.append(
'<th colspan="2" width="100px" style="padding-left: 5px; padding-right: 5px;">' f"""<th colspan="2" width="100px" style="padding-left: 5px; padding-right: 5px;">
+ jour { jour }
+ "</th>" </th>"""
) )
H.append("</tr><tr><td>&nbsp;</td>") H.append("</tr><tr><td>&nbsp;</td>")
for d in odates: for d in odates:
H.append( H.append(
'<th colspan="2" width="100px" style="padding-left: 5px; padding-right: 5px;">' f"""<th colspan="2" width="100px" style="padding-left: 5px; padding-right: 5px;">
+ d.strftime("%d/%m/%Y") { d.strftime("%d/%m/%Y") }
+ "</th>" </th>"""
) )
H.append("</tr><tr><td>&nbsp;</td>") H.append("</tr><tr><td>&nbsp;</td>")
H.append("<th>AM</th><th>PM</th>" * len(dates)) H.append("<th>AM</th><th>PM</th>" * len(dates))
@ -1483,16 +1481,6 @@ def process_billet_absence_form(billet_id):
return "\n".join(H) + html_sco_header.sco_footer() return "\n".join(H) + html_sco_header.sco_footer()
# @bp.route("/essai_api7")
# @scodoc
# @permission_required_compat_scodoc7(Permission.ScoView)
# @scodoc7func
# def essai_api7(x="xxx"):
# "un essai"
# log("arfffffffffffffffffff")
# return "OK OK x=" + str(x)
@bp.route("/XMLgetAbsEtud", methods=["GET", "POST"]) # pour compat anciens clients PHP @bp.route("/XMLgetAbsEtud", methods=["GET", "POST"]) # pour compat anciens clients PHP
@scodoc @scodoc
@permission_required_compat_scodoc7(Permission.ScoView) @permission_required_compat_scodoc7(Permission.ScoView)
@ -1503,7 +1491,6 @@ def XMLgetAbsEtud(beg_date="", end_date=""):
etuds = sco_etud.get_etud_info(filled=False) etuds = sco_etud.get_etud_info(filled=False)
if not etuds: if not etuds:
raise APIInvalidParams("étudiant inconnu") raise APIInvalidParams("étudiant inconnu")
# raise ScoValueError("étudiant inconnu")
etud = etuds[0] etud = etuds[0]
exp = re.compile(r"^(\d{4})\D?(0[1-9]|1[0-2])\D?([12]\d|0[1-9]|3[01])$") exp = re.compile(r"^(\d{4})\D?(0[1-9]|1[0-2])\D?([12]\d|0[1-9]|3[01])$")
if not exp.match(beg_date): if not exp.match(beg_date):

View File

@ -166,9 +166,7 @@ def refcomp_assoc_formation(formation_id: int):
def refcomp_desassoc_formation(formation_id: int): def refcomp_desassoc_formation(formation_id: int):
"""Désassocie la formation de son ref. de compétence""" """Désassocie la formation de son ref. de compétence"""
formation = Formation.query.get_or_404(formation_id) formation = Formation.query.get_or_404(formation_id)
formation.referentiel_competence = None formation.refcomp_desassoc()
db.session.add(formation)
db.session.commit()
return redirect( return redirect(
url_for("notes.ue_table", scodoc_dept=g.scodoc_dept, formation_id=formation.id) url_for("notes.ue_table", scodoc_dept=g.scodoc_dept, formation_id=formation.id)
) )

View File

@ -1,7 +1,7 @@
# -*- mode: python -*- # -*- mode: python -*-
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
SCOVERSION = "9.3.59" SCOVERSION = "9.3.60"
SCONAME = "ScoDoc" SCONAME = "ScoDoc"