diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4383301 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*.pyc +common/local_settings.py +db.sqlite3 +*.sql + diff --git a/.project b/.project new file mode 100644 index 0000000..6de12a2 --- /dev/null +++ b/.project @@ -0,0 +1,18 @@ + + + eds + + + + + + org.python.pydev.PyDevBuilder + + + + + + org.python.pydev.pythonNature + org.python.pydev.django.djangoNature + + diff --git a/.pydevproject b/.pydevproject new file mode 100644 index 0000000..1b60d58 --- /dev/null +++ b/.pydevproject @@ -0,0 +1,12 @@ + + + +DJANGO_MANAGE_LOCATION +eds/manage.py + + +/${PROJECT_DIR_NAME} + +python 3.0 +eds + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..d76493b --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +encoding//cms/forms.py=utf-8 +encoding//cms/models.py=utf-8 +encoding//cms/views.py=utf-8 +encoding//common/settings.py=utf-8 diff --git a/cms/migrations/0013_auto_20170108_2119.py b/cms/migrations/0013_auto_20170108_2119.py new file mode 100644 index 0000000..17d6169 --- /dev/null +++ b/cms/migrations/0013_auto_20170108_2119.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.4 on 2017-01-08 21:19 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('cms', '0012_auto_20170104_1347'), + ] + + operations = [ + migrations.AlterModelOptions( + name='competence', + options={'ordering': ('code',), 'verbose_name': 'compétence'}, + ), + migrations.AlterModelOptions( + name='processus', + options={'ordering': ('code',), 'verbose_name_plural': 'processus'}, + ), + migrations.AlterModelOptions( + name='souscompetence', + options={'ordering': ('code',), 'verbose_name': 'sous-compétence'}, + ), + ] diff --git a/cms/models.py b/cms/models.py index 501d586..dd0a4ed 100644 --- a/cms/models.py +++ b/cms/models.py @@ -5,8 +5,22 @@ Created on 17 nov. 2012 @author: alzo ''' from django.db import models +from django.http.response import HttpResponse +from django.conf import settings - +from reportlab.platypus import SimpleDocTemplate +from reportlab.platypus import Paragraph, Spacer, PageBreak, Table, TableStyle, Image +from reportlab.graphics.shapes import Line +from reportlab.lib.pagesizes import A4, landscape +from reportlab.lib.units import cm +from reportlab.lib.enums import TA_LEFT, TA_CENTER +from reportlab.lib import colors +from reportlab.lib.styles import ParagraphStyle as PS +style_8_c = PS(name='CORPS', fontName='Helvetica', fontSize=6, alignment = TA_CENTER) +style_normal = PS(name='CORPS', fontName='Helvetica', fontSize=8, alignment = TA_LEFT) +style_bold = PS(name='CORPS', fontName='Helvetica-Bold', fontSize=10, alignment = TA_LEFT) +style_title = PS(name='CORPS', fontName='Helvetica', fontSize=12, alignment = TA_LEFT) +style_adress = PS(name='CORPS', fontName='Helvetica', fontSize=10, alignment = TA_LEFT, leftIndent=300) # Create your models here. CHOIX_TYPE_SAVOIR = ( @@ -32,6 +46,9 @@ class Enseignant(models.Model): def __str__(self): return '{0} {1}'.format(self.nom, self.prenom) + def descr(self): + return '{0} ({1})'.format(self.__str__(), self.email) + class Domaine(models.Model): code = models.CharField(max_length=20, blank=True) @@ -102,7 +119,7 @@ class Module(models.Model): return "{1}".format(self.id, self.__str__()) def url_code(self): - return "{1}".format(self.id, self.code) + return "{1}".format(self.id, self.code, self.nom) class Competence(models.Model): @@ -143,7 +160,6 @@ class Ressource(models.Model): class Objectif(models.Model): libelle = models.CharField(max_length=200, blank=False) - #type = models.CharField(max_length=30, choices = CHOIX_TYPE_SAVOIR) module=models.ForeignKey(Module, null=True, default=None) def __str__(self): @@ -155,10 +171,61 @@ class Document(models.Model): - +class PDFResponse(HttpResponse): + def __init__(self, filename, title=''): + HttpResponse.__init__(self, content_type='application/pdf') + self['Content-Disposition'] = 'attachment; filename={0}'.format(filename) + self['Content-Type'] = 'charset=utf-8' + self.story = [] + image = Image(settings.MEDIA_ROOT + '/media/header.gif', width=350, height=40) + image.hAlign = 0 + + self.story.append(image) + self.story.append(Spacer(0,1*cm)) + + data = [['Filières EDS', title]] + t = Table(data, colWidths=[8*cm,8*cm]) + t.setStyle(TableStyle([ ('ALIGN',(0,0),(0,0),'LEFT'), + ('ALIGN',(1,0),(-1,-1),'RIGHT'), + ('LINEABOVE', (0,0) ,(-1,-1), 0.5, colors.black), + ('LINEBELOW', (0,-1),(-1,-1), 0.5, colors.black), + ])) + t.hAlign = 0 + self.story.append(t) + + +class MyDocTemplate(SimpleDocTemplate): + + def __init__(self, name): + + #BaseDocTemplate.__init__(self,name, pagesize=A4, topMargin=0.5*cm) + SimpleDocTemplate.__init__(self, name, pagesize=A4, topMargin=0.5*cm) + self.fileName = name + + + def beforePage(self): + # page number + self.canv.saveState() + self.canv.setFontSize(8) + #self.canv.drawCentredString(self.CENTRE_WIDTH,1*cm,"Page : " + str(self.canv.getPageNumber())) + self.canv.restoreState() + + + +class MyDocTemplateLandscape(SimpleDocTemplate): + + def __init__(self, name): + SimpleDocTemplate.__init__(self, name, pagesize=landscape(A4), topMargin=0.5*cm) + self.fileName = name + + def beforePage(self): + # page number + self.canv.saveState() + self.canv.setFontSize(8) + #self.canv.drawCentredString(self.CENTRE_WIDTH,1*cm,"Page : " + str(self.canv.getPageNumber())) + self.canv.restoreState() - \ No newline at end of file diff --git a/cms/static/css/main.css b/cms/static/css/main.css index 80bb59e..0f584d6 100644 --- a/cms/static/css/main.css +++ b/cms/static/css/main.css @@ -31,12 +31,11 @@ #plan { border-collapse: separate; - border-spacing: 5px 10px; - + border-spacing: 5px 6px; } table th { - font-size:120%; + font-size:110%; } ul, ul li { @@ -49,11 +48,16 @@ ul li { list-style-type:none; */ } - .liste-table { + margin-left:10px; + padding-left:0px; + +} + +.liste-table li{ list-style-type:square; - margin-left:0px; - padding:0px; + margin-left:3px; + padding:0px 10px;; } .clear-booth { float:none; diff --git a/cms/static/img/header.gif b/cms/static/img/header.gif new file mode 100755 index 0000000..a02c592 Binary files /dev/null and b/cms/static/img/header.gif differ diff --git a/cms/views.py b/cms/views.py index 644f8f4..d156640 100644 --- a/cms/views.py +++ b/cms/views.py @@ -5,9 +5,10 @@ Created on 4 déc. 2012 @author: alzo ''' import os -from django.shortcuts import render +from django.shortcuts import render, render_to_response from django.views.generic import ListView, TemplateView, DetailView -from .models import Domaine, Processus, Module, Document, Document +from .models import Domaine, Processus, Module, Document, PDFResponse, MyDocTemplate, MyDocTemplateLandscape +from .models import style_normal, style_bold, style_title from django.db.models import F, Sum from django.conf import settings @@ -15,12 +16,19 @@ from django.http import HttpResponseRedirect from django.http import HttpResponse from .forms import DocumentForm +from reportlab.pdfgen import canvas + +from reportlab.platypus import Paragraph, Spacer, PageBreak, Table, TableStyle, Preformatted +from reportlab.lib.units import cm +from reportlab.lib.enums import TA_LEFT +from reportlab.lib import colors +from reportlab.lib.colors import HexColor + # Create your views here. class HomeView(TemplateView): template_name = 'cms/index.html' - def get_context_data(self, **kwargs): context = super(HomeView, self).get_context_data(**kwargs) for d in Domaine.objects.all().order_by('code'): @@ -33,7 +41,89 @@ class HomeView(TemplateView): context[m.code] = m return context + + +class HomwPDFView(TemplateView): + template_name = 'cms/index.html' + def render_to_response(self, context, **response_kwargs): + + response = PDFResponse('PlanFormation.pdf' ,'Plan de formation') + d = Domaine.objects.all().order_by('code') + p = Processus.objects.all().order_by('code') + + + 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' ,'' , '' , '' , '' ], + ['' , '' , '' , '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' ], + ['' , '' , '' , '' ,'' , 'M08' , '' , '' ], + [Preformatted(d[2].__str__(), style_normal, maxLineLength=40), Preformatted(p[4].__str__(), style_normal, maxLineLength=60) , '' , '' ,'' , 'M10' , '' , 'M12' ], + ['' , Preformatted(p[5].__str__(), style_normal, maxLineLength=60) , '' , '' ,'' , 'M11' , '' , '' ], + [Preformatted(d[3].__str__(), style_normal, maxLineLength=40), Preformatted(p[6].__str__(), style_normal, maxLineLength=60) , '' , '' ,'' , 'M13' , '' , 'M14' ], + [Preformatted(d[4].__str__(), style_normal, maxLineLength=40), Preformatted(p[7].__str__(), style_normal, maxLineLength=60) , 'M15' , '' ,'' , '' , '' , '' ], + [Preformatted(d[5].__str__(), style_normal, maxLineLength=40), Preformatted(p[8].__str__(), style_normal, maxLineLength=60) , 'M16_1' , '' ,'M16_2' , '' , 'M16_3' , '' ], + [Preformatted(d[6].__str__(), style_normal, maxLineLength=40), Preformatted(p[9].__str__(), style_normal, maxLineLength=60), 'M17_1' , '' ,'M17_2' , '' , 'M17_3' , '' ], + [Preformatted(d[7].__str__(), style_normal, maxLineLength=40), Preformatted(p[10].__str__(), style_normal, maxLineLength=60) , 'Macc' , '' ,'' , '' , '' , '' ], + ] + + t = Table(data, colWidths=[5.5*cm, 8*cm, 1.5*cm, 1.5*cm,1.5*cm, 1.5*cm,1.5*cm,1.5*cm], spaceBefore=1*cm, spaceAfter=1*cm) + t.setStyle(TableStyle([ + ('SIZE', (0,0), (-1,-1), 8), + ('FONT', (0,0), (-1,0), 'Helvetica-Bold'), + ('VALIGN',(0,0),(-1,-1),'MIDDLE'), + ('ALIGN',(2,0),(-1,-1),'CENTER'), + + #('BOX',(0,0),(-1,-1), 0.25, colors.black), + ('GRID',(0,0),(-1,-1), 0.25, colors.black), + ('SPAN',(0,1), (0,4)), + ('SPAN',(1,1), (1,2)), + ('SPAN',(1,3), (1,4)), + ('SPAN',(0,5), (0,7)), + ('SPAN',(1,6), (1,7)), + ('SPAN',(0,8), (0,9)), + ('SPAN',(0,8), (0,9)), + ('SPAN',(5,8), (6,8)), + ('SPAN',(5,9), (6,9)), + ('SPAN',(2,11), (-1,11)), + ('SPAN',(2,12), (3,12)), + ('SPAN',(4,12), (5,12)), + ('SPAN',(6,12), (7,12)), + ('SPAN',(2,13), (3,13)), + ('SPAN',(4,13), (5,13)), + ('SPAN',(6,13), (7,13)), + ('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',(0,5), (1,7), colors.red), + ('BACKGROUND',(2,5), (2,5), colors.red), + ('BACKGROUND',(4,5), (4,5), colors.red), + ('BACKGROUND',(5,6), (5,6), colors.red), + ('BACKGROUND',(7,6), (7,6), colors.red), + ('BACKGROUND',(5,7), (5,7), colors.red), + ('BACKGROUND',(0,8), (1,9), colors.pink), + ('BACKGROUND',(5,8), (-1,8), colors.pink), + ('BACKGROUND',(5,9), (6,9), colors.pink), + ('BACKGROUND',(0,10), (1,10), HexColor('#AD7FA8')), + ('BACKGROUND',(5,10), (5,10), HexColor('#AD7FA8')), + ('BACKGROUND',(7,10), (7,10), HexColor('#AD7FA8')), + ('BACKGROUND',(0,11), (-1,11), HexColor('#729FCF')), + ('BACKGROUND',(0,12), (-1,12), colors.lightgreen), + ('BACKGROUND',(0,13), (-1,13), colors.white), + ('BACKGROUND',(0,14), (-1,14), colors.lightgrey), + ])) + + t.hAlign = 0 + response.story.append(t) + + doc = MyDocTemplateLandscape(response) + doc.build(response.story) + + return response class DomaineDetailView(DetailView): @@ -65,7 +155,102 @@ class ModuleListView(ListView): template_name = 'cms/module_list.html' model = Module +def Preformatted_left(text): + return Preformatted(text, style_normal, maxLineLength=15) + +def Preformatted_right(text): + return Preformatted(text, style_normal, maxLineLength=110) + + +class ModulePDF(DetailView): + + template_name = 'cms/module_detail.html' + model = Module + + def get_object(self): + # Call the superclass + return super(ModulePDF, self).get_object() + + + + def render_to_response(self, context, **response_kwargs): + #return DetailView.render_to_response(self, context, **response_kwargs) + m = self.get_object() + response = PDFResponse('Module_{0}.pdf'.format(m.code) ,'Module de formation') + + + str_comp = '' + for c in m.competences.all(): + str_comp += '- {0} ({1})\n'.format(c.libelle, c.code) + if self.request.user.is_authenticated: + for sc in c.souscompetence_set.all(): + str_comp += ' -- {0}\n'.format(sc.libelle) + + str_res = '' + for c in m.ressource_set.all(): + str_res += '- {0}\n'.format(c.libelle) + + str_obj = '' + for c in m.objectif_set.all(): + str_obj += '- {0}\n'.format(c.libelle) + + lines = m.contenu.split('\n') + str_con = '' + for l in lines: + str_con += '{0}\n'.format(l) + + response.story.append(Spacer(0,1*cm)) + response.story.append(Paragraph(m.__str__(), style_title)) + + data = [[Preformatted_left('Domaine'), Preformatted_right(m.processus.domaine.__str__())], + [Preformatted_left('Processus'), Preformatted_right(m.processus.__str__())], + [Preformatted_left('Situation emblématique'), Preformatted_right(m.situation)], + [Preformatted_left('Compétences visées'), Preformatted_right(str_comp)], + [Preformatted_left('Ressources à acquérir'), Preformatted_right(str_res)], + [Preformatted_left('Objectifs à atteindre'), Preformatted_right(str_obj)], + [Preformatted_left('Contenu'), Preformatted_right(str_con)], + [Preformatted_left('Evaluation'), Preformatted_right(m.evaluation)], + [Preformatted_left('Type'), Preformatted_right(m.type)], + [Preformatted_left('Semestre'), Preformatted_right(m.semestre)], + [Preformatted_left('Présentiel'), Preformatted_right('{0} heures'.format(m.periode_presentiel))], + [Preformatted_left('Travail personnel'), Preformatted_right('{0} heures'.format(m.travail_perso))], + [Preformatted_left('Responsable'), Preformatted_right(m.processus.domaine.responsable.descr())], + ] + t = Table(data, colWidths=[2.5*cm,10*cm]) + t.setStyle(TableStyle([ ('ALIGN',(0,0),(-1,-1),'LEFT'), + ('VALIGN',(0,0),(-1,-1),'TOP'), + ('LEFTPADDING', (0,0),(-1,-1), 0), + ])) + t.hAlign=0 + response.story.append(Spacer(0,1*cm)) + response.story.append(t) + + + doc = MyDocTemplate(response) + doc.build(response.story) + + return response + +""" +Calcul du nombre de périodes de formation +""" +def get_context(context): + liste = Module.objects.exclude(periode_presentiel = 0) + context['tot'] = liste.aggregate(Sum(F('periode_presentiel'))) + context['sem1'] = liste.exclude(sem1 = 0) + context['tot1'] = liste.aggregate(Sum(F('sem1'))) + context['sem2'] = liste.exclude(sem2 = 0) + context['tot2'] = liste.aggregate(Sum(F('sem2'))) + context['sem3'] = liste.exclude(sem3 = 0) + context['tot3'] = liste.aggregate(Sum(F('sem3'))) + context['sem4'] = liste.exclude(sem4 = 0) + context['tot4'] = liste.aggregate(Sum(F('sem4'))) + context['sem5'] = liste.exclude(sem5 = 0) + context['tot5'] = liste.aggregate(Sum(F('sem5'))) + context['sem6'] = liste.exclude(sem6 = 0) + context['tot6'] = liste.aggregate(Sum(F('sem6'))) + return context class PeriodeView(TemplateView): @@ -73,25 +258,69 @@ class PeriodeView(TemplateView): def get_context_data(self, **kwargs): context = TemplateView.get_context_data(self, **kwargs) - liste = Module.objects.exclude(periode_presentiel = 0) - context['tot'] = liste.aggregate(Sum(F('periode_presentiel'))) - context['sem1'] = liste.exclude(sem1 = 0) - context['tot1'] = liste.aggregate(Sum(F('sem1'))) - context['sem2'] = liste.exclude(sem2 = 0) - context['tot2'] = liste.aggregate(Sum(F('sem2'))) - context['sem3'] = liste.exclude(sem3 = 0) - context['tot3'] = liste.aggregate(Sum(F('sem3'))) - context['sem4'] = liste.exclude(sem4 = 0) - context['tot4'] = liste.aggregate(Sum(F('sem4'))) - context['sem5'] = liste.exclude(sem5 = 0) - context['tot5'] = liste.aggregate(Sum(F('sem5'))) - context['sem6'] = liste.exclude(sem6 = 0) - context['tot6'] = liste.aggregate(Sum(F('sem6'))) - - return context - - + return get_context(context) + +class PeriodePDFView(TemplateView): + template_name = 'cms/periodes.html' + + def render_to_response(self, context, **response_kwargs): + + response = PDFResponse('Périodes.pdf' ,'Périodes de formation') + context = get_context(context) + + data = [['Semestre 1', '{0} h.'.format(context['tot1']['sem1__sum']),'', 'Semestre 2', '{0} h.'.format(context['tot2']['sem2__sum'])], + [context['sem1'][0], '{0} h.'.format(context['sem1'][0].sem1),'', context['sem2'][0], '{0} h.'.format(context['sem2'][0].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'][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'][5], '{0} h.'.format(context['sem1'][5].sem1),'', '','' ], + [context['sem1'][6], '{0} h.'.format(context['sem1'][6].sem1),'', '','' ], + ['Semestre 3', '{0} h.'.format(context['tot3']['sem3__sum']),'', 'Semestre 4', '{0} h.'.format(context['tot4']['sem4__sum'])], + [context['sem3'][0], '{0} h.'.format(context['sem3'][0].sem3),'', context['sem4'][0], '{0} h.'.format(context['sem4'][0].sem4) ], + [context['sem3'][1], '{0} h.'.format(context['sem3'][1].sem3),'', context['sem4'][1], '{0} h.'.format(context['sem4'][1].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'][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['sem4'][5], '{0} h.'.format(context['sem4'][5].sem4) ], + ['','', '',context['sem4'][6], '{0} h.'.format(context['sem4'][6].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) ], + [context['sem5'][1], '{0} h.'.format(context['sem5'][1].sem5),'', context['sem6'][1], '{0} h.'.format(context['sem6'][1].sem6) ], + [context['sem5'][2], '{0} h.'.format(context['sem5'][2].sem5),'', context['sem6'][2], '{0} h.'.format(context['sem6'][2].sem6) ], + [context['sem5'][3], '{0} h.'.format(context['sem5'][3].sem5),'', context['sem6'][3], '{0} h.'.format(context['sem6'][3].sem6) ], + [context['sem5'][4], '{0} h.'.format(context['sem5'][4].sem5),'', context['sem6'][4], '{0} h.'.format(context['sem6'][4].sem6) ], + [context['sem5'][5], '{0} h.'.format(context['sem5'][5].sem5),'', '','' ], + [context['sem5'][6], '{0} h.'.format(context['sem5'][6].sem5),'', '','' ], + ] + + t = Table(data, colWidths=[6.5*cm,1*cm, 1*cm, 6.5*cm, 1*cm], spaceBefore=2*cm, spaceAfter=1.5*cm) + t.setStyle(TableStyle([ ('ALIGN',(0,0),(-1,-1),'LEFT'), + ('VALIGN',(0,0),(-1,-1),'TOP'), + ('LEFTPADDING', (0,0),(-1,-1), 0), + ('SIZE', (0,0), (-1,-1), 8), + ('ALIGN', (1,0), (1,-1), 'RIGHT'), + ('ALIGN', (-1,0), (-1,-1), 'RIGHT'), + ('LINEBELOW', (0,0), (1,0), 1, colors.black), + ('LINEBELOW', (3,0), (-1,0), 1, colors.black), + + ('TOPPADDING', (0,8), (-1,8), 15), + ('LINEBELOW', (0,8), (1,8), 1, colors.black), + ('LINEBELOW', (3,8), (-1,8), 1, colors.black), + ('TOPPADDING', (0,16), (-1,16), 15), + ('LINEBELOW', (0,16), (1,16), 1, colors.black), + ('LINEBELOW', (3,16), (-1,16), 1, colors.black), + ])) + + t.hAlign = 0 + response.story.append(t) + + response.story.append(Paragraph('Total des heures de cours: {0} h.'.format(context['tot']['periode_presentiel__sum']), style_normal)) + doc = MyDocTemplate(response) + doc.build(response.story) + + return response def AddDoc(request): if request.method == 'POST': @@ -114,5 +343,11 @@ def Download(request, file_name): response['Content-Length'] = os.stat(f).st_size return response - + +def pdf_view(request): + with open('/home/alzo/dev/eds/media/media/EDS_Calendrier_2017.pdf', 'r') as pdf: + response = HttpResponse(pdf.read().decode('latin-1') , content_type='application/pdf') + response['Content-Disposition'] = 'inline;filename=some_file.pdf' + return response + pdf.closed \ No newline at end of file diff --git a/common/settings.py b/common/settings.py index ffe054d..3205592 100644 --- a/common/settings.py +++ b/common/settings.py @@ -113,7 +113,7 @@ STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static/') MEDIA_URL = '/media/' -MEDIA_ROOT = os.path.join(BASE_DIR, 'media') +MEDIA_ROOT = os.path.join(BASE_DIR, 'media/') from .local_settings import * diff --git a/common/urls.py b/common/urls.py index 6224abf..af56370 100644 --- a/common/urls.py +++ b/common/urls.py @@ -21,6 +21,7 @@ from django.conf.urls.static import static urlpatterns = [ url(r'^$', views.HomeView.as_view(), name='home'), + url(r'^plan_pdf/$', views.HomwPDFView.as_view(), name='plan-pdf'), url(r'^admin/', admin.site.urls), url(r'^domaine/(?P\d+)$', views.DomaineDetailView.as_view(), name='domaine-detail'), url(r'^domaines/$', views.DomaineListView.as_view(), name='domaine-list'), @@ -28,7 +29,10 @@ urlpatterns = [ url(r'^processus/$', views.ProcessusListView.as_view(), name='processus-list'), url(r'^module/(?P\d+)$', views.ModuleDetailView.as_view(), name='module-detail'), url(r'^modules/$', views.ModuleListView.as_view(), name='module-list'), - url(r'^periode$', views.PeriodeView.as_view(), name='periode'), + url(r'^periodes$', views.PeriodeView.as_view(), name='periodes'), + url(r'^periodes_pdf$', views.PeriodePDFView.as_view(), name='periodes-pdf'), url(r'^upload$', views.AddDoc, name='upload'), url(r'^download/(?P.+)$', views.Download, name='download'), + url(r'^calendrier/$', views.pdf_view, name='pdf-view'), + url(r'^module_pdf/(?P\d+)$', views.ModulePDF.as_view(), name='module-pdf'), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/media/media/header.gif b/media/media/header.gif new file mode 100755 index 0000000..59d0a3c Binary files /dev/null and b/media/media/header.gif differ diff --git a/static/css/main.css b/static/css/main.css deleted file mode 100644 index c54c70b..0000000 --- a/static/css/main.css +++ /dev/null @@ -1,7 +0,0 @@ -@CHARSET "UTF-8"; - -#titre_col ul li { - list-style-type:none; -} - - diff --git a/templates/cms/base_site.html b/templates/cms/base_site.html index 0df6da7..e35847e 100644 --- a/templates/cms/base_site.html +++ b/templates/cms/base_site.html @@ -2,8 +2,17 @@ {% block title %}EDS{% endblock %} -{% block branding %}

