Ultron/ultron/people/admin.py

42 lines
925 B
Python
Raw Normal View History

2021-12-09 16:53:44 +01:00
from django.contrib import admin
from .models import Gymnast
class GymnastAdmin(admin.ModelAdmin):
model = Gymnast
2022-02-06 15:44:55 +01:00
def last_name(self, obj):
return obj.user.last_name
def first_name(self, obj):
return obj.user.first_name
def email(self, obj):
return obj.user.email
def is_active(self, obj):
return obj.user.is_active
2021-12-09 16:53:44 +01:00
fields = (
2022-09-07 12:21:22 +02:00
"last_name",
"first_name",
2022-02-06 15:44:55 +01:00
"user",
2021-12-19 09:30:51 +01:00
"birthdate",
"gender",
2022-09-07 12:21:22 +02:00
# "email",
"club",
"email_trainer",
2021-12-19 09:30:51 +01:00
"trainings_by_week",
"hours_by_week",
2022-09-07 12:21:22 +02:00
"informations",
2021-12-19 09:30:51 +01:00
"is_active",
2021-12-09 16:53:44 +01:00
)
2021-12-19 09:30:51 +01:00
list_display = ("last_name", "first_name", "age", "is_active") # , 'club'
2022-02-06 15:44:55 +01:00
list_filter = ("gender", "user__is_active") # , 'club'
2021-12-19 09:30:51 +01:00
search_fields = ("last_name", "first_name")
# autocomplete_fields = ('club',)
2021-12-09 16:53:44 +01:00
2021-12-19 09:30:51 +01:00
2021-12-09 16:53:44 +01:00
admin.site.register(Gymnast, GymnastAdmin)