Add number of books

This commit is contained in:
Gabriel Augendre 2019-06-28 15:08:40 +02:00
parent 0d900de02c
commit a8d0c18b20
1 changed files with 11 additions and 1 deletions

View File

@ -26,9 +26,15 @@ class TeacherAdmin(ExportMixin, admin.ModelAdmin):
actions = [send_link]
class TeacherResource(resources.ModelResource):
class Meta:
model = Teacher
fields = ('first_name', 'last_name', 'email', 'phone_number')
@admin.register(Level)
class LevelAdmin(admin.ModelAdmin):
list_display = ['name', 'order', 'consumable_count', 'consumable_price']
list_display = ['name', 'order', 'book_count', 'consumable_count', 'consumable_price']
list_editable = ['order']
list_display_links = ['name']
@ -36,6 +42,10 @@ class LevelAdmin(admin.ModelAdmin):
return obj.consumable_count
consumable_count.short_description = 'Nombre de consommable(s)'
def book_count(self, obj: Level):
return obj.book_set.count()
book_count.short_description = 'Nombre de livre(s)'
def consumable_price(self, obj: Level):
return f'{obj.consumable_price:.2f}'
consumable_price.short_description = 'Coût des consommables'