Intro svg

This commit is contained in:
alazo 2017-02-03 16:43:41 +01:00
parent 0a04b08308
commit 4c2549e8a4
5 changed files with 63 additions and 29 deletions

View file

@ -48,13 +48,31 @@ class Enseignant(models.Model):
def descr(self): def descr(self):
return '{0} ({1})'.format(self.__str__(), self.email) return '{0} ({1})'.format(self.__str__(), self.email)
class SVG_Domaine:
compteur = 0
x = 30
y = 10
width = 200
svg = '<rect x="20" y="{0}" rx="5" ry="5" width="60" height="{1}" fill="{3}" stroke="black" stroke-width="2" />'
txt = '<text x="25" y="{0}" style="stroke:#000000;font-size:12;">{1}</text>'
def get_svg(self):
return '{0}{1}'.format(self.svg, self.txt)
def __init__(self, domaine):
SVG_Domaine.compteur += 1
self.svg = self.svg.format(20, 100, settings.DOMAINE_COULEUR[domaine.code])
self.txt = self.txt.format(20, domaine.__str__())
class Domaine(models.Model): class Domaine(models.Model):
code = models.CharField(max_length=20, blank=True) code = models.CharField(max_length=20, blank=True)
nom = models.CharField(max_length=200, blank=False) nom = models.CharField(max_length=200, blank=False)
responsable = models.ForeignKey(Enseignant, null=True, default=None) responsable = models.ForeignKey(Enseignant, null=True, default=None)
class Meta: class Meta:
ordering = ('code',) ordering = ('code',)
@ -64,6 +82,14 @@ class Domaine(models.Model):
def url(self): def url(self):
return "<a href='/domaine/{0}'>{1}</a>".format(self.id, self.__str__()) return "<a href='/domaine/{0}'>{1}</a>".format(self.id, self.__str__())
def svg(self):
svg = '<rect x="20" y="{0}" rx="5" ry="5" width="200" height="{1}" fill="{2}" stroke="black" stroke-width="1" />'
txt = '<text x="25" y="{0}" style="stroke:#000000;font-size:10;">{1}</text>'
return svg.format(20, 100, settings.DOMAINE_COULEURS[self.code]) + txt.format(50, self.__str__())
class Processus(models.Model): class Processus(models.Model):
code = models.CharField(max_length=20, blank=True) code = models.CharField(max_length=20, blank=True)
@ -177,8 +203,7 @@ class PDFResponse(HttpResponse):
self['Content-Type'] = 'charset=utf-8' self['Content-Type'] = 'charset=utf-8'
self.story = [] self.story = []
image = Image(settings.MEDIA_ROOT + '/media/header.png', width=480, height=80) image = Image(settings.MEDIA_ROOT + '/media/header.png', width=480, height=80)
image.hAlign = 0 image.hAlign = TA_LEFT
self.story.append(image) self.story.append(image)
#self.story.append(Spacer(0,1*cm)) #self.story.append(Spacer(0,1*cm))
@ -193,7 +218,7 @@ class PDFResponse(HttpResponse):
('LINEABOVE', (0,0) ,(-1,-1), 0.5, colors.black), ('LINEABOVE', (0,0) ,(-1,-1), 0.5, colors.black),
('LINEBELOW', (0,-1),(-1,-1), 0.5, colors.black), ('LINEBELOW', (0,-1),(-1,-1), 0.5, colors.black),
])) ]))
t.hAlign = 0 t.hAlign = TA_LEFT
self.story.append(t) self.story.append(t)
@ -201,7 +226,7 @@ class PDFResponse(HttpResponse):
class MyDocTemplate(SimpleDocTemplate): class MyDocTemplate(SimpleDocTemplate):
def __init__(self, name): def __init__(self, name):
SimpleDocTemplate.__init__(self, name, pagesize=A4, topMargin=0.5*cm) SimpleDocTemplate.__init__(self, name, pagesize=A4, topMargin=0*cm)
self.fileName = name self.fileName = name
self.PAGE_WIDTH = A4[0] self.PAGE_WIDTH = A4[0]
self.PAGE_HEIGHT = A4[1] self.PAGE_HEIGHT = A4[1]
@ -221,7 +246,7 @@ class MyDocTemplate(SimpleDocTemplate):
class MyDocTemplateLandscape(SimpleDocTemplate): class MyDocTemplateLandscape(SimpleDocTemplate):
def __init__(self, name): def __init__(self, name):
SimpleDocTemplate.__init__(self, name, pagesize=landscape(A4), topMargin=0.5*cm) SimpleDocTemplate.__init__(self, name, pagesize=landscape(A4), topMargin=0*cm, leftMargin=2*cm)
self.fileName = name self.fileName = name
self.PAGE_WIDTH = A4[1] self.PAGE_WIDTH = A4[1]
self.PAGE_HEIGHT = A4[0] self.PAGE_HEIGHT = A4[0]

