From 44dde2e678c650812be445605d21168ceb81520a Mon Sep 17 00:00:00 2001 From: viennet Date: Sat, 2 Jan 2021 00:18:47 +0100 Subject: [PATCH 1/4] Avoid trying to delete depts when no config file --- scotests/scointeractive.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scotests/scointeractive.sh b/scotests/scointeractive.sh index 38bf8dfac..2cecaf90c 100755 --- a/scotests/scointeractive.sh +++ b/scotests/scointeractive.sh @@ -17,6 +17,7 @@ usage() { set -euo pipefail cd /opt/scodoc/Products/ScoDoc || exit 2 +source config/config.sh source config/utils.sh if [ $# -lt 1 ] @@ -38,7 +39,11 @@ shift if [ "$recreate_dept" = 1 ] then - (cd config || terminate "no config directory"; ./delete_dept.sh -n "$DEPT") || terminate "error deleting dept $DEPT" + cfg_pathname="${SCODOC_VAR_DIR}/config/depts/$DEPT".cfg + if [ -e "$cfg_pathname" ] + then + (cd config || terminate "no config directory"; ./delete_dept.sh -n "$DEPT") || terminate "error deleting dept $DEPT" + fi (cd config || terminate "no config directory"; ./create_dept.sh -n "$DEPT") || terminate "error creating dept $DEPT" # systemctl start scodoc fi From e9e9e1c6e11c98eedb23a87df75346785d9eb716 Mon Sep 17 00:00:00 2001 From: viennet Date: Sat, 2 Jan 2021 22:07:38 +0100 Subject: [PATCH 2/4] Ajout lien saisie absence sur tableau bord module, et lien affichage notes tous --- ZAbsences.py | 2 +- ZScolar.py | 5 +---- sco_formsemestre.py | 12 ++++++++++-- sco_groups_view.py | 17 ++++++++++++++--- sco_moduleimpl_status.py | 27 ++++++++++++++++++++------- static/css/scodoc.css | 6 ++++-- 6 files changed, 50 insertions(+), 19 deletions(-) diff --git a/ZAbsences.py b/ZAbsences.py index 94b3b2c85..6ebf844e0 100644 --- a/ZAbsences.py +++ b/ZAbsences.py @@ -936,7 +936,7 @@ class ZAbsences( moduleimpl_id = None groups_infos = sco_groups_view.DisplayedGroupsInfos( - self, group_ids, REQUEST=REQUEST + self, group_ids, moduleimpl_id=moduleimpl_id, REQUEST=REQUEST ) if not groups_infos.members: return ( diff --git a/ZScolar.py b/ZScolar.py index 133a827c9..7a6355700 100644 --- a/ZScolar.py +++ b/ZScolar.py @@ -764,14 +764,11 @@ UE11 Découverte métiers (code UCOD46, 16 ECTS, Apo ' % sem) FA.append(groups_infos.get_form_elem()) - + if moduleimpl_id: + FA.append( + '' % moduleimpl_id + ) FA.append('') FA.append( diff --git a/sco_moduleimpl_status.py b/sco_moduleimpl_status.py index e60c642fb..99f1f8627 100644 --- a/sco_moduleimpl_status.py +++ b/sco_moduleimpl_status.py @@ -43,7 +43,7 @@ import sco_formsemestre import sco_formsemestre_status from sco_formsemestre_status import makeMenu import sco_compute_moy - +import ZAbsences # ported from old DTML code in oct 2009 @@ -224,7 +224,6 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No ) H.append("") else: - t0, t1 = "règle de calcul standard", "" H.append( 'règle de calcul standard' ) @@ -235,10 +234,21 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No ) H.append("") H.append( - 'Absences ' + 'Absences dans ce module' % moduleimpl_id ) - H.append("") + # Adapté à partir d'une suggestion de DS (Le Havre) + # Liens saisies absences seulement si permission et date courante dans le semestre + if authuser.has_permission( + ScoAbsChange, context + ) and sco_formsemestre.sem_est_courant(context, sem): + datelundi = ZAbsences.ddmmyyyy(time.strftime("%d/%m/%Y")).prev_monday() + H.append( + 'Saisie Absences hebdo.' + % (formsemestre_id, moduleimpl_id, datelundi) + ) + + H.append("") # if has_expression and nt.expr_diagnostics: H.append( @@ -478,7 +488,11 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No % etat ) if etat["moy"]: - H.append("%s / %g" % (etat["moy"], eval["note_max"])) + H.append("%s / %g" % (etat["moy"], eval["note_max"])) + H.append( + """  (afficher)""" + % (eval["evaluation_id"],) + ) else: H.append( """saisir notes""" @@ -488,7 +502,6 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No # if etat["nb_notes"] == 0: H.append(""" """ % tr_class) - # XXX H.append("""""") else: # il y a deja des notes saisies gr_moyennes = etat["gr_moyennes"] @@ -505,7 +518,7 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No if gr_moyenne["gr_nb_notes"] > 0: H.append("%(gr_moy)s" % gr_moyenne) H.append( - """  (%s notes""" + """  (%s notes""" % ( eval["evaluation_id"], gr_moyenne["group_id"], diff --git a/static/css/scodoc.css b/static/css/scodoc.css index 875361b1c..7eebc65f8 100644 --- a/static/css/scodoc.css +++ b/static/css/scodoc.css @@ -1223,7 +1223,7 @@ ul.ue_inscr_list li.etud { } #grouplists table { - //border: 1px solid black; + /*border: 1px solid black;*/ border-spacing: 1px; } @@ -1236,7 +1236,9 @@ div.moduleimpl_tableaubord { padding: 7px; border: 2px solid gray; } - +span.moduleimpl_abs_link { + padding-right: 2em; +} .moduleimpl_evaluations_top_links { font-size: 80%; margin-bottom: 3px; From bb70ef8e388d98d6ae115b7d38d59f1dfb0aa5d8 Mon Sep 17 00:00:00 2001 From: viennet Date: Mon, 4 Jan 2021 11:31:18 +0100 Subject: [PATCH 3/4] Fix: trombino Tours --- sco_bulletins_generator.py | 2 +- sco_bulletins_pdf.py | 2 +- sco_moduleimpl_status.py | 1 - sco_pdf.py | 2 +- sco_trombino.py | 4 ++-- sco_trombino_tours.py | 8 ++++++-- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/sco_bulletins_generator.py b/sco_bulletins_generator.py index 4e09360b3..717cd9be1 100644 --- a/sco_bulletins_generator.py +++ b/sco_bulletins_generator.py @@ -198,7 +198,7 @@ class BulletinGenerator: document.addPageTemplates( ScolarsPageTemplate( document, - self.context, + context=self.context, author="%s %s (E. Viennet) [%s]" % (SCONAME, SCOVERSION, self.description), title="Bulletin %s de %s" diff --git a/sco_bulletins_pdf.py b/sco_bulletins_pdf.py index 56617a573..e01dca0db 100644 --- a/sco_bulletins_pdf.py +++ b/sco_bulletins_pdf.py @@ -86,7 +86,7 @@ def pdfassemblebulletins( document.addPageTemplates( ScolarsPageTemplate( document, - context, + context=context, author="%s %s (E. Viennet)" % (SCONAME, SCOVERSION), title="Bulletin %s" % bul_title, subject="Bulletin de note", diff --git a/sco_moduleimpl_status.py b/sco_moduleimpl_status.py index 99f1f8627..7a4bf1e78 100644 --- a/sco_moduleimpl_status.py +++ b/sco_moduleimpl_status.py @@ -50,7 +50,6 @@ import ZAbsences # menu evaluation dans moduleimpl def moduleimpl_evaluation_menu(context, evaluation_id, nbnotes=0, REQUEST=None): "Menu avec actions sur une evaluation" - authuser = REQUEST.AUTHENTICATED_USER E = context.do_evaluation_list({"evaluation_id": evaluation_id})[0] modimpl = context.do_moduleimpl_list(moduleimpl_id=E["moduleimpl_id"])[0] diff --git a/sco_pdf.py b/sco_pdf.py index 80f72f956..0d14e7930 100644 --- a/sco_pdf.py +++ b/sco_pdf.py @@ -300,7 +300,7 @@ def pdf_basic_page( document.addPageTemplates( ScolarsPageTemplate( document, - context, + context=context, title=title, author="%s %s (E. Viennet)" % (SCONAME, SCOVERSION), footer_template="Edité par %(scodoc_name)s le %(day)s/%(month)s/%(year)s à %(hour)sh%(minute)s", diff --git a/sco_trombino.py b/sco_trombino.py index f1a338567..04ffb314b 100644 --- a/sco_trombino.py +++ b/sco_trombino.py @@ -366,7 +366,7 @@ def _trombino_pdf(context, groups_infos, REQUEST): document.addPageTemplates( ScolarsPageTemplate( document, - context, + context=context, preferences=context.get_preferences(sem["formsemestre_id"]), ) ) @@ -515,7 +515,7 @@ def _listeappel_photos_pdf(context, groups_infos, REQUEST): document.addPageTemplates( ScolarsPageTemplate( document, - context, + context=context, preferences=context.get_preferences(sem["formsemestre_id"]), ) ) diff --git a/sco_trombino_tours.py b/sco_trombino_tours.py index 6c0e9556b..eece74eb0 100644 --- a/sco_trombino_tours.py +++ b/sco_trombino_tours.py @@ -276,7 +276,9 @@ def pdf_trombino_tours( filename = "trombino-%s-%s.pdf" % (DeptName, groups_infos.groups_filename) document = BaseDocTemplate(report) document.addPageTemplates( - ScolarsPageTemplate(document, preferences=context.get_preferences()) + ScolarsPageTemplate( + document, context=context, preferences=context.get_preferences() + ) ) document.build(objects) data = report.getvalue() @@ -468,7 +470,9 @@ def pdf_feuille_releve_absences( else: document = BaseDocTemplate(report, pagesize=taille) document.addPageTemplates( - ScolarsPageTemplate(document, preferences=context.get_preferences()) + ScolarsPageTemplate( + document, context=context, preferences=context.get_preferences() + ) ) document.build(objects) data = report.getvalue() From 82f0612883b74b5184bfe49d6d16a939c304ba44 Mon Sep 17 00:00:00 2001 From: viennet Date: Mon, 4 Jan 2021 13:53:19 +0100 Subject: [PATCH 4/4] pylint --- gen_tables.py | 2 +- sco_pdf.py | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/gen_tables.py b/gen_tables.py index c1a84d18c..fbd8309c7 100644 --- a/gen_tables.py +++ b/gen_tables.py @@ -693,7 +693,7 @@ class SeqGenTable: def excel(self): """Export des genTables dans un unique fichier excel avec plusieurs feuilles tagguées""" - book = sco_excel.Workbook() # Le fichier xls en devenir + book = sco_excel.Workbook() # pylint: disable=no-member for (_, gt) in self.genTables.items(): gt.excel(wb=book) # Ecrit dans un fichier excel return book.savetostr() diff --git a/sco_pdf.py b/sco_pdf.py index 0d14e7930..23e5c7ff0 100644 --- a/sco_pdf.py +++ b/sco_pdf.py @@ -31,7 +31,10 @@ Tout accès à ReportLab doit donc être précédé d'un PDFLOCK.acquire() et terminé par un PDFLOCK.release() """ -import time, cStringIO +import time +import cStringIO +import re +import os from types import StringType import unicodedata import traceback @@ -49,9 +52,12 @@ from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY from reportlab.lib import styles from reportlab.lib.pagesizes import letter, A4, landscape -from sco_utils import * +import sco_utils as scu +from sco_utils import CONFIG, SCO_ENCODING, SCODOC_LOGOS_DIR, LOGOS_IMAGES_ALLOWED_TYPES from notes_log import log +from sco_exceptions import ScoGenError from SuppressAccents import suppression_diacritics +import VERSION from VERSION import SCOVERSION, SCONAME PAGE_HEIGHT = defaultPageSize[1] @@ -107,7 +113,7 @@ def makeParas(txt, style, suppress_empty=False): if suppress_empty: r = [] for para in paras: - m = re.match("\s*<\s*para.*>\s*(.*)\s*<\s*/\s*para\s*>\s*", para) + m = re.match(r"\s*<\s*para.*>\s*(.*)\s*<\s*/\s*para\s*>\s*", para) if not m: r.append(para) # not a paragraph, keep it else: @@ -229,7 +235,10 @@ class ScolarsPageTemplate(PageTemplate): # ---- Logo: a small image, positionned at top left of the page if self.logo is not None: # draws the logo if it exists - ((width, height), image) = self.logo + ( # pylint: disable=unpacking-non-sequence + (width, height), + image, + ) = self.logo canvas.drawImage(image, inch, doc.pagesize[1] - inch, width, height) # ---- Filigranne (texte en diagonal en haut a gauche de chaque page)