From da46061a5a84f4ab80bce52aaaf95ef01bb6e65b Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Mon, 10 Jul 2023 17:22:41 +0200 Subject: [PATCH] Ajout PDF infos CorpContact --- common/urls.py | 1 + stages/admin.py | 8 ++++++-- stages/pdf.py | 10 ++++++++++ stages/views/__init__.py | 12 ++++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/common/urls.py b/common/urls.py index 5598c31..ccedb42 100644 --- a/common/urls.py +++ b/common/urls.py @@ -48,6 +48,7 @@ urlpatterns = [ name='print-supervisor-compens-form'), path('exam//indemn//', views.PrintCompensationForm.as_view(), name='print-compens-form'), + path('expert//info/', views.PrintExpertInfoForm.as_view(), name='print-supervisor-info'), # Qualification EDE path('student_ede//send_convocation/', views.StudentConvocationExaminationView.as_view(), diff --git a/stages/admin.py b/stages/admin.py index 483356b..3d8f639 100644 --- a/stages/admin.py +++ b/stages/admin.py @@ -163,7 +163,9 @@ class StudentAdmin(admin.ModelAdmin): list_filter = (('archived', ArchivedListFilter), ('klass', KlassRelatedListFilter)) search_fields = ('last_name', 'first_name', 'pcode', 'city', 'klass__name') autocomplete_fields = ('corporation', 'instructor', 'instructor2', 'supervisor', 'mentor') - readonly_fields = ('report_sem1_sent', 'report_sem2_sent', 'mentor_indemn', 'superv_indemn') + readonly_fields = ( + 'report_sem1_sent', 'report_sem2_sent', 'mentor_indemn', 'superv_indemn', + ) fieldsets = [ (None, { 'fields': ( @@ -202,8 +204,10 @@ class StudentAdmin(admin.ModelAdmin): if obj is None or not obj.supervisor: return '-' return format_html( - 'Indemnité au superviseur', + 'Indemnité au superviseur ' + 'Fiche info', reverse('print-supervisor-compens-form', args=[obj.pk]), + reverse('print-supervisor-info', args=[obj.supervisor.pk]), ) superv_indemn.short_description = 'Indemnité' diff --git a/stages/pdf.py b/stages/pdf.py index 09a6ea9..2d3d2c0 100644 --- a/stages/pdf.py +++ b/stages/pdf.py @@ -557,6 +557,16 @@ class CompensationPDFForm(CompensationForm, EpcBaseDocTemplate): self.build(self.story) +class ExpertInfoForm(CompensationPDFForm): + def __init__(self, out, contact, **kwargs): + self.contact = contact + super().__init__(out, **kwargs) + + def produce(self): + self.add_private_data(self.contact) + self.build(self.story) + + class MentorCompensationPdfForm(CompensationPDFForm): mandat_type = CompensationPDFForm.MENTOR_MANDAT mandat_template = "Mentoring de {student_civility} {student_fullname}, classe {klass}" diff --git a/stages/views/__init__.py b/stages/views/__init__.py index ee96f57..ea39698 100644 --- a/stages/views/__init__.py +++ b/stages/views/__init__.py @@ -571,6 +571,18 @@ class PrintCompensationForm(PDFBaseView): return super().get(request, *args, **kwargs) +class PrintExpertInfoForm(PDFBaseView): + pdf_class = pdf.ExpertInfoForm + + def get_object(self): + return CorpContact.objects.get(pk=self.kwargs['pk']) + + def filename(self, obj): + return slugify( + '{0}_{1}'.format(obj.last_name, obj.first_name) + ) + f'_Info.pdf' + + class PrintExpertEDSCompensationForm(PrintExpertEDECompensationForm): """ Imprime le PDF à envoyer à l'expert EDS en accompagnement du