Formation EDS

{% endblock %} -{% block usertools %}{% endblock %} +{% block branding %}

Formation en Education sociale ES

{% endblock %} +{% block usertools %} +
+{% if user.is_authenticated %} +{% block welcome-msg %}Bienvenue {% firstof user.username %}.{% endblock %} +Site public  Admin +{% else %} +Admin +{% endif %} +
+{% endblock %} {% block nav-global %}{% endblock %} {% block breadcrumbs %} {% endblock %} diff --git a/templates/cms/module_detail.html b/templates/cms/module_detail.html index 85c4677..5cb0c60 100644 --- a/templates/cms/module_detail.html +++ b/templates/cms/module_detail.html @@ -10,13 +10,15 @@ - - - - - - + + + + + + {% if object.periode_presentiel > 0 %} @@ -28,9 +30,9 @@ {% if object.travail_perso > 0 %} {% endif %} - +
Domaine{{object.processus.domaine.url|safe}}
Processus{{object.processus.url|safe}}
Situation emblématique{{object.situation}}
Compétences visées

L'éducateur social, l'éducatrice sociale

-{% for c in object.competences.all %}- {{c.libelle}} ({{c.code}})
{% endfor %}
Ressources{% for c in object.ressource_set.all %}- {{c}}
{% endfor %}
Objectifs{% for c in object.objectif_set.all %}- {{c}}
{% endfor %}
Contenu{{object.contenu}}
Evaluation{{object.evaluation}}
Situation emblématique{{object.situation|linebreaksbr}}
Compétences visées

L'éducateur social, l'éducatrice sociale:

+{% for c in object.competences.all %}- {{c.libelle}} ({{c.code}})
+{% if user.is_authenticated %} +{% for sc in c.souscompetence_set.all %}    - {{sc.libelle}}
{%endfor %}{% endif %}{% endfor %}
Ressources à acquérir{% for c in object.ressource_set.all %}- {{c}}
{% endfor %}
Objectifs à atteindre{% for c in object.objectif_set.all %}- {{c}}
{% endfor %}
Contenu{{object.contenu|linebreaksbr}}
Evaluation{{object.evaluation|linebreaksbr}}
Type{{object.type}}
Semestre{{object.semestre}}
Travail perso.{{object.travail_perso}} heures
Responsable{{object.processus.domaine.responsable}} ({{object.processus.domaine.responsable.email}})
Responsable{{object.processus.domaine.responsable.descr}}
- +

Imprimer en PDF

{% endblock %} diff --git a/templates/cms/periodes.html b/templates/cms/periodes.html index 8609849..7ad341a 100644 --- a/templates/cms/periodes.html +++ b/templates/cms/periodes.html @@ -1,47 +1,59 @@ {% extends "./base_site.html" %} {% load i18n static %} -{% block extrastyle %}{{ block.super }} -{% endblock %} - {% block coltype %}colMS{% endblock %} -{% block bodyclass %}{{ block.super }} dashboard{% endblock %} - -{% block breadcrumbs %}{% endblock %} {% block content %}

Périodes de formation

- + + + + + + + + + +
Semestre 1{{tot1.sem1__sum}}h.
Semestre 1{{tot1.sem1__sum}}h.Semestre 2{{tot2.sem2__sum}}h.
{% for s in sem1 %} {% endfor %} - +
{{s}}{{s.sem1}} h.
Semestre 2{{tot2.sem2__sum}}h.
+
+ {% for s in sem2 %} {% endfor %} - +
{{s}}{{s.sem2}} h.
Semestre 3{{tot3.sem3__sum}}h.
+
Semestre 3{{tot3.sem3__sum}}h.Semestre 4{{tot4.sem4__sum}}h.
{% for s in sem3 %} {% endfor %} - +
{{s}}{{s.sem3}} h.
Semestre 4{{tot4.sem4__sum}}h.
{% for s in sem4 %} {% endfor %} - +
{{s}}{{s.sem4}} h.
Semestre 5{{tot5.sem5__sum}}h.
Semestre 5{{tot5.sem5__sum}}h.Semestre 6{{tot6.sem6__sum}}h.
{% for s in sem5 %} {% endfor %} - +
{{s}}{{s.sem5}} h.
Semestre 6{{tot6.sem6__sum}}h.
+ {% for s in sem6 %} {% endfor %}
{{s}}{{s.sem6}} h.
-{{tot.tot__sum}} +
+
+Total des périodes de cours: {{tot.periode_presentiel__sum}} heures + +

+Imprimer en PDF
{% endblock %} diff --git a/templates/cms/processus_detail.html b/templates/cms/processus_detail.html index bc89180..bfeb01a 100644 --- a/templates/cms/processus_detail.html +++ b/templates/cms/processus_detail.html @@ -13,7 +13,7 @@

{{object}}

-
Description{{object.description}}
Compétences visées

L'éducateur social, l'éducatrice sociale

+
Compétences visées

L'éducateur social, l'éducatrice sociale:

{% for m in object.module_set.all %}{% for c in m.competences.all %} - {{c.libelle}} ({{c.code}})
{% endfor %}{% endfor %}
Domaine{{object.domaine.url|safe}}