Intro svg
This commit is contained in:
parent
0a04b08308
commit
4c2549e8a4
5 changed files with 63 additions and 29 deletions
|
|
@ -48,13 +48,31 @@ class Enseignant(models.Model):
|
|||
|
||||
def descr(self):
|
||||
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):
|
||||
code = models.CharField(max_length=20, blank=True)
|
||||
nom = models.CharField(max_length=200, blank=False)
|
||||
responsable = models.ForeignKey(Enseignant, null=True, default=None)
|
||||
|
||||
|
||||
class Meta:
|
||||
ordering = ('code',)
|
||||
|
||||
|
|
@ -64,6 +82,14 @@ class Domaine(models.Model):
|
|||
def url(self):
|
||||
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):
|
||||
code = models.CharField(max_length=20, blank=True)
|
||||
|
|
@ -177,8 +203,7 @@ class PDFResponse(HttpResponse):
|
|||
self['Content-Type'] = 'charset=utf-8'
|
||||
self.story = []
|
||||
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(Spacer(0,1*cm))
|
||||
|
|
@ -193,7 +218,7 @@ class PDFResponse(HttpResponse):
|
|||
('LINEABOVE', (0,0) ,(-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)
|
||||
|
||||
|
||||
|
|
@ -201,7 +226,7 @@ class PDFResponse(HttpResponse):
|
|||
class MyDocTemplate(SimpleDocTemplate):
|
||||
|
||||
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.PAGE_WIDTH = A4[0]
|
||||
self.PAGE_HEIGHT = A4[1]
|
||||
|
|
@ -221,7 +246,7 @@ class MyDocTemplate(SimpleDocTemplate):
|
|||
class MyDocTemplateLandscape(SimpleDocTemplate):
|
||||
|
||||
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.PAGE_WIDTH = A4[1]
|
||||
self.PAGE_HEIGHT = A4[0]
|
||||
|
|
|
|||
16
cms/views.py
16
cms/views.py
|
|
@ -56,7 +56,7 @@ class HomwPDFView(TemplateView):
|
|||
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' , '' ,'' , '' , '' ,'' ],
|
||||
['' , '' , 'M02' , '' ,'' , '' , '' ,'' ],
|
||||
['' , Preformatted(p[1].__str__(), style_normal, maxLineLength=60) , '' , 'M03' ,'' , '' , '' , '' ],
|
||||
['' , Preformatted(p[1].__str__(), style_normal, maxLineLength=60) , '' , '' ,'' , 'M03' , '' , '' ],
|
||||
['' , '' , '' , 'M04' ,'' , '' , '' , '' ],
|
||||
[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' ],
|
||||
|
|
@ -79,13 +79,12 @@ class HomwPDFView(TemplateView):
|
|||
|
||||
#('BOX',(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,3), (1,4)),
|
||||
('SPAN',(0,5), (0,7)),
|
||||
('SPAN',(0,5), (0,7)), #Domaine 2
|
||||
('SPAN',(1,6), (1,7)),
|
||||
('SPAN',(0,8), (0,9)),
|
||||
('SPAN',(0,8), (0,9)),
|
||||
('SPAN',(0,8), (0,9)), #Domaine 3
|
||||
('SPAN',(5,8), (6,8)),
|
||||
('SPAN',(5,9), (6,9)),
|
||||
('SPAN',(2,11), (-1,11)),
|
||||
|
|
@ -98,7 +97,8 @@ class HomwPDFView(TemplateView):
|
|||
('SPAN',(2,14), (-1,14)),
|
||||
('BACKGROUND',(0,1), (1,4), 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',(2,5), (2,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'][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'][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),'', '', ''],
|
||||
|
||||
|
||||
|
|
@ -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'][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'][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'])],
|
||||
[context['sem5'][0], '{0} h.'.format(context['sem5'][0].sem5),'', context['sem6'][0], '{0} h.'.format(context['sem6'][0].sem6) ],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue