-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Ladder Entries view and Django Admin Customizations. (#33)
* Added Ladder Entries Page. * isort * Added some admin panel customization.
- Loading branch information
Showing
38 changed files
with
431 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
""" CombatLog admin """ | ||
|
||
from django.contrib import admin | ||
from django.db.models import JSONField | ||
from django_json_widget.widgets import JSONEditorWidget | ||
|
||
from .models import CombatLog, Metadata | ||
|
||
admin.site.register(CombatLog) | ||
admin.site.register(Metadata) | ||
|
||
|
||
@admin.register(Metadata) | ||
class MetadataAdmin(admin.ModelAdmin): | ||
formfield_overrides = { | ||
JSONField: {"widget": JSONEditorWidget}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,55 @@ | ||
""" CombatLog admin """ | ||
|
||
from django.contrib import admin | ||
from django.db.models import JSONField | ||
from django_json_widget.widgets import JSONEditorWidget | ||
|
||
from .models import Ladder, LadderEntry, Variant | ||
|
||
admin.site.register(Ladder) | ||
admin.site.register(LadderEntry) | ||
admin.site.register(Variant) | ||
|
||
|
||
@admin.register(LadderEntry) | ||
class LadderEntryAdmin(admin.ModelAdmin): | ||
list_display = [ | ||
"player", | ||
"ladder__name", | ||
"ladder__difficulty", | ||
"ladder__variant__name", | ||
"dps", | ||
"damage", | ||
"combat_time", | ||
"build", | ||
] | ||
formfield_overrides = { | ||
JSONField: {"widget": JSONEditorWidget}, | ||
} | ||
|
||
@admin.display(ordering="ladder__name") | ||
def ladder__name(self, obj): | ||
return obj.ladder.name | ||
|
||
@admin.display(ordering="ladder__difficulty") | ||
def ladder__difficulty(self, obj): | ||
return obj.ladder.difficulty | ||
|
||
@admin.display(ordering="ladder__variant__name") | ||
def ladder__variant__name(self, obj): | ||
return obj.ladder.variant.name | ||
|
||
@admin.display(ordering="data__DPS") | ||
def dps(self, obj): | ||
return int(obj.data.get("DPS")) | ||
|
||
@admin.display(ordering="data__total_damage") | ||
def damage(self, obj): | ||
return int(obj.data.get("total_damage")) | ||
|
||
@admin.display(ordering="data__combat_time") | ||
def combat_time(self, obj): | ||
return int(obj.data.get("combat_time")) | ||
|
||
@admin.display(ordering="data__build") | ||
def build(self, obj): | ||
return obj.data.get("build") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.