Add test2
This commit is contained in:
parent
326def22e5
commit
729bc1bea1
6 changed files with 39 additions and 93 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -3,6 +3,7 @@ common/local_settings.py
|
||||||
/media/
|
/media/
|
||||||
/static/
|
/static/
|
||||||
*.sqlite3
|
*.sqlite3
|
||||||
|
*.json
|
||||||
db.eds
|
db.eds
|
||||||
db.*
|
db.*
|
||||||
*.sql
|
*.sql
|
||||||
|
|
|
||||||
|
|
@ -6,25 +6,9 @@ Created on 17 nov. 2012
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.http.response import HttpResponse
|
|
||||||
from django.conf import settings
|
|
||||||
|
|
||||||
from tinymce import models as tinymce_models
|
from tinymce import models as tinymce_models
|
||||||
|
|
||||||
from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, Image
|
|
||||||
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)
|
|
||||||
|
|
||||||
|
|
||||||
CHOIX_TYPE_SAVOIR = (
|
CHOIX_TYPE_SAVOIR = (
|
||||||
('Savoir', 'savoir'),
|
('Savoir', 'savoir'),
|
||||||
|
|
@ -97,7 +81,6 @@ class Module(models.Model):
|
||||||
situation = models.TextField()
|
situation = models.TextField()
|
||||||
evaluation = models.TextField()
|
evaluation = models.TextField()
|
||||||
contenu = models.TextField()
|
contenu = models.TextField()
|
||||||
#periode_presentiel = models.IntegerField(verbose_name='Présentiel')
|
|
||||||
travail_perso = models.IntegerField(verbose_name='Travail personnel')
|
travail_perso = models.IntegerField(verbose_name='Travail personnel')
|
||||||
pratique_prof = models.IntegerField(default=0, verbose_name='Pratique prof.')
|
pratique_prof = models.IntegerField(default=0, verbose_name='Pratique prof.')
|
||||||
didactique = models.TextField()
|
didactique = models.TextField()
|
||||||
|
|
@ -195,69 +178,3 @@ class UploadDoc(models.Model):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.titre
|
return self.titre
|
||||||
|
|
||||||
"""
|
|
||||||
class PDFResponse(HttpResponse):
|
|
||||||
|
|
||||||
def __init__(self, filename, title='', portrait=True):
|
|
||||||
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.png', width=520, height=75)
|
|
||||||
image.hAlign = TA_LEFT
|
|
||||||
self.story.append(image)
|
|
||||||
data = list(['Filières EDS', title])
|
|
||||||
if portrait:
|
|
||||||
t = Table(data, colWidths=[8*cm, 8*cm])
|
|
||||||
else:
|
|
||||||
t = Table(data, colWidths=[11*cm, 11*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 = TA_LEFT
|
|
||||||
self.story.append(t)
|
|
||||||
|
|
||||||
|
|
||||||
class MyDocTemplate(SimpleDocTemplate):
|
|
||||||
|
|
||||||
def __init__(self, name):
|
|
||||||
SimpleDocTemplate.__init__(self, name, pagesize=A4, topMargin=0*cm)
|
|
||||||
self.fileName = name
|
|
||||||
self.PAGE_WIDTH = A4[0]
|
|
||||||
self.PAGE_HEIGHT = A4[1]
|
|
||||||
self.CENTRE_WIDTH = self.PAGE_WIDTH/2.0
|
|
||||||
self.CENTRE_HEIGHT = self.PAGE_HEIGHT/2.0
|
|
||||||
|
|
||||||
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*cm, leftMargin=2*cm)
|
|
||||||
self.fileName = name
|
|
||||||
self.PAGE_WIDTH = A4[1]
|
|
||||||
self.PAGE_HEIGHT = A4[0]
|
|
||||||
self.CENTRE_WIDTH = self.PAGE_WIDTH/2.0
|
|
||||||
self.CENTRE_HEIGHT = self.PAGE_HEIGHT/2.0
|
|
||||||
|
|
||||||
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()
|
|
||||||
"""
|
|
||||||
|
|
|
||||||
|
|
@ -227,7 +227,6 @@ class FormationPlanPdf(EpcBaseDocTemplate):
|
||||||
return Preformatted(el1, style_normal, maxLineLength=length)
|
return Preformatted(el1, style_normal, maxLineLength=length)
|
||||||
|
|
||||||
def produce(self, domain, process):
|
def produce(self, domain, process):
|
||||||
print(domain[0], process[0])
|
|
||||||
data = [
|
data = [
|
||||||
['Domaines', 'Processus', 'Sem1', 'Sem2', 'Sem3', 'Sem4', 'Sem5', 'Sem6'],
|
['Domaines', 'Processus', 'Sem1', 'Sem2', 'Sem3', 'Sem4', 'Sem5', 'Sem6'],
|
||||||
[self.formating(domain[0]), self.formating(process[0], 60), 'M01', '', '', '', '', ''],
|
[self.formating(domain[0]), self.formating(process[0], 60), 'M01', '', '', '', '', ''],
|
||||||
|
|
|
||||||
35
cms/tests.py
35
cms/tests.py
|
|
@ -1,12 +1,19 @@
|
||||||
|
import os
|
||||||
|
|
||||||
|
from django.db.models import Sum
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.core import mail
|
from django.core import mail
|
||||||
from django.test import TestCase, override_settings
|
|
||||||
|
from django.test import TestCase, Client
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
# Create your tests here.
|
# Create your tests here.
|
||||||
|
from cms.models import Domaine, Processus, Module
|
||||||
|
|
||||||
|
|
||||||
class PdfTestCase(TestCase):
|
class PdfTestCase(TestCase):
|
||||||
|
fixtures = ['enseignant.json', 'domaine.json', 'processus.json', 'module.json']
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
|
|
@ -14,13 +21,33 @@ class PdfTestCase(TestCase):
|
||||||
User.objects.create_superuser('me', 'me@example.org', 'mepassword')
|
User.objects.create_superuser('me', 'me@example.org', 'mepassword')
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
self.client = Client()
|
||||||
self.client.login(username='me', password='mepassword')
|
self.client.login(username='me', password='mepassword')
|
||||||
|
|
||||||
|
def test_index(self):
|
||||||
|
response = self.client.get('')
|
||||||
|
self.assertGreater(len(response.content), 200)
|
||||||
|
|
||||||
def test_plan_pdf(self):
|
def test_plan_pdf(self):
|
||||||
response = self.client.get(reverse('plan-pdf'))
|
response = self.client.get(reverse('plan-pdf'))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
response['Content-Disposition'],
|
response['content-disposition'],
|
||||||
'attachment; filename="plan_formation.pdf"'
|
'attachment; filename="EDS_plan_formation.pdf"'
|
||||||
)
|
)
|
||||||
self.assertEqual(response['Content-Type'], 'application/pdf')
|
self.assertEqual(response['content-type'], 'application/pdf')
|
||||||
self.assertGreater(len(response.content), 200)
|
self.assertGreater(len(response.content), 200)
|
||||||
|
|
||||||
|
def test_periode_presentiel(self):
|
||||||
|
tot = 0
|
||||||
|
for m in Module.objects.all():
|
||||||
|
tot += m.total_presentiel
|
||||||
|
tot = Module.objects.aggregate(Sum('total_presentiel'))
|
||||||
|
self.assertEqual(tot, 1200)
|
||||||
|
|
||||||
|
def test_periode_pratique(self):
|
||||||
|
tot = Module.objects.aggregate(Sum('pratique_prof'))
|
||||||
|
self.assertEqual(tot['pratique_prof__sum'], 1200)
|
||||||
|
|
||||||
|
def test_periode_travail_perso(self):
|
||||||
|
tot = Module.objects.aggregate(Sum('travail_perso'))
|
||||||
|
self.assertEqual(tot['travail_perso__sum'], 1200)
|
||||||
|
|
@ -6,11 +6,13 @@ Created on 4 déc. 2012
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from django.views.generic import ListView, TemplateView, DetailView
|
|
||||||
from django.db.models import F, Sum, Q
|
from django.db.models import F, Sum
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
|
from django.views.generic import ListView, TemplateView, DetailView
|
||||||
|
|
||||||
from cms.pdf import PeriodSemesterPdf, ModuleDescriptionPdf, FormationPlanPdf
|
from cms.pdf import PeriodSemesterPdf, ModuleDescriptionPdf, FormationPlanPdf
|
||||||
|
|
||||||
from cms.models import (
|
from cms.models import (
|
||||||
Domaine, Processus, Module, Competence, Concept, UploadDoc
|
Domaine, Processus, Module, Competence, Concept, UploadDoc
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
<div id="content-main">
|
<div id="content-main">
|
||||||
<h1>Liste des compétences du PEC avec les modules correspondants</h1>
|
<h1>Liste des compétences du PEC avec les modules correspondants</h1>
|
||||||
<table border="0">
|
<table border="0">
|
||||||
{% for c in object_list %}
|
{% for competence in object_list %}
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="3">{{ c }}</td>
|
<td colspan="3">{{ competence }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th width="10px"> </th>
|
<th width="10px"> </th>
|
||||||
<td colspan="2"><a href=" {% url 'module-detail' c.module.id %}">{{ c.module }}</a></td>
|
<td colspan="2"><a href=" {% url 'module-detail' competence.module.id %}">{{ competence.module }}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue