Update colors in PDF module
This commit is contained in:
parent
29815bb6eb
commit
7e748bd41f
6 changed files with 82 additions and 96 deletions
77
cms/pdf.py
77
cms/pdf.py
|
|
@ -1,14 +1,17 @@
|
||||||
|
|
||||||
from reportlab.platypus import (SimpleDocTemplate, Spacer, Frame, Paragraph, Preformatted,
|
from reportlab.platypus import (
|
||||||
PageTemplate, NextPageTemplate, FrameBreak, Table, TableStyle)
|
SimpleDocTemplate, Spacer, Frame, Paragraph, Preformatted, PageTemplate, NextPageTemplate,
|
||||||
|
FrameBreak, Table, TableStyle
|
||||||
|
)
|
||||||
from reportlab.lib.pagesizes import A4, landscape
|
from reportlab.lib.pagesizes import A4, landscape
|
||||||
from reportlab.lib.units import cm
|
from reportlab.lib.units import cm
|
||||||
from reportlab.lib.enums import TA_LEFT, TA_CENTER
|
from reportlab.lib.enums import TA_LEFT
|
||||||
from reportlab.lib import colors
|
from reportlab.lib import colors
|
||||||
from reportlab.lib.colors import HexColor
|
|
||||||
from reportlab.lib.styles import ParagraphStyle as ps
|
from reportlab.lib.styles import ParagraphStyle as ps
|
||||||
from reportlab.pdfgen import canvas
|
from reportlab.pdfgen import canvas
|
||||||
|
|
||||||
from django.contrib.staticfiles.finders import find
|
from django.contrib.staticfiles.finders import find
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
style_normal = ps(name='CORPS', fontName='Helvetica', fontSize=9, alignment=TA_LEFT)
|
style_normal = ps(name='CORPS', fontName='Helvetica', fontSize=9, alignment=TA_LEFT)
|
||||||
style_bold = ps(name='CORPS', fontName='Helvetica-Bold', fontSize=10, alignment=TA_LEFT)
|
style_bold = ps(name='CORPS', fontName='Helvetica-Bold', fontSize=10, alignment=TA_LEFT)
|
||||||
|
|
@ -17,11 +20,11 @@ LOGO_EPC = find('img/logo_EPC.png')
|
||||||
LOGO_ESNE = find('img/logo_ESNE.png')
|
LOGO_ESNE = find('img/logo_ESNE.png')
|
||||||
FILIERE = 'Formation EDS'
|
FILIERE = 'Formation EDS'
|
||||||
|
|
||||||
|
|
||||||
class NumberedCanvas(canvas.Canvas):
|
class NumberedCanvas(canvas.Canvas):
|
||||||
"""
|
"""
|
||||||
Page number and pages counter
|
Page number and pages counter
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
canvas.Canvas.__init__(self, *args, **kwargs)
|
canvas.Canvas.__init__(self, *args, **kwargs)
|
||||||
self._saved_page_states = []
|
self._saved_page_states = []
|
||||||
|
|
@ -70,7 +73,7 @@ class EpcBaseDocTemplate(SimpleDocTemplate):
|
||||||
canvas.line(doc.leftMargin, doc.height + 0.2 * cm, doc.width + doc.leftMargin, doc.height + 0.2 * cm)
|
canvas.line(doc.leftMargin, doc.height + 0.2 * cm, doc.width + doc.leftMargin, doc.height + 0.2 * cm)
|
||||||
canvas.restoreState()
|
canvas.restoreState()
|
||||||
|
|
||||||
def setNormalTemplatePage(self):
|
def normal_template_page(self):
|
||||||
first_page_table_frame = Frame(self.leftMargin, self.bottomMargin, self.width + 1 * cm, self.height - 4 * cm,
|
first_page_table_frame = Frame(self.leftMargin, self.bottomMargin, self.width + 1 * cm, self.height - 4 * cm,
|
||||||
id='first_table', showBoundary=0, leftPadding=0 * cm)
|
id='first_table', showBoundary=0, leftPadding=0 * cm)
|
||||||
later_pages_table_frame = Frame(self.leftMargin, self.bottomMargin, self.width + 1 * cm, self.height - 2 * cm,
|
later_pages_table_frame = Frame(self.leftMargin, self.bottomMargin, self.width + 1 * cm, self.height - 2 * cm,
|
||||||
|
|
@ -81,7 +84,7 @@ class EpcBaseDocTemplate(SimpleDocTemplate):
|
||||||
self.addPageTemplates([first_page, later_pages])
|
self.addPageTemplates([first_page, later_pages])
|
||||||
self.story = [NextPageTemplate(['*', 'LaterPages'])]
|
self.story = [NextPageTemplate(['*', 'LaterPages'])]
|
||||||
|
|
||||||
def setSixSemestreTemplatePage(self):
|
def six_semester_template_page(self):
|
||||||
frame_size = (8 * cm, 6.5 * cm,)
|
frame_size = (8 * cm, 6.5 * cm,)
|
||||||
w, h = frame_size
|
w, h = frame_size
|
||||||
|
|
||||||
|
|
@ -102,7 +105,7 @@ class ModuleDescriptionPdf(EpcBaseDocTemplate):
|
||||||
|
|
||||||
def __init__(self, filename):
|
def __init__(self, filename):
|
||||||
super().__init__(filename, 'Module de formation', A4)
|
super().__init__(filename, 'Module de formation', A4)
|
||||||
self.setNormalTemplatePage()
|
self.normal_template_page()
|
||||||
|
|
||||||
def produce(self, module):
|
def produce(self, module):
|
||||||
str_competence = ''
|
str_competence = ''
|
||||||
|
|
@ -177,7 +180,7 @@ class FormationPlanPdf(EpcBaseDocTemplate):
|
||||||
|
|
||||||
def __init__(self, filename):
|
def __init__(self, filename):
|
||||||
super().__init__(filename, 'Plan de formation', landscape(A4))
|
super().__init__(filename, 'Plan de formation', landscape(A4))
|
||||||
self.setNormalTemplatePage()
|
self.normal_template_page()
|
||||||
|
|
||||||
def formating(self, el1='', length=40):
|
def formating(self, el1='', length=40):
|
||||||
el1 = '' if el1 == '' else el1.__str__()
|
el1 = '' if el1 == '' else el1.__str__()
|
||||||
|
|
@ -201,10 +204,13 @@ class FormationPlanPdf(EpcBaseDocTemplate):
|
||||||
[self.formating(domain[6]), self.formating(process[9], 60), 'M17_1', '', 'M17_2', '', 'M17_3', ''],
|
[self.formating(domain[6]), self.formating(process[9], 60), 'M17_1', '', 'M17_2', '', 'M17_3', ''],
|
||||||
[self.formating(domain[7]), self.formating(process[10], 60), 'Macc', '', '', '', '', ''],
|
[self.formating(domain[7]), self.formating(process[10], 60), 'Macc', '', '', '', '', ''],
|
||||||
]
|
]
|
||||||
t = Table(data, colWidths=[7 * cm, 9 * cm, 1.5 * cm, 1.5 * cm, 1.5 * cm, 1.5 * cm, 1.5 * cm, 1.5 * cm],
|
t = Table(
|
||||||
|
data, colWidths=[7 * cm, 9 * cm, 1.5 * cm, 1.5 * cm, 1.5 * cm, 1.5 * cm, 1.5 * cm, 1.5 * cm],
|
||||||
spaceBefore=0.5 * cm, spaceAfter=1 * cm
|
spaceBefore=0.5 * cm, spaceAfter=1 * cm
|
||||||
)
|
)
|
||||||
t.setStyle(TableStyle([
|
t.setStyle(
|
||||||
|
TableStyle(
|
||||||
|
[
|
||||||
('SIZE', (0, 0), (-1, -1), 8),
|
('SIZE', (0, 0), (-1, -1), 8),
|
||||||
('FONT', (0, 0), (-1, 0), 'Helvetica-Bold'),
|
('FONT', (0, 0), (-1, 0), 'Helvetica-Bold'),
|
||||||
('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
|
('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
|
||||||
|
|
@ -214,47 +220,49 @@ class FormationPlanPdf(EpcBaseDocTemplate):
|
||||||
('SPAN', (0, 1), (0, 4)),
|
('SPAN', (0, 1), (0, 4)),
|
||||||
('SPAN', (1, 1), (1, 2)),
|
('SPAN', (1, 1), (1, 2)),
|
||||||
('SPAN', (1, 3), (1, 4)),
|
('SPAN', (1, 3), (1, 4)),
|
||||||
('BACKGROUND', (0, 1), (1, 4), colors.orange),
|
('BACKGROUND', (0, 1), (1, 4), settings.DOMAINE_COULEURS['D1']),
|
||||||
('BACKGROUND', (2, 1), (2, 2), colors.orange),
|
('BACKGROUND', (2, 1), (2, 2), settings.DOMAINE_COULEURS['D1']),
|
||||||
('BACKGROUND', (5, 3), (5, 3), colors.orange),
|
('BACKGROUND', (5, 3), (5, 3), settings.DOMAINE_COULEURS['D1']),
|
||||||
('BACKGROUND', (3, 4), (3, 4), colors.orange),
|
('BACKGROUND', (3, 4), (3, 4), settings.DOMAINE_COULEURS['D1']),
|
||||||
# Domaine 2
|
# Domaine 2
|
||||||
('SPAN', (0, 5), (0, 7)),
|
('SPAN', (0, 5), (0, 7)),
|
||||||
('BACKGROUND', (0, 5), (1, 7), colors.red),
|
('BACKGROUND', (0, 5), (1, 7), settings.DOMAINE_COULEURS['D2']),
|
||||||
('BACKGROUND', (2, 5), (2, 5), colors.red),
|
('BACKGROUND', (2, 5), (2, 5), settings.DOMAINE_COULEURS['D2']),
|
||||||
('BACKGROUND', (4, 5), (4, 5), colors.red),
|
('BACKGROUND', (4, 5), (4, 5), settings.DOMAINE_COULEURS['D2']),
|
||||||
('BACKGROUND', (6, 6), (6, 6), colors.red),
|
('BACKGROUND', (6, 6), (6, 6), settings.DOMAINE_COULEURS['D2']),
|
||||||
('BACKGROUND', (7, 6), (7, 6), colors.red),
|
('BACKGROUND', (7, 6), (7, 6), settings.DOMAINE_COULEURS['D2']),
|
||||||
('BACKGROUND', (6, 7), (6, 7), colors.red),
|
('BACKGROUND', (6, 7), (6, 7), settings.DOMAINE_COULEURS['D2']),
|
||||||
# Domaine 3
|
# Domaine 3
|
||||||
('SPAN', (0, 8), (0, 9)),
|
('SPAN', (0, 8), (0, 9)),
|
||||||
('SPAN', (1, 6), (1, 7)),
|
('SPAN', (1, 6), (1, 7)),
|
||||||
('SPAN', (4, 8), (5, 8)),
|
('SPAN', (4, 8), (5, 8)),
|
||||||
('SPAN', (4, 9), (5, 9)),
|
('SPAN', (4, 9), (5, 9)),
|
||||||
('BACKGROUND', (0, 8), (1, 9), colors.pink),
|
('BACKGROUND', (0, 8), (1, 9), settings.DOMAINE_COULEURS['D3']),
|
||||||
('BACKGROUND', (4, 8), (6, 8), colors.pink),
|
('BACKGROUND', (4, 8), (6, 8), settings.DOMAINE_COULEURS['D3']),
|
||||||
('BACKGROUND', (4, 9), (5, 9), colors.pink),
|
('BACKGROUND', (4, 9), (5, 9), settings.DOMAINE_COULEURS['D3']),
|
||||||
# Domaine 4
|
# Domaine 4
|
||||||
('BACKGROUND', (0, 10), (1, 10), HexColor('#AD7FA8')),
|
('BACKGROUND', (0, 10), (1, 10), settings.DOMAINE_COULEURS['D4']),
|
||||||
('BACKGROUND', (4, 10), (4, 10), HexColor('#AD7FA8')),
|
('BACKGROUND', (4, 10), (4, 10), settings.DOMAINE_COULEURS['D4']),
|
||||||
('BACKGROUND', (6, 10), (6, 10), HexColor('#AD7FA8')),
|
('BACKGROUND', (6, 10), (6, 10), settings.DOMAINE_COULEURS['D4']),
|
||||||
# Domaine 5
|
# Domaine 5
|
||||||
('SPAN', (2, 11), (-1, 11)),
|
('SPAN', (2, 11), (-1, 11)),
|
||||||
('BACKGROUND', (0, 11), (-1, 11), HexColor('#729FCF')),
|
('BACKGROUND', (0, 11), (-1, 11), settings.DOMAINE_COULEURS['D5']),
|
||||||
# Domaine 6
|
# Domaine 6
|
||||||
('SPAN', (2, 12), (3, 12)),
|
('SPAN', (2, 12), (3, 12)),
|
||||||
('SPAN', (4, 12), (5, 12)),
|
('SPAN', (4, 12), (5, 12)),
|
||||||
('SPAN', (6, 12), (7, 12)),
|
('SPAN', (6, 12), (7, 12)),
|
||||||
('BACKGROUND', (0, 12), (-1, 12), colors.lightgreen),
|
('BACKGROUND', (0, 12), (-1, 12), settings.DOMAINE_COULEURS['D6']),
|
||||||
# Domaine 7
|
# Domaine 7
|
||||||
('SPAN', (2, 13), (3, 13)),
|
('SPAN', (2, 13), (3, 13)),
|
||||||
('SPAN', (4, 13), (5, 13)),
|
('SPAN', (4, 13), (5, 13)),
|
||||||
('SPAN', (6, 13), (7, 13)),
|
('SPAN', (6, 13), (7, 13)),
|
||||||
('BACKGROUND', (0, 13), (-1, 13), colors.white),
|
('BACKGROUND', (0, 13), (-1, 13), settings.DOMAINE_COULEURS['D7']),
|
||||||
# Domaine 8
|
# Domaine 8
|
||||||
('SPAN', (2, 14), (-1, 14)),
|
('SPAN', (2, 14), (-1, 14)),
|
||||||
('BACKGROUND', (0, 14), (-1, 14), colors.lightgrey),
|
('BACKGROUND', (0, 14), (-1, 14), settings.DOMAINE_COULEURS['D8']),
|
||||||
]))
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
t.hAlign = TA_LEFT
|
t.hAlign = TA_LEFT
|
||||||
self.story.append(t)
|
self.story.append(t)
|
||||||
self.build(self.story, canvasmaker=NumberedCanvas)
|
self.build(self.story, canvasmaker=NumberedCanvas)
|
||||||
|
|
@ -267,7 +275,7 @@ class PeriodSemesterPdf(EpcBaseDocTemplate):
|
||||||
|
|
||||||
def __init__(self, filename):
|
def __init__(self, filename):
|
||||||
super().__init__(filename, 'Périodes de formation', A4)
|
super().__init__(filename, 'Périodes de formation', A4)
|
||||||
self.setSixSemestreTemplatePage()
|
self.six_semester_template_page()
|
||||||
|
|
||||||
def produce(self, context):
|
def produce(self, context):
|
||||||
for sem in range(1, 7):
|
for sem in range(1, 7):
|
||||||
|
|
@ -277,7 +285,8 @@ class PeriodSemesterPdf(EpcBaseDocTemplate):
|
||||||
for line in modules:
|
for line in modules:
|
||||||
value = getattr(line, 'sem{0}'.format(sem))
|
value = getattr(line, 'sem{0}'.format(sem))
|
||||||
data.append([line.nom, '{0} h.'.format(value)])
|
data.append([line.nom, '{0} h.'.format(value)])
|
||||||
t = Table(data, colWidths=[6.5 * cm, 1 * cm], spaceBefore=0.5 * cm, spaceAfter=1 * cm, hAlign=TA_LEFT,
|
t = Table(
|
||||||
|
data, colWidths=[6.5 * cm, 1 * cm], spaceBefore=0.5 * cm, spaceAfter=1 * cm, hAlign=TA_LEFT,
|
||||||
style=[
|
style=[
|
||||||
('ALIGN', (0, 0), (0, 0), 'LEFT'),
|
('ALIGN', (0, 0), (0, 0), 'LEFT'),
|
||||||
('ALIGN', (1, 0), (-1, -1), 'RIGHT'),
|
('ALIGN', (1, 0), (-1, -1), 'RIGHT'),
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 86 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 86 KiB |
|
|
@ -114,20 +114,6 @@ STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
|
||||||
MEDIA_URL = '/media/'
|
MEDIA_URL = '/media/'
|
||||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
|
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
|
||||||
|
|
||||||
"""
|
|
||||||
STUDENT_IMPORT_MAPPING = {
|
|
||||||
'Num élève': 'id_ext',
|
|
||||||
'Nom élève': 'nom',
|
|
||||||
'Prénom élève': 'prenom',
|
|
||||||
'Rue élève': 'adresse',
|
|
||||||
'Localité élève': 'localite', # pcode is separated from city in prepare_import
|
|
||||||
'Tél. élève': 'telephone',
|
|
||||||
'Natel élève': 'mobile',
|
|
||||||
'Email élève': 'email_rpn',
|
|
||||||
'Date nais. élève': 'date_naissance',
|
|
||||||
'Classe': 'klasse',
|
|
||||||
}
|
|
||||||
"""
|
|
||||||
|
|
||||||
DOMAINE_COULEURS = {
|
DOMAINE_COULEURS = {
|
||||||
'D1': '#fcaf3e',
|
'D1': '#fcaf3e',
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@
|
||||||
|
|
||||||
{% block coltype %}colMS{% endblock %}
|
{% block coltype %}colMS{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<div id="content-main">
|
<div id="content-main">
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,8 @@
|
||||||
{% extends "./base_site.html" %}
|
{% extends "./base_site.html" %}
|
||||||
{% load i18n static %}
|
{% load i18n static %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{% block coltype %}colMS{% endblock %}
|
{% block coltype %}colMS{% endblock %}
|
||||||
|
|
||||||
{% block bodyclass %}{{ block.super }}{% endblock %}
|
{% block bodyclass %}{{ block.super }}{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<div id="content-main">
|
<div id="content-main">
|
||||||
|
|
||||||
<h1>Liste des domaines</h1>
|
<h1>Liste des domaines</h1>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue