Another Step in the Quest to clean up the code base.

This commit is contained in:
2017-09-08 07:19:50 +02:00
parent 8f4bdec701
commit 6e2240ed5f
229 changed files with 1915 additions and 15175 deletions

View File

@@ -1,18 +1,13 @@
# -*- encoding: utf-8 -*-
""" Adds management of the mahong ranking system to the admin interface. """
"""
Created on 19.09.2011
@author: christian
"""
# import stuff we need from django
from django.contrib import admin
from django.utils.translation import ugettext as _
from . import models, set_dirty
def recalculate(modeladmin, request, queryset):
def recalculate(modeladmin, request, queryset): # Ignore PyLintBear (W0613)
""" An admin action to force recalculation of the selected items. """
if isinstance(modeladmin, HanchanAdmin):
for hanchan in queryset:
hanchan.save()
@@ -31,7 +26,8 @@ def recalculate(modeladmin, request, queryset):
recalculate.short_description = _("Recalculate")
def confirm(modeladmin, request, queryset):
def confirm(modeladmin, request, queryset): # Ignore PyLintBear (W0613)
"""An admin action to quickly set selected hanchans to confirmed. """
for hanchan in queryset:
hanchan.confirmed = True
hanchan.save()
@@ -40,7 +36,8 @@ def confirm(modeladmin, request, queryset):
confirm.short_description = _("Confirm")
def unconfirm(modeladmin, request, queryset):
def unconfirm(modeladmin, request, queryset): # Ignore PyLintBear (W0613)
"""An admin action to quickly set selected hanchans to unconfirmed. """
for hanchan in queryset:
hanchan.confirmed = False
hanchan.save()
@@ -50,6 +47,7 @@ unconfirm.short_description = _('Set unconfirmed')
class EventRankingAdmin(admin.ModelAdmin):
""" Lists the Event Rankings and allows to recalculate them. """
list_filter = ['event']
list_display = ('placement', 'user', 'event', 'avg_placement', 'avg_score',
'hanchan_count', 'good_hanchans', 'won_hanchans')
@@ -58,6 +56,7 @@ class EventRankingAdmin(admin.ModelAdmin):
class HanchanAdmin(admin.ModelAdmin):
""" To administrate the stored Hanchans. """
actions = [recalculate, confirm, unconfirm]
date_hierarchy = 'start'
list_filter = ('season', 'event', 'confirmed')
@@ -82,6 +81,7 @@ class HanchanAdmin(admin.ModelAdmin):
class KyuDanAdmin(admin.ModelAdmin):
""" Lists the Kyu/dan Rankings and allows to recalculate them. """
actions = [recalculate]
list_display = ('user', 'kyu', 'kyu_points', 'dan', 'dan_points',
'hanchan_count')
@@ -92,13 +92,15 @@ class KyuDanAdmin(admin.ModelAdmin):
'classes': ('grp-collapse grp-open',),
}),
('Frühere Aufzeichnungen', {
'fields': ('legacy_date', 'legacy_hanchan_count', ('legacy_kyu_points', 'legacy_dan_points')),
'fields': ('legacy_date', 'legacy_hanchan_count',
('legacy_kyu_points', 'legacy_dan_points')),
'classes': ('grp-collapse grp-closed',),
}),
)
class SeasonRankingAdmin(admin.ModelAdmin):
""" Lists the Season Rankings and allows to recalculate them. """
actions = [recalculate]
list_display = ('placement', 'season', 'user', 'avg_placement',
'avg_score', 'hanchan_count', 'good_hanchans',
@@ -108,6 +110,7 @@ class SeasonRankingAdmin(admin.ModelAdmin):
class LadderSeasonAdmin(admin.ModelAdmin):
""" Seasons will be generated automaticly, but you can examine them here."""
actions = [recalculate]
list_display = ('name', 'start', 'end')