Ajout PDF infos CorpContact

This commit is contained in:
Claude Paroz 2023-07-10 17:22:41 +02:00
parent f6cc953014
commit da46061a5a
4 changed files with 29 additions and 2 deletions

View file

@ -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(
'<a class="button" href="{}">Indemnité au superviseur</a>',
'<a class="button" href="{}">Indemnité au superviseur</a>&nbsp;'
'<a class="button" href="{}">Fiche info</a>',
reverse('print-supervisor-compens-form', args=[obj.pk]),
reverse('print-supervisor-info', args=[obj.supervisor.pk]),
)
superv_indemn.short_description = 'Indemnité'

View file

@ -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}"

View file

@ -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