amélioration code formsemestre_status

This commit is contained in:
Emmanuel Viennet 2021-07-26 17:52:38 +03:00
parent 97446272af
commit c3e3f45370
3 changed files with 65 additions and 55 deletions

View File

@ -28,9 +28,6 @@
"""Tableau de bord semestre """Tableau de bord semestre
""" """
import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error
import cgi
from flask import current_app from flask import current_app
from flask import g from flask import g
from flask import url_for from flask import url_for
@ -773,21 +770,13 @@ def formsemestre_description(
def _make_listes_sem(context, sem, REQUEST=None, with_absences=True): def _make_listes_sem(context, sem, REQUEST=None, with_absences=True):
context = context context = context
authuser = REQUEST.AUTHENTICATED_USER authuser = REQUEST.AUTHENTICATED_USER
r = scu.ScoURL() # root url
# construit l'URL "destination" # construit l'URL "destination"
# (a laquelle on revient apres saisie absences) # (a laquelle on revient apres saisie absences)
query_args = cgi.parse_qs(REQUEST.QUERY_STRING) # XXX TODO a revoir #py3 destination = url_for(
# soit via flask soit via https://docs.python.org/3/library/urllib.parse.html#module-urllib.parse "notes.formsemestre_status",
if "head_message" in query_args: scodoc_dept=g.scodoc_dept,
del query_args["head_message"] formsemestre_id=sem["formsemestre_id"],
destination = "%s?%s" % (
REQUEST.URL,
six.moves.urllib.parse.urlencode(query_args, True),
) )
destination = destination.replace(
"%", "%%"
) # car ici utilisee dans un format string !
# #
H = [] H = []
# pas de menu absences si pas autorise: # pas de menu absences si pas autorise:
@ -806,39 +795,29 @@ def _make_listes_sem(context, sem, REQUEST=None, with_absences=True):
try: try:
if with_absences: if with_absences:
first_monday = sco_abs.ddmmyyyy(sem["date_debut"]).prev_monday() first_monday = sco_abs.ddmmyyyy(sem["date_debut"]).prev_monday()
FA = [] # formulaire avec menu saisi absences form_abs_tmpl = f"""
FA.append( <td><form action="{url_for(
'<td><form action="{}" method="get">'.format(
url_for(
"absences.SignaleAbsenceGrSemestre", scodoc_dept=g.scodoc_dept "absences.SignaleAbsenceGrSemestre", scodoc_dept=g.scodoc_dept
) )}" method="get">
) <input type="hidden" name="datefin" value="{sem['date_fin']}"/>
) <input type="hidden" name="group_ids" value="%(group_id)s"/>
FA.append( <input type="hidden" name="destination" value="{destination}"/>
'<input type="hidden" name="datefin" value="%(date_fin)s"/>' % sem <input type="submit" value="Saisir absences du" />
) <select name="datedebut" class="noprint">
FA.append('<input type="hidden" name="group_ids" value="%(group_id)s"/>') """
FA.append(
'<input type="hidden" name="destination" value="%s"/>' % destination
)
FA.append('<input type="submit" value="Saisir absences du" />')
FA.append('<select name="datedebut" class="noprint">')
date = first_monday date = first_monday
for jour in sco_abs.day_names(context): for jour in sco_abs.day_names(context):
FA.append('<option value="%s">%s</option>' % (date, jour)) form_abs_tmpl += '<option value="%s">%s</option>' % (date, jour)
date = date.next_day() date = date.next_day()
FA.append("</select>") form_abs_tmpl += """
FA.append( </select>
'<a href="Absences/EtatAbsencesGr?group_ids=%%(group_id)s&debut=%(date_debut)s&fin=%(date_fin)s">état</a>' <a href="%(url_etat)s">état</a>
% sem </form></td>
) """
FA.append("</form></td>")
FormAbs = "\n".join(FA)
else: else:
FormAbs = "" form_abs_tmpl = ""
except ScoInvalidDateError: # dates incorrectes dans semestres ? except ScoInvalidDateError: # dates incorrectes dans semestres ?
FormAbs = "" form_abs_tmpl = ""
# #
H.append('<div id="grouplists">') H.append('<div id="grouplists">')
# Genere liste pour chaque partition (categorie de groupes) # Genere liste pour chaque partition (categorie de groupes)
@ -854,25 +833,50 @@ def _make_listes_sem(context, sem, REQUEST=None, with_absences=True):
n_members = len( n_members = len(
sco_groups.get_group_members(context, group["group_id"]) sco_groups.get_group_members(context, group["group_id"])
) )
group["url"] = r group["url_etat"] = url_for(
"absences.EtatAbsencesGr",
group_ids=group["group_id"],
debut=sem["date_debut"],
fin=sem["date_fin"],
scodoc_dept=g.scodoc_dept,
)
if group["group_name"]: if group["group_name"]:
group["label"] = "groupe %(group_name)s" % group group["label"] = "groupe %(group_name)s" % group
else: else:
group["label"] = "liste" group["label"] = "liste"
H.append('<tr class="listegroupelink">')
H.append( H.append(
"""<td> f"""
<a href="%(url)s/groups_view?group_ids=%(group_id)s">%(label)s</a> <tr class="listegroupelink">
<td>
<a href="{
url_for("scolar.groups_view",
group_ids=group["group_id"],
scodoc_dept=g.scodoc_dept,
)
}">{group["label"]}</a>
</td><td> </td><td>
(<a href="%(url)s/groups_view?group_ids=%(group_id)s&format=xls">format tableur</a>) (<a href="{
<a href="%(url)s/groups_view?curtab=tab-photos&group_ids=%(group_id)s&etat=I">Photos</a> url_for("scolar.groups_view",
</td>""" group_ids=group["group_id"],
% group format="xls",
scodoc_dept=g.scodoc_dept,
)
}">tableur</a>)
<a href="{
url_for("scolar.groups_view",
curtab="tab-photos",
group_ids=group["group_id"],
etat="I",
scodoc_dept=g.scodoc_dept,
)
}">Photos</a>
</td>
<td>({n_members} étudiants)</td>
"""
) )
H.append("<td>(%d étudiants)</td>" % n_members)
if with_absences: if with_absences:
H.append(FormAbs % group) H.append(form_abs_tmpl % group)
H.append("</tr>") H.append("</tr>")
H.append("</table>") H.append("</table>")
@ -890,8 +894,13 @@ def _make_listes_sem(context, sem, REQUEST=None, with_absences=True):
context, REQUEST, formsemestre_id context, REQUEST, formsemestre_id
): ):
H.append( H.append(
'<h4><a href="editPartitionForm?formsemestre_id=%s">Ajouter une partition</a></h4>' f"""<h4><a
% formsemestre_id href="{
url_for("scolar.editPartitionForm",
formsemestre_id=formsemestre_id,
scodoc_dept=g.scodoc_dept,
)
}">Ajouter une partition</a></h4>"""
) )
H.append("</div>") H.append("</div>")

View File

@ -184,6 +184,7 @@ sco_publish(
"/formsemestre_createwithmodules", "/formsemestre_createwithmodules",
sco_formsemestre_edit.formsemestre_createwithmodules, sco_formsemestre_edit.formsemestre_createwithmodules,
Permission.ScoImplement, Permission.ScoImplement,
methods=["GET", "POST"],
) )
# controle d'acces specifique pour dir. etud: # controle d'acces specifique pour dir. etud:

View File

@ -1505,7 +1505,7 @@ def _etudident_create_or_edit_form(context, REQUEST, edit):
return REQUEST.RESPONSE.redirect("ficheEtud?etudid=" + etudid) return REQUEST.RESPONSE.redirect("ficheEtud?etudid=" + etudid)
@bp.route("/etudident_delete") @bp.route("/etudident_delete", methods=["GET", "POST"])
@permission_required(Permission.ScoEtudInscrit) @permission_required(Permission.ScoEtudInscrit)
@scodoc7func(context) @scodoc7func(context)
def etudident_delete(context, etudid, dialog_confirmed=False, REQUEST=None): def etudident_delete(context, etudid, dialog_confirmed=False, REQUEST=None):