Add total logbook + logbook inline in teacher admin
This commit is contained in:
parent
b50dd1a619
commit
718ba80dba
3 changed files with 17 additions and 2 deletions
|
|
@ -85,14 +85,23 @@ class KlassAdmin(admin.ModelAdmin):
|
|||
inlines = [StudentInline]
|
||||
|
||||
|
||||
class LogBookInline(admin.TabularInline):
|
||||
model = LogBook
|
||||
ordering = ('input_date',)
|
||||
fields = ('start_date', 'end_date', 'reason', 'comment', 'nb_period')
|
||||
extra = 0
|
||||
|
||||
|
||||
class TeacherAdmin(admin.ModelAdmin):
|
||||
list_display = ('__str__', 'abrev', 'email', 'contract', 'rate', 'archived')
|
||||
list_display = ('__str__', 'abrev', 'email', 'contract', 'rate', 'total_logbook', 'archived')
|
||||
list_filter = (('archived', ArchivedListFilter), 'contract')
|
||||
fields = (('civility', 'last_name', 'first_name', 'abrev'),
|
||||
('birth_date', 'email', 'ext_id'),
|
||||
('contract', 'rate', 'archived'),
|
||||
('previous_report', 'next_report'))
|
||||
('previous_report', 'next_report', 'total_logbook'))
|
||||
readonly_fields = ('total_logbook',)
|
||||
actions = [print_charge_sheet]
|
||||
inlines = [LogBookInline]
|
||||
|
||||
|
||||
class StudentAdmin(admin.ModelAdmin):
|
||||
|
|
|
|||
|
|
@ -143,6 +143,10 @@ class Teacher(models.Model):
|
|||
|
||||
return (self.calc_activity(), imputations)
|
||||
|
||||
def total_logbook(self):
|
||||
return LogBook.objects.filter(teacher=self).aggregate(models.Sum('nb_period'))['nb_period__sum']
|
||||
total_logbook.short_description = 'Solde du carnet du lait'
|
||||
|
||||
|
||||
class LogBookReason(models.Model):
|
||||
name = models.CharField('Motif', max_length=50, unique=True)
|
||||
|
|
|
|||
|
|
@ -3,3 +3,5 @@ ul#main li { font-size: 14px; }
|
|||
|
||||
form#teacher_form input#id_abrev { width: 3em; }
|
||||
form#teacher_form input#id_civility { width: 5em; }
|
||||
|
||||
tr[id^=logbook_set-] td.original { visibility: hidden; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue