/
admin.py
51 lines (37 loc) · 1.41 KB
/
admin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from django.contrib import admin
from player.tenhou.models import TenhouAggregatedStatistics, TenhouStatistics
class TenhouStatisticsAdmin(admin.ModelAdmin):
list_display = [
"player",
"player_city",
"tenhou_object",
"rank",
"lobby",
"played_games",
"average_place",
"last_played_date",
]
list_filter = ["lobby", "stat_type"]
def player(self, obj):
return obj.tenhou_object.player.full_name
def player_city(self, obj):
return obj.tenhou_object.player.city
def rank(self, obj):
return obj.tenhou_object.get_rank_display()
rank.short_description = "Rank"
rank.admin_order_field = "tenhou_object__rank"
def last_played_date(self, obj):
return obj.tenhou_object.last_played_date
class TenhouAggregatedStatisticsAdmin(admin.ModelAdmin):
list_display = ["player", "tenhou_object", "rank", "game_players", "played_games", "pt"]
list_filter = ["tenhou_object__is_active"]
search_fields = [
"tenhou_object__player__first_name_ru",
"tenhou_object__player__last_name_ru",
"tenhou_object__player__first_name_en",
"tenhou_object__player__last_name_en",
]
def player(self, obj):
return obj.tenhou_object.player
admin.site.register(TenhouStatistics, TenhouStatisticsAdmin)
admin.site.register(TenhouAggregatedStatistics, TenhouAggregatedStatisticsAdmin)