281 lines
9.8 KiB
Python
281 lines
9.8 KiB
Python
# -*- mode: python -*-
|
|
# -*- coding: utf-8 -*-
|
|
|
|
##############################################################################
|
|
#
|
|
# Gestion scolarite IUT
|
|
#
|
|
# Copyright (c) 1999 - 2021 Emmanuel Viennet. All rights reserved.
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program; if not, write to the Free Software
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
#
|
|
# Emmanuel Viennet emmanuel.viennet@viennet.net
|
|
#
|
|
##############################################################################
|
|
|
|
"""Page accueil département (liste des semestres, etc)
|
|
"""
|
|
|
|
from flask import g
|
|
from flask_login import current_user
|
|
|
|
import app.scodoc.sco_utils as scu
|
|
from app.scodoc.gen_tables import GenTable
|
|
from app.scodoc.sco_permissions import Permission
|
|
from app.scodoc import html_sco_header
|
|
from app.scodoc import sco_formsemestre
|
|
from app.scodoc import sco_formsemestre_inscriptions
|
|
from app.scodoc import sco_modalites
|
|
from app.scodoc import sco_news
|
|
from app.scodoc import sco_preferences
|
|
from app.scodoc import sco_up_to_date
|
|
from app.scodoc import sco_users
|
|
|
|
|
|
def index_html(context, REQUEST=None, showcodes=0, showsemtable=0):
|
|
"Page accueil département (liste des semestres)"
|
|
showsemtable = int(showsemtable)
|
|
H = []
|
|
|
|
# News:
|
|
# 2020-12-30: abandonne l'icon rss
|
|
# rssicon = scu.icontag("rssscodoc_img", title="Flux RSS", border="0")
|
|
H.append(sco_news.scolar_news_summary_html(context)) # , rssicon=rssicon))
|
|
|
|
# Avertissement de mise à jour:
|
|
H.append(sco_up_to_date.html_up_to_date_box(context))
|
|
|
|
# Liste de toutes les sessions:
|
|
sems = sco_formsemestre.do_formsemestre_list(context)
|
|
cursems = [] # semestres "courants"
|
|
othersems = [] # autres (verrouillés)
|
|
# icon image:
|
|
groupicon = scu.icontag("groupicon_img", title="Inscrits", border="0")
|
|
emptygroupicon = scu.icontag(
|
|
"emptygroupicon_img", title="Pas d'inscrits", border="0"
|
|
)
|
|
lockicon = scu.icontag("lock32_img", title="verrouillé", border="0")
|
|
# Sélection sur l'etat du semestre
|
|
for sem in sems:
|
|
if sem["etat"] == "1" and sem["modalite"] != "EXT":
|
|
sem["lockimg"] = ""
|
|
cursems.append(sem)
|
|
else:
|
|
sem["lockimg"] = lockicon
|
|
othersems.append(sem)
|
|
# Responsable de formation:
|
|
sco_formsemestre.sem_set_responsable_name(context, sem)
|
|
|
|
if showcodes == "1":
|
|
sem["tmpcode"] = "<td><tt>%s</tt></td>" % sem["formsemestre_id"]
|
|
else:
|
|
sem["tmpcode"] = ""
|
|
# Nombre d'inscrits:
|
|
args = {"formsemestre_id": sem["formsemestre_id"]}
|
|
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
|
|
context, args=args
|
|
)
|
|
nb = len(ins) # nb etudiants
|
|
sem["nb_inscrits"] = nb
|
|
if nb > 0:
|
|
sem["groupicon"] = groupicon
|
|
else:
|
|
sem["groupicon"] = emptygroupicon
|
|
|
|
# S'il n'y a pas d'utilisateurs dans la base, affiche message
|
|
if not sco_users.get_user_list(dept=g.scodoc_dept):
|
|
H.append(
|
|
"""<h2>Aucun utilisateur défini !</h2><p>Pour définir des utilisateurs
|
|
<a href="Users">passez par la page Utilisateurs</a>.
|
|
<br/>
|
|
Définissez au moins un utilisateur avec le rôle AdminXXX (le responsable du département XXX).
|
|
</p>
|
|
"""
|
|
)
|
|
|
|
# Liste des formsemestres "courants"
|
|
if cursems:
|
|
H.append('<h2 class="listesems">Sessions en cours</h2>')
|
|
H.append(_sem_table(context, cursems))
|
|
else:
|
|
# aucun semestre courant: affiche aide
|
|
H.append(
|
|
"""<h2 class="listesems">Aucune session en cours !</h2>
|
|
<p>Pour ajouter une session, aller dans <a href="Notes">Programmes</a>,
|
|
choisissez une formation, puis suivez le lien "<em>UE, modules, semestres</em>".
|
|
</p><p>
|
|
Là, en bas de page, suivez le lien
|
|
"<em>Mettre en place un nouveau semestre de formation...</em>"
|
|
</p>"""
|
|
)
|
|
|
|
if showsemtable:
|
|
H.append(
|
|
"""<hr/>
|
|
<h2>Semestres de %s</h2>
|
|
"""
|
|
% sco_preferences.get_preference("DeptName")
|
|
)
|
|
H.append(_sem_table_gt(context, sems).html())
|
|
H.append("</table>")
|
|
if not showsemtable:
|
|
H.append(
|
|
'<hr/><p><a href="%s?showsemtable=1">Voir tous les semestres</a></p>'
|
|
% REQUEST.URL0
|
|
)
|
|
|
|
H.append(
|
|
"""<p><form action="%s/view_formsemestre_by_etape">
|
|
Chercher étape courante: <input name="etape_apo" type="text" size="8" spellcheck="false"></input>
|
|
</form
|
|
</p>
|
|
"""
|
|
% scu.NotesURL()
|
|
)
|
|
#
|
|
if current_user.has_permission(Permission.ScoEtudInscrit):
|
|
H.append(
|
|
"""<hr>
|
|
<h3>Gestion des étudiants</h3>
|
|
<ul>
|
|
<li><a class="stdlink" href="etudident_create_form">créer <em>un</em> nouvel étudiant</a></li>
|
|
<li><a class="stdlink" href="form_students_import_excel">importer de nouveaux étudiants</a> (ne pas utiliser sauf cas particulier, utilisez plutôt le lien dans
|
|
le tableau de bord semestre si vous souhaitez inscrire les
|
|
étudiants importés à un semestre)</li>
|
|
</ul>
|
|
"""
|
|
)
|
|
#
|
|
if current_user.has_permission(Permission.ScoEditApo):
|
|
H.append(
|
|
"""<hr>
|
|
<h3>Exports Apogée</h3>
|
|
<ul>
|
|
<li><a class="stdlink" href="%s/semset_page">Années scolaires / exports Apogée</a></li>
|
|
</ul>
|
|
"""
|
|
% scu.NotesURL()
|
|
)
|
|
#
|
|
H.append(
|
|
"""<hr>
|
|
<h3>Assistance</h3>
|
|
<ul>
|
|
<li><a class="stdlink" href="sco_dump_and_send_db">Envoyer données</a></li>
|
|
</ul>
|
|
"""
|
|
)
|
|
#
|
|
return html_sco_header.sco_header() + "\n".join(H) + html_sco_header.sco_footer()
|
|
|
|
|
|
def _sem_table(context, sems):
|
|
"""Affiche liste des semestres, utilisée pour semestres en cours"""
|
|
tmpl = """<tr class="%(trclass)s">%(tmpcode)s
|
|
<td class="semicon">%(lockimg)s <a href="%(notes_url)s/formsemestre_status?formsemestre_id=%(formsemestre_id)s#groupes">%(groupicon)s</a></td>
|
|
<td class="datesem">%(mois_debut)s</td><td class="datesem"><a title="%(session_id)s">-</a> %(mois_fin)s</td>
|
|
<td><a class="stdlink" href="%(notes_url)s/formsemestre_status?formsemestre_id=%(formsemestre_id)s">%(titre_num)s</a>
|
|
<span class="respsem">(%(responsable_name)s)</span>
|
|
</td>
|
|
</tr>
|
|
"""
|
|
|
|
# Liste des semestres, groupés par modalités
|
|
sems_by_mod, modalites = sco_modalites.group_sems_by_modalite(context, sems)
|
|
|
|
H = ['<table class="listesems">']
|
|
for modalite in modalites:
|
|
if len(modalites) > 1:
|
|
H.append('<tr><th colspan="4">%s</th></tr>' % modalite["titre"])
|
|
|
|
if sems_by_mod[modalite["modalite"]]:
|
|
cur_idx = sems_by_mod[modalite["modalite"]][0]["semestre_id"]
|
|
for sem in sems_by_mod[modalite["modalite"]]:
|
|
if cur_idx != sem["semestre_id"]:
|
|
sem["trclass"] = "firstsem" # separe les groupes de semestres
|
|
cur_idx = sem["semestre_id"]
|
|
else:
|
|
sem["trclass"] = ""
|
|
sem["notes_url"] = scu.NotesURL()
|
|
H.append(tmpl % sem)
|
|
H.append("</table>")
|
|
return "\n".join(H)
|
|
|
|
|
|
def _sem_table_gt(context, sems, showcodes=False):
|
|
"""Nouvelle version de la table des semestres"""
|
|
_style_sems(context, sems)
|
|
columns_ids = (
|
|
"lockimg",
|
|
"semestre_id_n",
|
|
"modalite",
|
|
#'mois_debut',
|
|
"dash_mois_fin",
|
|
"titre_resp",
|
|
"nb_inscrits",
|
|
"etapes_apo_str",
|
|
)
|
|
if showcodes:
|
|
columns_ids = ("formsemestre_id",) + columns_ids
|
|
|
|
tab = GenTable(
|
|
titles={
|
|
"formsemestre_id": "id",
|
|
"semestre_id_n": "S#",
|
|
"modalite": "",
|
|
"mois_debut": "Début",
|
|
"dash_mois_fin": "Année",
|
|
"titre_resp": "Semestre",
|
|
"nb_inscrits": "N", # groupicon,
|
|
},
|
|
columns_ids=columns_ids,
|
|
rows=sems,
|
|
html_class="table_leftalign semlist",
|
|
html_sortable=True,
|
|
# base_url = '%s?formsemestre_id=%s' % (REQUEST.URL0, formsemestre_id),
|
|
# caption='Maquettes enregistrées',
|
|
preferences=sco_preferences.SemPreferences(),
|
|
)
|
|
|
|
return tab
|
|
|
|
|
|
def _style_sems(context, sems):
|
|
"""ajoute quelques attributs de présentation pour la table"""
|
|
for sem in sems:
|
|
sem["notes_url"] = scu.NotesURL()
|
|
sem["_groupicon_target"] = (
|
|
"%(notes_url)s/formsemestre_status?formsemestre_id=%(formsemestre_id)s"
|
|
% sem
|
|
)
|
|
sem["_formsemestre_id_class"] = "blacktt"
|
|
sem["dash_mois_fin"] = '<a title="%(session_id)s"></a> %(anneescolaire)s' % sem
|
|
sem["_dash_mois_fin_class"] = "datesem"
|
|
sem["titre_resp"] = (
|
|
"""<a class="stdlink" href="%(notes_url)s/formsemestre_status?formsemestre_id=%(formsemestre_id)s">%(titre_num)s</a>
|
|
<span class="respsem">(%(responsable_name)s)</span>"""
|
|
% sem
|
|
)
|
|
sem["_css_row_class"] = "css_S%d css_M%s" % (
|
|
sem["semestre_id"],
|
|
sem["modalite"],
|
|
)
|
|
sem["_semestre_id_class"] = "semestre_id"
|
|
sem["_modalite_class"] = "modalite"
|
|
if sem["semestre_id"] == -1:
|
|
sem["semestre_id_n"] = ""
|
|
else:
|
|
sem["semestre_id_n"] = sem["semestre_id"]
|