[Scodoc-devel] [SVN] Scolar : [1559] Logos par departements (contrib.

eviennet at lipn.univ-paris13.fr eviennet at lipn.univ-paris13.fr
Jeu 8 Sep 11:09:47 CEST 2016


Une pièce jointe HTML a été nettoyée...
URL: <https://www-rt.iutv.univ-paris13.fr/pipermail/scodoc-devel/attachments/20160908/ceb7731a/attachment-0001.html>
-------------- section suivante --------------
Modified: branches/ScoDoc7/sco_bulletins_pdf.py
===================================================================
--- branches/ScoDoc7/sco_bulletins_pdf.py	2016-09-06 19:51:39 UTC (rev 1558)
+++ branches/ScoDoc7/sco_bulletins_pdf.py	2016-09-08 09:09:47 UTC (rev 1559)
@@ -57,6 +57,7 @@
 import sco_bulletins
 
 from sco_pdf import *
+import os
 
 
 def pdfassemblebulletins( formsemestre_id,
@@ -115,7 +116,10 @@
         return text
     # --- PDF format:
     # handle logos:
-    image_dir = context.file_path + '/logos'
+    if os.path.exists(context.file_path + '/logos_' + context.DeptId() + '/'):
+        image_dir = context.file_path + '/logos_' + context.DeptId() + '/'
+    else:
+        image_dir = context.file_path + '/logos'
     text = re.sub( r'<(\s*)logo(.*?)src\s*=\s*(.*?)>', r'<\1logo\2\3>', text) # remove forbidden src attribute
     text = re.sub(r'<\s*logo(.*?)name\s*=\s*"(\w*?)"(.*?)/?>', 
                   r'<img\1src="%s/logo_\2.jpg"\3/>' % image_dir, text)

Modified: branches/ScoDoc7/sco_pvpdf.py
===================================================================
--- branches/ScoDoc7/sco_pvpdf.py	2016-09-06 19:51:39 UTC (rev 1558)
+++ branches/ScoDoc7/sco_pvpdf.py	2016-09-08 09:09:47 UTC (rev 1559)
@@ -36,6 +36,7 @@
 from sco_pdf import PDFLOCK
 import sco_preferences
 import sco_bulletins_pdf
+import os
 
 LOGO_FOOTER_ASPECT = CONFIG.LOGO_FOOTER_ASPECT # XXX A AUTOMATISER
 LOGO_FOOTER_HEIGHT = CONFIG.LOGO_FOOTER_HEIGHT * mm
@@ -250,6 +251,10 @@
     # ----- Build PDF
     report = cStringIO.StringIO() # in-memory document, no disk file
     document = BaseDocTemplate(report)
+    if os.path.exists(context.file_path + '/logos_' + context.DeptId() + '/'):
+        image_dir = context.file_path + '/logos_' + context.DeptId() + '/'
+    else:
+        image_dir = context.file_path + '/logos/'
     document.addPageTemplates( CourrierIndividuelTemplate(
         document,
         author='%s %s (E. Viennet)' % (SCONAME, SCOVERSION),
@@ -257,7 +262,7 @@
         subject='Décision jury',
         margins=margins,
         pagesbookmarks=bookmarks,
-        image_dir=context.file_path + '/logos/',
+        image_dir=image_dir,
         preferences=prefs))
     
     document.build(objects)
@@ -438,12 +443,16 @@
     report = cStringIO.StringIO() # in-memory document, no disk file
     document = BaseDocTemplate(report)
     document.pagesize = landscape(A4)
+    if os.path.exists(context.file_path + '/logos_' + context.DeptId() + '/'):
+        image_dir = context.file_path + '/logos_' + context.DeptId() + '/'
+    else:
+        image_dir = context.file_path + '/logos/'
     document.addPageTemplates( PVTemplate(
         document,
         author='%s %s (E. Viennet)' % (SCONAME, SCOVERSION),
         title=SU('PV du jury de %s' % sem['titre_num']),
         subject='PV jury',
-        image_dir = context.file_path + '/logos/',
+        image_dir = image_dir,
         preferences=context.get_preferences(formsemestre_id)))
 
     document.build(objects)


Plus d'informations sur la liste de diffusion Scodoc-devel