1
0
forked from ScoDoc/ScoDoc

élimination des qq REQUESTS et correction publication XML/XLS/JSON/...

This commit is contained in:
Emmanuel Viennet 2021-09-24 16:32:49 +02:00
parent 0a50edc9f0
commit 75f43bbdde
3 changed files with 32 additions and 37 deletions

View File

@ -56,7 +56,6 @@ from app.scodoc import sco_etud
from app.scodoc.gen_tables import GenTable from app.scodoc.gen_tables import GenTable
from app.scodoc.sco_exceptions import ScoValueError from app.scodoc.sco_exceptions import ScoValueError
from app.scodoc.sco_permissions import Permission from app.scodoc.sco_permissions import Permission
from six.moves import range
JAVASCRIPTS = html_sco_header.BOOTSTRAP_MULTISELECT_JS + [ JAVASCRIPTS = html_sco_header.BOOTSTRAP_MULTISELECT_JS + [
"js/etud_info.js", "js/etud_info.js",
@ -65,11 +64,10 @@ JAVASCRIPTS = html_sco_header.BOOTSTRAP_MULTISELECT_JS + [
CSSSTYLES = html_sco_header.BOOTSTRAP_MULTISELECT_CSS CSSSTYLES = html_sco_header.BOOTSTRAP_MULTISELECT_CSS
# view:
def groups_view( def groups_view(
group_ids=[], group_ids=(),
format="html", format="html",
REQUEST=None,
# Options pour listes: # Options pour listes:
with_codes=0, with_codes=0,
etat=None, etat=None,
@ -94,7 +92,6 @@ def groups_view(
return groups_table( return groups_table(
groups_infos=groups_infos, groups_infos=groups_infos,
format=format, format=format,
REQUEST=REQUEST,
with_codes=with_codes, with_codes=with_codes,
etat=etat, etat=etat,
with_paiement=with_paiement, with_paiement=with_paiement,
@ -134,7 +131,6 @@ def groups_view(
groups_table( groups_table(
groups_infos=groups_infos, groups_infos=groups_infos,
format=format, format=format,
REQUEST=REQUEST,
with_codes=with_codes, with_codes=with_codes,
etat=etat, etat=etat,
with_paiement=with_paiement, with_paiement=with_paiement,
@ -143,11 +139,11 @@ def groups_view(
), ),
"</div>", "</div>",
"""<div class="tab-pane" id="tab-photos">""", """<div class="tab-pane" id="tab-photos">""",
tab_photos_html(groups_infos, etat=etat, REQUEST=REQUEST), tab_photos_html(groups_infos, etat=etat),
#'<p>hello</p>', #'<p>hello</p>',
"</div>", "</div>",
'<div class="tab-pane" id="tab-abs">', '<div class="tab-pane" id="tab-abs">',
tab_absences_html(groups_infos, etat=etat, REQUEST=REQUEST), tab_absences_html(groups_infos, etat=etat),
"</div>", "</div>",
) )
) )
@ -296,7 +292,7 @@ class DisplayedGroupsInfos(object):
def __init__( def __init__(
self, self,
group_ids=[], # groupes specifies dans l'URL, ou un seul int group_ids=(), # groupes specifies dans l'URL, ou un seul int
formsemestre_id=None, formsemestre_id=None,
etat=None, etat=None,
select_all_when_unspecified=False, select_all_when_unspecified=False,
@ -421,7 +417,6 @@ class DisplayedGroupsInfos(object):
# Ancien ZScolar.group_list renommé ici en group_table # Ancien ZScolar.group_list renommé ici en group_table
def groups_table( def groups_table(
REQUEST=None,
groups_infos=None, # instance of DisplayedGroupsInfos groups_infos=None, # instance of DisplayedGroupsInfos
with_codes=0, with_codes=0,
etat=None, etat=None,
@ -529,7 +524,8 @@ def groups_table(
# et groupes: # et groupes:
for partition_id in etud["partitions"]: for partition_id in etud["partitions"]:
etud[partition_id] = etud["partitions"][partition_id]["group_name"] etud[partition_id] = etud["partitions"][partition_id]["group_name"]
# Ajoute colonne pour moodle: semestre_groupe, de la forme RT-DUT-FI-S3-2021-PARTITION-GROUPE # Ajoute colonne pour moodle: semestre_groupe, de la forme
# RT-DUT-FI-S3-2021-PARTITION-GROUPE
moodle_groupename = [] moodle_groupename = []
if groups_infos.selected_partitions: if groups_infos.selected_partitions:
# il y a des groupes selectionnes, utilise leurs partitions # il y a des groupes selectionnes, utilise leurs partitions
@ -638,22 +634,21 @@ def groups_table(
[ [
"""<span style="margin-left: 2em;"><select name="group_list_options" id="group_list_options" class="multiselect" multiple="multiple">""", """<span style="margin-left: 2em;"><select name="group_list_options" id="group_list_options" class="multiselect" multiple="multiple">""",
"\n".join(Of), "\n".join(Of),
""" """</select></span>
</select></span> <script type="text/javascript">
<script type="text/javascript"> $(document).ready(function() {
$(document).ready(function() { $('#group_list_options').multiselect(
$('#group_list_options').multiselect( {
{ includeSelectAllOption: false,
includeSelectAllOption: false, nonSelectedText:'Options...',
nonSelectedText:'Options...', onChange: function(element, checked){
onChange: function(element, checked){ change_list_options();
change_list_options(); }
} }
} );
); });
}); </script>
</script> """,
""",
] ]
) )
H.append("</h3></form>") H.append("</h3></form>")
@ -797,7 +792,7 @@ def groups_table(
raise ValueError("unsupported format") raise ValueError("unsupported format")
def tab_absences_html(groups_infos, etat=None, REQUEST=None): def tab_absences_html(groups_infos, etat=None):
"""contenu du tab "absences et feuilles diverses" """ """contenu du tab "absences et feuilles diverses" """
authuser = current_user authuser = current_user
H = ['<div class="tab-content">'] H = ['<div class="tab-content">']
@ -808,10 +803,10 @@ def tab_absences_html(groups_infos, etat=None, REQUEST=None):
"<h3>Absences</h3>", "<h3>Absences</h3>",
'<ul class="ul_abs">', '<ul class="ul_abs">',
"<li>", "<li>",
form_choix_saisie_semaine(groups_infos, REQUEST=REQUEST), # Ajout Le Havre form_choix_saisie_semaine(groups_infos), # Ajout Le Havre
"</li>", "</li>",
"<li>", "<li>",
form_choix_jour_saisie_hebdo(groups_infos, REQUEST=REQUEST), form_choix_jour_saisie_hebdo(groups_infos),
"</li>", "</li>",
"""<li><a class="stdlink" href="Absences/EtatAbsencesGr?%s&debut=%s&fin=%s">État des absences du groupe</a></li>""" """<li><a class="stdlink" href="Absences/EtatAbsencesGr?%s&debut=%s&fin=%s">État des absences du groupe</a></li>"""
% ( % (
@ -856,17 +851,17 @@ def tab_absences_html(groups_infos, etat=None, REQUEST=None):
return "".join(H) return "".join(H)
def tab_photos_html(groups_infos, etat=None, REQUEST=None): def tab_photos_html(groups_infos, etat=None):
"""contenu du tab "photos" """ """contenu du tab "photos" """
from app.scodoc import sco_trombino from app.scodoc import sco_trombino
if not groups_infos.members: if not groups_infos.members:
return '<div class="tab-content"><h3>Aucun étudiant !</h3></div>' return '<div class="tab-content"><h3>Aucun étudiant !</h3></div>'
return sco_trombino.trombino_html(groups_infos, REQUEST=REQUEST) return sco_trombino.trombino_html(groups_infos)
def form_choix_jour_saisie_hebdo(groups_infos, moduleimpl_id=None, REQUEST=None): def form_choix_jour_saisie_hebdo(groups_infos, moduleimpl_id=None):
"""Formulaire choix jour semaine pour saisie.""" """Formulaire choix jour semaine pour saisie."""
authuser = current_user authuser = current_user
if not authuser.has_permission(Permission.ScoAbsChange): if not authuser.has_permission(Permission.ScoAbsChange):
@ -908,7 +903,7 @@ def form_choix_jour_saisie_hebdo(groups_infos, moduleimpl_id=None, REQUEST=None)
# Ajout Le Havre # Ajout Le Havre
# Formulaire saisie absences semaine # Formulaire saisie absences semaine
def form_choix_saisie_semaine(groups_infos, REQUEST=None): def form_choix_saisie_semaine(groups_infos):
authuser = current_user authuser = current_user
if not authuser.has_permission(Permission.ScoAbsChange): if not authuser.has_permission(Permission.ScoAbsChange):
return "" return ""

View File

@ -104,7 +104,7 @@ def _trombino_html_header():
return html_sco_header.sco_header(javascripts=["js/trombino.js"]) return html_sco_header.sco_header(javascripts=["js/trombino.js"])
def trombino_html(groups_infos, REQUEST=None): def trombino_html(groups_infos):
"HTML snippet for trombino (with title and menu)" "HTML snippet for trombino (with title and menu)"
menuTrombi = [ menuTrombi = [
{ {

View File

@ -585,9 +585,9 @@ def send_file(data, filename="", suffix="", mime=None, attached=None):
""" """
if attached is None: if attached is None:
if mime == XML_MIMETYPE or mime == JSON_MIMETYPE: if mime == XML_MIMETYPE or mime == JSON_MIMETYPE:
attached = True
else:
attached = False attached = False
else:
attached = True
# if attached and not filename: # if attached and not filename:
# raise ValueError("send_file: missing attachement filename") # raise ValueError("send_file: missing attachement filename")
if filename: if filename: