Formatting fixes

This commit is contained in:
alazo 2017-08-08 15:21:10 +02:00 committed by Claude Paroz
parent fdf81eb95f
commit e08356e6eb
3 changed files with 25 additions and 31 deletions

View file

@ -216,7 +216,7 @@ class Corporation(models.Model):
class Meta:
verbose_name = "Institution"
ordering = ('name',)
unique_together=(('name', 'city'),)
unique_together = (('name', 'city'),)
def __str__(self):
sect = ' (%s)' % self.sector if self.sector else ''
@ -352,7 +352,7 @@ class Training(models.Model):
IMPUTATION_CHOICES = (
('ASAFE', 'ASAFE'),
('ASEFE', 'ASEFE'),
('ASSCFE','ASSCFE'),
('ASSCFE', 'ASSCFE'),
('EDEpe', 'EDEpe'),
('EDEps', 'EDEps'),
('EDE', 'EDE'),
@ -360,6 +360,7 @@ IMPUTATION_CHOICES = (
('CAS-FPP', 'CAS-FPP'),
)
class Course(models.Model):
"""Cours et mandats attribués aux enseignants"""
teacher = models.ForeignKey(Teacher, blank=True, null=True,

View file

@ -13,9 +13,7 @@ from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_RIGHT
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_mandat = PS(name='CORPS', fontName='Helvetica', fontSize=8, alignment = TA_LEFT, leftIndent=30)
style_bold = PS(name='CORPS', fontName='Helvetica-Bold', fontSize=10, alignment = TA_LEFT)
style_title = PS(name='CORPS', fontName='Helvetica-Bold', fontSize=12, alignment = TA_LEFT, spaceBefore=2*cm)
style_adress = PS(name='CORPS', fontName='Helvetica', fontSize=10, alignment = TA_LEFT, leftIndent=280)
@ -43,37 +41,29 @@ class ChargeSheetPDF(SimpleDocTemplate):
data = [[settings.CHARGE_SHEET_TITLE]]
data.append(["Report de l'année précédente",
'{0:3d} pér.'.format(self.teacher.previous_report) ])
data.append(['Mandats',
'{0:3d} pér.'.format(activities['tot_mandats'])])
data.append(["Report de l'année précédente", '{0:3d} pér.'.format(self.teacher.previous_report)])
data.append(['Mandats', '{0:3d} pér.'.format(activities['tot_mandats'])])
for act in activities['mandats']:
data.append([' * {0} ({1} pér.)'.format(act.subject, act.period)])
data.append(['Enseignement (coef.2)',
'{0:3d} pér.'.format(activities['tot_ens'])])
data.append(['Formation continue et autres tâches',
'{0:3d} pér.'.format(activities['tot_formation'])])
data.append(['Total des heures travaillées',
'{0:3d} pér.'.format(activities['tot_trav']),
data.append(['Enseignement (coef.2)', '{0:3d} pér.'.format(activities['tot_ens'])])
data.append(['Formation continue et autres tâches', '{0:3d} pér.'.format(activities['tot_formation'])])
data.append(['Total des heures travaillées', '{0:3d} pér.'.format(activities['tot_trav']),
'{0:4.1f} %'.format(activities['tot_trav']/21.50)])
data.append(['Total des heures payées',
'{0:3d} pér.'.format(activities['tot_paye']),
data.append(['Total des heures payées', '{0:3d} pér.'.format(activities['tot_paye']),
'{0:4.1f} %'.format(activities['tot_paye']/21.50)])
data.append(["Report à l'année prochaine",
'{0:3d} pér.'.format(activities['report'])])
data.append(["Report à l'année prochaine", '{0:3d} pér.'.format(activities['report'])])
t = Table(data, colWidths=[12*cm, 2*cm, 2*cm] )
t.setStyle(TableStyle([('ALIGN',(1,0),(-1,-1),'RIGHT'),
('FONT', (0,0),(-1,0), 'Helvetica-Bold'),
('LINEBELOW', (0,0),(-1,0), 0.5, colors.black),
('LINEABOVE', (0,-3) ,(-1,-1), 0.5, colors.black),
('FONT', (0,-2),(-1,-2), 'Helvetica-Bold'),
t = Table(data, colWidths=[12*cm, 2*cm, 2*cm])
t.setStyle(TableStyle([('ALIGN', (1, 0), (-1, -1), 'RIGHT'),
('FONT', (0, 0), (-1, 0), 'Helvetica-Bold'),
('LINEBELOW', (0, 0), (-1, 0), 0.5, colors.black),
('LINEABOVE', (0, -3) ,(-1, -1), 0.5, colors.black),
('FONT', (0, -2), (-1, -2), 'Helvetica-Bold'),
]))
t.hAlign = TA_CENTER
self.story.append(t)
self.story.append(Spacer(0, 2*cm))
d = 'La Chaux-de-Fonds, le {0}'.format(date.today().strftime('%d.%m.%y'))
self.story.append(Paragraph(d, style_normal))

View file

@ -423,7 +423,7 @@ class HPImportView(ImportViewBase):
def import_data(self, up_file):
obj_created = obj_modified = 0
#Pour accélérer la recherche
# Pour accélérer la recherche
profs = {}
for t in Teacher.objects.all():
profs[t.__str__()] = t
@ -440,9 +440,9 @@ class HPImportView(ImportViewBase):
}
obj, created = Course.objects.get_or_create(
teacher = defaults['teacher'],
subject = defaults['subject'],
public = defaults['public'])
teacher=defaults['teacher'],
subject=defaults['subject'],
public=defaults['public'])
period = int(float(line['TOTAL']))
if created:
@ -486,6 +486,7 @@ EXPORT_FIELDS = [
('Courriel contact - copie', None),
]
NON_ATTR_EXPORT_FIELDS = [
('Filière', 'period__section__name'),
('Nom du stage', 'period__title'),
@ -505,6 +506,7 @@ NON_ATTR_EXPORT_FIELDS = [
('Courriel contact - copie', None),
]
def stages_export(request, scope=None):
period_filter = request.GET.get('period')
non_attributed = bool(int(request.GET.get('non_attr', 0)))
@ -590,6 +592,7 @@ IMPUTATIONS_EXPORT_FIELDS = [
'ASA', 'ASSC', 'ASE', 'MP', 'EDEpe', 'EDEps', 'EDS', 'CAS-FPP', 'Direction'
]
def imputations_export(request):
wb = Workbook()
ws = wb.get_active_sheet()
@ -613,10 +616,10 @@ def imputations_export(request):
ws.cell(row=row_idx, column=9).value = 'Charge globale'
ws.cell(row=row_idx, column=10).value = '{0:.2f}'.format(activities['tot_paye']/21.50)
ws.cell(row=row_idx, column=11).value = teacher.next_report
col_idx=12
col_idx = 12
for k, v in imputations.items():
ws.cell(row=row_idx, column=col_idx).value = v
col_idx+=1
col_idx += 1
response = HttpResponse(
save_virtual_workbook(wb),