petites amélioration du code
This commit is contained in:
parent
d21af70abb
commit
b124468399
@ -811,63 +811,58 @@ def formsemestre_description(
|
||||
|
||||
|
||||
# genere liste html pour accès aux groupes de ce semestre
|
||||
def _make_listes_sem(formsemestre: FormSemestre, with_absences=True):
|
||||
# construit l'URL "destination"
|
||||
# (a laquelle on revient apres saisie absences)
|
||||
destination = url_for(
|
||||
"notes.formsemestre_status",
|
||||
scodoc_dept=g.scodoc_dept,
|
||||
formsemestre_id=formsemestre.id,
|
||||
)
|
||||
#
|
||||
def _make_listes_sem(formsemestre: FormSemestre) -> str:
|
||||
"""La section avec les groupes et l'assiduité"""
|
||||
H = []
|
||||
# pas de menu absences si pas autorise:
|
||||
if with_absences and not current_user.has_permission(Permission.ScoAbsChange):
|
||||
with_absences = False
|
||||
|
||||
can_edit_abs = current_user.has_permission(Permission.ScoAbsChange)
|
||||
#
|
||||
H.append(
|
||||
f"""<h3>Listes de {formsemestre.titre}
|
||||
<span class="infostitresem">({formsemestre.mois_debut()} - {formsemestre.mois_fin()})</span></h3>"""
|
||||
)
|
||||
|
||||
weekday = datetime.datetime.today().weekday()
|
||||
try:
|
||||
if with_absences:
|
||||
form_abs_tmpl = f"""
|
||||
<td>
|
||||
<a class="btn" href="{
|
||||
url_for("assiduites.visu_assi_group", scodoc_dept=g.scodoc_dept)
|
||||
}?group_ids=%(group_id)s&date_debut={formsemestre.date_debut.isoformat()}&date_fin={formsemestre.date_fin.isoformat()}"><button>Visualiser l'assiduité</button></a>
|
||||
"""
|
||||
form_abs_tmpl += f"""
|
||||
<a class="btn" href="{
|
||||
url_for("assiduites.signal_assiduites_group", scodoc_dept=g.scodoc_dept)
|
||||
}?group_ids=%(group_id)s&jour={
|
||||
datetime.date.today().isoformat()
|
||||
}&formsemestre_id={formsemestre.id}"><button>Saisie journalière</button></a>
|
||||
<a class="btn" href="{
|
||||
url_for("assiduites.signal_assiduites_diff", scodoc_dept=g.scodoc_dept)
|
||||
}?group_ids=%(group_id)s&formsemestre_id={
|
||||
formsemestre.formsemestre_id
|
||||
}"><button>Saisie différée</button></a>
|
||||
<a class="btn" href="{
|
||||
url_for("assiduites.bilan_dept", scodoc_dept=g.scodoc_dept)
|
||||
}?group_id=%(group_id)s&formsemestre_id={
|
||||
formsemestre.formsemestre_id
|
||||
}"><button>Justificatifs en attente</button></a>
|
||||
</td>
|
||||
"""
|
||||
else:
|
||||
form_abs_tmpl = f"""
|
||||
<td>
|
||||
<a class="btn" href="{
|
||||
url_for("assiduites.visu_assiduites_group", scodoc_dept=g.scodoc_dept)
|
||||
}?group_ids=%(group_id)s&jour={datetime.date.today().isoformat()}&formsemestre_id={formsemestre.id}"><button>Voir l'assiduité</button></a>
|
||||
</td>
|
||||
"""
|
||||
except ScoInvalidDateError: # dates incorrectes dans semestres ?
|
||||
form_abs_tmpl = ""
|
||||
form_abs_tmpl = f"""
|
||||
<td>
|
||||
<a class="btn" href="{
|
||||
url_for("assiduites.visu_assi_group",
|
||||
scodoc_dept=g.scodoc_dept,
|
||||
date_debut=formsemestre.date_debut.isoformat(),
|
||||
date_fin=formsemestre.date_fin.isoformat()
|
||||
)}&group_ids=%(group_id)s">
|
||||
<button>Bilan assiduité</button></a>
|
||||
"""
|
||||
|
||||
if can_edit_abs:
|
||||
form_abs_tmpl += f"""
|
||||
<a class="btn" href="{
|
||||
url_for("assiduites.visu_assiduites_group",
|
||||
scodoc_dept=g.scodoc_dept,
|
||||
formsemestre_id=formsemestre.id,
|
||||
jour = datetime.date.today().isoformat()
|
||||
)}&group_ids=%(group_id)s">
|
||||
<button>Visualiser l'assiduité</button></a>
|
||||
<a class="btn" href="{
|
||||
url_for("assiduites.signal_assiduites_group",
|
||||
scodoc_dept=g.scodoc_dept,
|
||||
jour=datetime.date.today().isoformat(),
|
||||
formsemestre_id=formsemestre.id,
|
||||
)}&group_ids=%(group_id)s">
|
||||
<button>Saisie journalière</button></a>
|
||||
<a class="btn" href="{
|
||||
url_for("assiduites.signal_assiduites_diff",
|
||||
scodoc_dept=g.scodoc_dept,
|
||||
formsemestre_id=formsemestre.id,
|
||||
)}&group_ids=%(group_id)s">
|
||||
<button>Saisie différée</button></a>
|
||||
<a class="btn" href="{
|
||||
url_for("assiduites.bilan_dept",
|
||||
scodoc_dept=g.scodoc_dept,
|
||||
formsemestre=formsemestre.id,
|
||||
)}&group_id=%(group_id)s">
|
||||
<button>Justificatifs en attente</button></a>
|
||||
"""
|
||||
form_abs_tmpl += "</td>"
|
||||
#
|
||||
H.append('<div id="grouplists">')
|
||||
# Genere liste pour chaque partition (categorie de groupes)
|
||||
@ -875,7 +870,7 @@ def _make_listes_sem(formsemestre: FormSemestre, with_absences=True):
|
||||
if not partition["partition_name"]:
|
||||
H.append("<h4>Tous les étudiants</h4>")
|
||||
else:
|
||||
H.append("<h4>Groupes de %(partition_name)s</h4>" % partition)
|
||||
H.append(f"""<h4>Groupes de {partition["partition_name"]}</h4>""")
|
||||
partition_is_empty = True
|
||||
groups = sco_groups.get_partition_groups(partition)
|
||||
if groups:
|
||||
|
@ -704,8 +704,8 @@ def signal_assiduites_group():
|
||||
@permission_required(Permission.ScoView)
|
||||
def visu_assiduites_group():
|
||||
"""
|
||||
signal_assiduites_group Saisie des assiduités des groupes pour le jour donnée
|
||||
|
||||
Visualisation des assiduités des groupes pour le jour donné
|
||||
dans le formsemestre_id et le moduleimpl_id
|
||||
Returns:
|
||||
str: l'html généré
|
||||
"""
|
||||
@ -721,15 +721,17 @@ def visu_assiduites_group():
|
||||
map(str, group_ids)
|
||||
|
||||
# Vérification du moduleimpl_id
|
||||
try:
|
||||
moduleimpl_id = int(moduleimpl_id)
|
||||
except (TypeError, ValueError):
|
||||
moduleimpl_id = None
|
||||
if moduleimpl_id is not None:
|
||||
try:
|
||||
moduleimpl_id = int(moduleimpl_id)
|
||||
except (TypeError, ValueError) as exc:
|
||||
raise ScoValueError("identifiant de moduleimpl invalide") from exc
|
||||
# Vérification du formsemestre_id
|
||||
try:
|
||||
formsemestre_id = int(formsemestre_id)
|
||||
except (TypeError, ValueError):
|
||||
formsemestre_id = None
|
||||
if formsemestre_id is not None:
|
||||
try:
|
||||
formsemestre_id = int(formsemestre_id)
|
||||
except (TypeError, ValueError) as exc:
|
||||
raise ScoValueError("identifiant de formsemestre invalide") from exc
|
||||
|
||||
groups_infos = sco_groups_view.DisplayedGroupsInfos(
|
||||
group_ids, moduleimpl_id=moduleimpl_id, formsemestre_id=formsemestre_id
|
||||
@ -924,6 +926,7 @@ def etat_abs_date():
|
||||
@scodoc
|
||||
@permission_required(Permission.ScoView)
|
||||
def visu_assi_group():
|
||||
"""Visualisation de l'assiduité d'un groupe entre deux dates"""
|
||||
dates = {
|
||||
"debut": request.args.get("date_debut"),
|
||||
"fin": request.args.get("date_fin"),
|
||||
|
Loading…
Reference in New Issue
Block a user