View file

@ -56,7 +56,7 @@ class HomwPDFView(TemplateView):
data = [['Domaines','Processus', 'Sem1', 'Sem2', 'Sem3','Sem4','Sem5','Sem6'], data = [['Domaines','Processus', 'Sem1', 'Sem2', 'Sem3','Sem4','Sem5','Sem6'],
[Preformatted(d[0].__str__(), style_normal, maxLineLength=40), Preformatted(p[0].__str__(), style_normal, maxLineLength=60) , 'M01' , '' ,'' , '' , '' ,'' ], [Preformatted(d[0].__str__(), style_normal, maxLineLength=40), Preformatted(p[0].__str__(), style_normal, maxLineLength=60) , 'M01' , '' ,'' , '' , '' ,'' ],
['' , '' , 'M02' , '' ,'' , '' , '' ,'' ], ['' , '' , 'M02' , '' ,'' , '' , '' ,'' ],
['' , Preformatted(p[1].__str__(), style_normal, maxLineLength=60) , '' , 'M03' ,'' , '' , '' , '' ], ['' , Preformatted(p[1].__str__(), style_normal, maxLineLength=60) , '' , '' ,'' , 'M03' , '' , '' ],
['' , '' , '' , 'M04' ,'' , '' , '' , '' ], ['' , '' , '' , 'M04' ,'' , '' , '' , '' ],
[Preformatted(d[1].__str__(), style_normal, maxLineLength=40), Preformatted(p[2].__str__(), style_normal, maxLineLength=60) , 'M05' , '' ,'M06' , '' , '' , '' ], [Preformatted(d[1].__str__(), style_normal, maxLineLength=40), Preformatted(p[2].__str__(), style_normal, maxLineLength=60) , 'M05' , '' ,'M06' , '' , '' , '' ],
['' , Preformatted(p[3].__str__(), style_normal, maxLineLength=60) , '' , '' ,'' , 'M07' , '' , 'M09' ], ['' , Preformatted(p[3].__str__(), style_normal, maxLineLength=60) , '' , '' ,'' , 'M07' , '' , 'M09' ],
@ -79,13 +79,12 @@ class HomwPDFView(TemplateView):
#('BOX',(0,0),(-1,-1), 0.25, colors.black), #('BOX',(0,0),(-1,-1), 0.25, colors.black),
('GRID',(0,0),(-1,-1), 0.25, colors.black), ('GRID',(0,0),(-1,-1), 0.25, colors.black),
('SPAN',(0,1), (0,4)), ('SPAN',(0,1), (0,4)), #Domaine 1
('SPAN',(1,1), (1,2)), ('SPAN',(1,1), (1,2)),
('SPAN',(1,3), (1,4)), ('SPAN',(1,3), (1,4)),
('SPAN',(0,5), (0,7)), ('SPAN',(0,5), (0,7)), #Domaine 2
('SPAN',(1,6), (1,7)), ('SPAN',(1,6), (1,7)),
('SPAN',(0,8), (0,9)), ('SPAN',(0,8), (0,9)), #Domaine 3
('SPAN',(0,8), (0,9)),
('SPAN',(5,8), (6,8)), ('SPAN',(5,8), (6,8)),
('SPAN',(5,9), (6,9)), ('SPAN',(5,9), (6,9)),
('SPAN',(2,11), (-1,11)), ('SPAN',(2,11), (-1,11)),
@ -98,7 +97,8 @@ class HomwPDFView(TemplateView):
('SPAN',(2,14), (-1,14)), ('SPAN',(2,14), (-1,14)),
('BACKGROUND',(0,1), (1,4), colors.orange), ('BACKGROUND',(0,1), (1,4), colors.orange),
('BACKGROUND',(2,1), (2,2), colors.orange), ('BACKGROUND',(2,1), (2,2), colors.orange),
('BACKGROUND',(3,3), (3,4), colors.orange), ('BACKGROUND',(5,3), (5,3), colors.orange),
('BACKGROUND',(3,4), (3,4), colors.orange),
('BACKGROUND',(0,5), (1,7), colors.red), ('BACKGROUND',(0,5), (1,7), colors.red),
('BACKGROUND',(2,5), (2,5), colors.red), ('BACKGROUND',(2,5), (2,5), colors.red),
('BACKGROUND',(4,5), (4,5), colors.red), ('BACKGROUND',(4,5), (4,5), colors.red),
@ -278,7 +278,7 @@ class PeriodePDFView(TemplateView):
[context['sem1'][1], '{0} h.'.format(context['sem1'][1].sem1),'', context['sem2'][1], '{0} h.'.format(context['sem2'][1].sem2) ], [context['sem1'][1], '{0} h.'.format(context['sem1'][1].sem1),'', context['sem2'][1], '{0} h.'.format(context['sem2'][1].sem2) ],
[context['sem1'][2], '{0} h.'.format(context['sem1'][2].sem1),'', context['sem2'][2], '{0} h.'.format(context['sem2'][2].sem2) ], [context['sem1'][2], '{0} h.'.format(context['sem1'][2].sem1),'', context['sem2'][2], '{0} h.'.format(context['sem2'][2].sem2) ],
[context['sem1'][3], '{0} h.'.format(context['sem1'][3].sem1),'', context['sem2'][3], '{0} h.'.format(context['sem2'][3].sem2) ], [context['sem1'][3], '{0} h.'.format(context['sem1'][3].sem1),'', context['sem2'][3], '{0} h.'.format(context['sem2'][3].sem2) ],
[context['sem1'][4], '{0} h.'.format(context['sem1'][4].sem1),'', context['sem2'][4], '{0} h.'.format(context['sem2'][4].sem2) ], [context['sem1'][4], '{0} h.'.format(context['sem1'][4].sem1),'', '', ''],
[context['sem1'][5], '{0} h.'.format(context['sem1'][5].sem1),'', '', ''], [context['sem1'][5], '{0} h.'.format(context['sem1'][5].sem1),'', '', ''],
@ -288,7 +288,7 @@ class PeriodePDFView(TemplateView):
[context['sem3'][2], '{0} h.'.format(context['sem3'][2].sem3),'', context['sem4'][2], '{0} h.'.format(context['sem4'][2].sem4) ], [context['sem3'][2], '{0} h.'.format(context['sem3'][2].sem3),'', context['sem4'][2], '{0} h.'.format(context['sem4'][2].sem4) ],
[context['sem3'][3], '{0} h.'.format(context['sem3'][3].sem3),'', context['sem4'][3], '{0} h.'.format(context['sem4'][3].sem4) ], [context['sem3'][3], '{0} h.'.format(context['sem3'][3].sem3),'', context['sem4'][3], '{0} h.'.format(context['sem4'][3].sem4) ],
[context['sem3'][4], '{0} h.'.format(context['sem3'][4].sem3),'', context['sem4'][4], '{0} h.'.format(context['sem4'][4].sem4) ], [context['sem3'][4], '{0} h.'.format(context['sem3'][4].sem3),'', context['sem4'][4], '{0} h.'.format(context['sem4'][4].sem4) ],
[context['sem3'][5], '{0} h.'.format(context['sem3'][5].sem3),'', '' ], [context['sem3'][5], '{0} h.'.format(context['sem3'][5].sem3),'', context['sem4'][5], '{0} h.'.format(context['sem4'][5].sem4) ],
['Semestre 5', '{0} h.'.format(context['tot5']['sem5__sum']),'', 'Semestre 6', '{0} h.'.format(context['tot6']['sem6__sum'])], ['Semestre 5', '{0} h.'.format(context['tot5']['sem5__sum']),'', 'Semestre 6', '{0} h.'.format(context['tot6']['sem6__sum'])],
[context['sem5'][0], '{0} h.'.format(context['sem5'][0].sem5),'', context['sem6'][0], '{0} h.'.format(context['sem6'][0].sem6) ], [context['sem5'][0], '{0} h.'.format(context['sem5'][0].sem5),'', context['sem6'][0], '{0} h.'.format(context['sem6'][0].sem6) ],

View file

@ -129,6 +129,8 @@ STUDENT_IMPORT_MAPPING = {
} }
DOMAINE_COULEURS = {'D1':'#fcaf3e', 'D2': '#cc0000', 'D3': '#ef896b', 'D4': '#ad7fa8', 'D5': '#729fcf', 'D6':'#73d216', 'D7':'#ffffff', 'D8':'#babdb6' }
from .local_settings import * from .local_settings import *

View file

@ -30,7 +30,7 @@
</tr> </tr>
<tr> <tr>
<td rowspan="2" class="l1 p">{{P02.url|safe}}</td> <td rowspan="2" class="l1 p">{{P02.url|safe}}</td>
<td></td><td class="l1 m">{{M03.url_code|safe}}</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td> <td></td><td>&nbsp;</td><td>&nbsp;</td><td class="l1 m">{{M03.url_code|safe}}</td><td>&nbsp;</td><td>&nbsp;</td>
</tr> </tr>
<tr> <tr>
@ -87,7 +87,9 @@
<tr> <tr>
<td class="l7 d">{{D7.url|safe}}</td> <td class="l7 d">{{D7.url|safe}}</td>
<td class="l7 p">{{P10.url|safe}}</td> <td class="l7 p">{{P10.url|safe}}</td>
<td colspan="2" class="l7 m">{{M17_1.url_code|safe}}</td><td colspan="2" class="l7 m">{{M17_2.url_code|safe}}</td><td colspan="2" class="l7 m">{{M17_3.url_code|safe}}</td> <td colspan="2" class="l7 m">{{M17_1.url_code|safe}}</td>
<td colspan="2" class="l7 m">{{M17_2.url_code|safe}}</td>
<td colspan="2" class="l7 m">{{M17_3.url_code|safe}}</td>
</tr> </tr>
<!-- Ligne 8 --> <!-- Ligne 8 -->
@ -100,6 +102,9 @@
<br/> <br/>
<a href="{% url 'plan-pdf' %}">Imprimer en PDF</a> <a href="{% url 'plan-pdf' %}">Imprimer en PDF</a>
</div> </div>
<svg xmlns="http://www.w3.org/2000/svg">
{{D1.svg|safe}}
</svg>
{% endblock %} {% endblock %}

View file

@ -10,43 +10,45 @@
<h1>Périodes de formation</h1> <h1>Périodes de formation</h1>
<table> <table>
<tr><th width="290px">Semestre 1</th><th text-align="right">{{tot1.sem1__sum}}h.</th><th width="40px"></th><th width="290px">Semestre 2</th><th text-align="right">{{tot2.sem2__sum}}h.</th></tr> <tr><th width="290px">Semestre 1</th><th text-align="right">{{tot1.sem1__sum}}h.</th><th width="40px"></th><th width="290px">Semestre 2</th><th text-align="right">{{tot2.sem2__sum}}h.</th></tr>
<tr><td colspan="2"><table align="right"> <tr><td colspan="2"><table align="left">
{% for s in sem1 %} {% for s in sem1 %}
<tr><td>{{s}}</td><td>{{s.sem1}} h.</td></tr> <tr><td width="290px">{{s}}</td><td>{{s.sem1}} h.</td></tr>
{% endfor %} {% endfor %}
</table> </table>
</td> </td>
<td></td> <td></td>
<td colspan="2"> <td colspan="2">
<table align="right"> <table align="left">
{% for s in sem2 %} {% for s in sem2 %}
<tr><td>{{s}}</td><td>{{s.sem2}} h.</td></tr> <tr><td width="290px">{{s}}</td><td>{{s.sem2}} h.</td></tr>
{% endfor %} {% endfor %}
</table> </table>
</td></tr> </td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><th>Semestre 3</th><th text-align="right">{{tot3.sem3__sum}}h.</th><th></th><th>Semestre 4</th><th text-align="right">{{tot4.sem4__sum}}h.</th> </tr> <tr><th>Semestre 3</th><th text-align="right">{{tot3.sem3__sum}}h.</th><th></th><th>Semestre 4</th><th text-align="right">{{tot4.sem4__sum}}h.</th> </tr>
<tr><td colspan="2"><table align="right"> <tr><td colspan="2"><table align="left">
{% for s in sem3 %} {% for s in sem3 %}
<tr><td>{{s}}</td><td>{{s.sem3}} h.</td></tr> <tr><td width="290px">{{s}}</td><td>{{s.sem3}} h.</td></tr>
{% endfor %} {% endfor %}
</table></td> </table></td>
<td></td> <td></td>
<td colspan="2"><table align="right"> <td colspan="2"><table align="left">
{% for s in sem4 %} {% for s in sem4 %}
<tr><td>{{s}}</td><td>{{s.sem4}} h.</td></tr> <tr><td width="290px">{{s}}</td><td>{{s.sem4}} h.</td></tr>
{% endfor %} {% endfor %}
</table></td></tr> </table></td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><th>Semestre 5</th><th text-align="right">{{tot5.sem5__sum}}h.</th><th></th><th>Semestre 6</th><th text-align="right">{{tot6.sem6__sum}}h.</th></tr> <tr><th>Semestre 5</th><th text-align="right">{{tot5.sem5__sum}}h.</th><th></th><th>Semestre 6</th><th text-align="right">{{tot6.sem6__sum}}h.</th></tr>
<tr><td colspan="2"><table align="right"> <tr><td colspan="2"><table align="left">
{% for s in sem5 %} {% for s in sem5 %}
<tr><td>{{s}}</td><td>{{s.sem5}} h.</td></tr> <tr><td width="290px">{{s}}</td><td>{{s.sem5}} h.</td></tr>
{% endfor %} {% endfor %}
</table></td> </table></td>
<td></td> <td></td>
<td colspan="2"> <td colspan="2">
<table align="right"> <table align="left">
{% for s in sem6 %} {% for s in sem6 %}
<tr><td>{{s}}</td><td>{{s.sem6}} h.</td></tr> <tr><td width="290px">{{s}}</td><td>{{s.sem6}} h.</td></tr>
{% endfor %} {% endfor %}
</table> </table>
</td></tr> </td></tr>