Add number of books
This commit is contained in:
parent
0d900de02c
commit
a8d0c18b20
1 changed files with 11 additions and 1 deletions
|
@ -26,9 +26,15 @@ class TeacherAdmin(ExportMixin, admin.ModelAdmin):
|
||||||
actions = [send_link]
|
actions = [send_link]
|
||||||
|
|
||||||
|
|
||||||
|
class TeacherResource(resources.ModelResource):
|
||||||
|
class Meta:
|
||||||
|
model = Teacher
|
||||||
|
fields = ('first_name', 'last_name', 'email', 'phone_number')
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Level)
|
@admin.register(Level)
|
||||||
class LevelAdmin(admin.ModelAdmin):
|
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_editable = ['order']
|
||||||
list_display_links = ['name']
|
list_display_links = ['name']
|
||||||
|
|
||||||
|
@ -36,6 +42,10 @@ class LevelAdmin(admin.ModelAdmin):
|
||||||
return obj.consumable_count
|
return obj.consumable_count
|
||||||
consumable_count.short_description = 'Nombre de consommable(s)'
|
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):
|
def consumable_price(self, obj: Level):
|
||||||
return f'{obj.consumable_price:.2f}€'
|
return f'{obj.consumable_price:.2f}€'
|
||||||
consumable_price.short_description = 'Coût des consommables'
|
consumable_price.short_description = 'Coût des consommables'
|
||||||
|
|
Loading…
Reference in a new issue