Compare commits

...

1 Commits

Author SHA1 Message Date
ddb631144a generation des classes ccs dans la table 2021-01-02 09:47:04 +01:00
2 changed files with 96 additions and 7 deletions

View File

@ -5,7 +5,7 @@
#
# Gestion scolarite IUT
#
# Copyright (c) 1999 - 2021 Emmanuel Viennet. All rights reserved.
# Copyright (c) 1999 - 2020 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
@ -28,6 +28,7 @@
"""Page accueil département (liste des semestres, etc)
"""
from notesdb import *
from sco_dept_filtrage import complete_sem, get_filtrage_html
from sco_utils import *
from notes_log import log
import sco_modalites
@ -43,9 +44,8 @@ def index_html(context, REQUEST=None, showcodes=0, showsemtable=0):
H = []
# News:
# 2020-12-30: abandonne l'icon rss
# rssicon = icontag("rssscodoc_img", title="Flux RSS", border="0")
H.append(sco_news.scolar_news_summary_html(context)) # , rssicon=rssicon))
rssicon = 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))
@ -118,6 +118,7 @@ def index_html(context, REQUEST=None, showcodes=0, showsemtable=0):
% context.get_preference("DeptName")
)
H.append(_sem_table_gt(context, sems).html())
H.append(get_filtrage_html())
H.append("</table>")
if not showsemtable:
H.append(
@ -170,7 +171,8 @@ Chercher étape courante: <input name="etape_apo" type="text" size="8"></input>
def _sem_table(context, sems):
"""Affiche liste des semestres, utilisée pour semestres en cours"""
"""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/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>
@ -202,7 +204,8 @@ def _sem_table(context, sems):
def _sem_table_gt(context, sems, showcodes=False):
"""Nouvelle version de la table des semestres"""
"""Nouvelle version de la table des semestres
"""
_style_sems(context, sems)
columns_ids = (
"lockimg",
@ -217,6 +220,7 @@ def _sem_table_gt(context, sems, showcodes=False):
if showcodes:
columns_ids = ("formsemestre_id",) + columns_ids
complete_sem(sems)
tab = GenTable(
titles={
"formsemestre_id": "id",
@ -240,7 +244,8 @@ def _sem_table_gt(context, sems, showcodes=False):
def _style_sems(context, sems):
"""ajoute quelques attributs de présentation pour la table"""
"""ajoute quelques attributs de présentation pour la table
"""
for sem in sems:
sem["_groupicon_target"] = (
"Notes/formsemestre_status?formsemestre_id=%(formsemestre_id)s" % sem

84
sco_dept_filtrage.py Normal file
View File

@ -0,0 +1,84 @@
# -*- 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
#
##############################################################################
import re
from notes_log import log
class SemProperty:
def __init__(self, prefix):
self.index = {} # valeur : clé
self.next_key = 0
self.prefix = prefix
def get_key(self, value):
if value in self.index:
return self.index[value]
else:
self.index[value] = self.prefix + "{:02d}".format(self.next_key)
self.next_key += 1
def js(self):
returned = "\n"
for val in sorted(self.index):
returned += "%s:%s\n" % (self.index[val], val)
return returned
locked = SemProperty("A")
semestre_id = SemProperty("B")
modalite = SemProperty("B")
annee = SemProperty("C")
titre = SemProperty("D")
etapes = SemProperty("E")
def get_filtrage_html():
returned = "<!-- "
returned += locked.js()
returned += semestre_id.js()
returned += modalite.js()
returned += annee.js()
returned += titre.js()
returned += etapes.js()
returned += " -->"
return returned
def complete_sem(sems):
for row in sems:
classes = []
classes.append(locked.get_key(row["lockimg"]))
classes.append(semestre_id.get_key(row["semestre_id_n"]))
classes.append(modalite.get_key(row["modalite"]))
classes.append(annee.get_key(row["anneescolaire"]))
pattern = "<a.*>(.*)</a>"
title = re.search(pattern, row["titre_resp"]).group(1)
classes.append(titre.get_key(title))
for etapevdi in row["etapes"]:
classes.append(etapes.get_key(etapevdi.etape))
row["_css_row_class"] = " ".join([x for x in classes if x is not None])