Ajout fiche indemnité pour superviseur
This commit is contained in:
parent
820f7a3254
commit
f6cc953014
4 changed files with 26 additions and 6 deletions
|
|
@ -163,7 +163,7 @@ 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')
|
||||
readonly_fields = ('report_sem1_sent', 'report_sem2_sent', 'mentor_indemn', 'superv_indemn')
|
||||
fieldsets = [
|
||||
(None, {
|
||||
'fields': (
|
||||
|
|
@ -179,7 +179,7 @@ class StudentAdmin(admin.ModelAdmin):
|
|||
("Procédure de qualification", {
|
||||
'classes': ['collapse'],
|
||||
'fields': (
|
||||
('supervisor', 'supervision_attest_received'),
|
||||
('supervisor', 'supervision_attest_received', 'superv_indemn'),
|
||||
('subject', 'title'),
|
||||
('training_referent', 'referent'),
|
||||
('mentor', 'mentor_indemn'),
|
||||
|
|
@ -198,6 +198,15 @@ class StudentAdmin(admin.ModelAdmin):
|
|||
)
|
||||
mentor_indemn.short_description = 'Indemnité'
|
||||
|
||||
def superv_indemn(self, obj):
|
||||
if obj is None or not obj.supervisor:
|
||||
return '-'
|
||||
return format_html(
|
||||
'<a class="button" href="{}">Indemnité au superviseur</a>',
|
||||
reverse('print-supervisor-compens-form', args=[obj.pk]),
|
||||
)
|
||||
superv_indemn.short_description = 'Indemnité'
|
||||
|
||||
def get_inlines(self, request, obj=None):
|
||||
if obj is None:
|
||||
return []
|
||||
|
|
|
|||
|
|
@ -570,6 +570,14 @@ class MentorCompensationPdfForm(CompensationPDFForm):
|
|||
super().__init__(out)
|
||||
|
||||
|
||||
class SupervisorCompensationPdfForm(MentorCompensationPdfForm):
|
||||
mandat_template = "Supevision de {student_civility} {student_fullname}, classe {klass}"
|
||||
|
||||
def __init__(self, out, student):
|
||||
super().__init__(out, student)
|
||||
self.expert = student.supervisor
|
||||
|
||||
|
||||
class EntretienProfCompensationPdfForm(CompensationPDFForm):
|
||||
mandat_type = CompensationPDFForm.EXPERT_MANDAT
|
||||
mandat_template = "Expert·e aux examens finaux"
|
||||
|
|
|
|||
|
|
@ -541,26 +541,27 @@ class PrintCompensationForm(PDFBaseView):
|
|||
def pdf_class(self):
|
||||
return {
|
||||
'mentor': pdf.MentorCompensationPdfForm,
|
||||
'supervisor': pdf.SupervisorCompensationPdfForm,
|
||||
'ep': pdf.EntretienProfCompensationPdfForm,
|
||||
'sout': pdf.SoutenanceCompensationPdfForm,
|
||||
}.get(self.typ)
|
||||
|
||||
def filename(self, obj):
|
||||
student = obj if self.typ == 'mentor' else obj.student
|
||||
student = obj if self.typ in ('mentor', 'supervisor') else obj.student
|
||||
return slugify(
|
||||
'{0}_{1}'.format(student.last_name, student.first_name)
|
||||
) + f'_Indemn_{self.typ}.pdf'
|
||||
|
||||
def get_object(self):
|
||||
model = Student if self.typ == 'mentor' else Examination
|
||||
model = Student if self.typ in ('mentor', 'supervisor') else Examination
|
||||
return model.objects.get(pk=self.kwargs['pk'])
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
self.typ = self.kwargs['typ']
|
||||
if self.typ == 'mentor':
|
||||
if self.typ in ('mentor', 'supervisor'):
|
||||
student = self.get_object()
|
||||
if not student.mentor:
|
||||
messages.error(request, "Aucun mentor n’est attribué à cet étudiant")
|
||||
messages.error(request, "Aucun mentor/superviseur n’est attribué à cet étudiant")
|
||||
return redirect(reverse("admin:stages_student_change", args=(student.pk,)))
|
||||
else:
|
||||
exam = self.get_object()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue