1
0
forked from ScoDoc/ScoDoc

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

View File

@ -184,6 +184,7 @@ sco_publish(
"/formsemestre_createwithmodules",
sco_formsemestre_edit.formsemestre_createwithmodules,
Permission.ScoImplement,
methods=["GET", "POST"],
)
# 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)
@bp.route("/etudident_delete")
@bp.route("/etudident_delete", methods=["GET", "POST"])
@permission_required(Permission.ScoEtudInscrit)
@scodoc7func(context)
def etudident_delete(context, etudid, dialog_confirmed=False, REQUEST=None):