Ajout d'un filter par plateforme sur les jeux (Game)
This commit is contained in:
parent
4dfe7f4285
commit
64ef1b8086
@ -7,7 +7,7 @@ msgid ""
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: 0.1\n"
|
"Project-Id-Version: 0.1\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2018-01-15 20:10+0000\n"
|
"POT-Creation-Date: 2018-01-18 19:55+0000\n"
|
||||||
"PO-Revision-Date: 2018-01-15 21:10+0100\n"
|
"PO-Revision-Date: 2018-01-15 21:10+0100\n"
|
||||||
"Last-Translator: \n"
|
"Last-Translator: \n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
@ -17,23 +17,23 @@ msgstr ""
|
|||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
"X-Generator: Poedit 2.0.5\n"
|
"X-Generator: Poedit 2.0.5\n"
|
||||||
|
|
||||||
#: core/models.py:8 core/models.py:28
|
#: core/models.py:9 core/models.py:29
|
||||||
msgid "name"
|
msgid "name"
|
||||||
msgstr "nom"
|
msgstr "nom"
|
||||||
|
|
||||||
#: core/models.py:9
|
#: core/models.py:10
|
||||||
msgid "shortname"
|
msgid "shortname"
|
||||||
msgstr "nom court"
|
msgstr "nom court"
|
||||||
|
|
||||||
#: core/models.py:25
|
#: core/models.py:26
|
||||||
msgid "New"
|
msgid "New"
|
||||||
msgstr "Nouveau"
|
msgstr "Nouveau"
|
||||||
|
|
||||||
#: core/models.py:48 core/models.py:79
|
#: core/models.py:49 core/models.py:82
|
||||||
msgid "status"
|
msgid "status"
|
||||||
msgstr "état"
|
msgstr "état"
|
||||||
|
|
||||||
#: core/models.py:65
|
#: core/models.py:68
|
||||||
msgid "date"
|
msgid "date"
|
||||||
msgstr "date"
|
msgstr "date"
|
||||||
|
|
||||||
@ -73,22 +73,22 @@ msgstr "Progression de la figurine"
|
|||||||
msgid "state"
|
msgid "state"
|
||||||
msgstr "état"
|
msgstr "état"
|
||||||
|
|
||||||
#: games/admin.py:40
|
#: games/admin.py:40 games/models.py:15 games/models.py:29
|
||||||
|
msgid "platform"
|
||||||
|
msgstr "plateforme"
|
||||||
|
|
||||||
|
#: games/admin.py:63
|
||||||
msgid "Game Information"
|
msgid "Game Information"
|
||||||
msgstr "Information du jeu"
|
msgstr "Information du jeu"
|
||||||
|
|
||||||
#: games/admin.py:42
|
#: games/admin.py:65
|
||||||
msgid "Progress"
|
msgid "Progress"
|
||||||
msgstr "Progression"
|
msgstr "Progression"
|
||||||
|
|
||||||
#: games/admin.py:56
|
#: games/admin.py:79
|
||||||
msgid "Platform"
|
msgid "Platform"
|
||||||
msgstr "Plateforme"
|
msgstr "Plateforme"
|
||||||
|
|
||||||
#: games/models.py:15 games/models.py:29
|
|
||||||
msgid "platform"
|
|
||||||
msgstr "plateforme"
|
|
||||||
|
|
||||||
#: games/models.py:16
|
#: games/models.py:16
|
||||||
msgid "platforms"
|
msgid "platforms"
|
||||||
msgstr "plateformes"
|
msgstr "plateformes"
|
||||||
|
@ -33,9 +33,32 @@ class StatusFilter(admin.SimpleListFilter):
|
|||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
|
|
||||||
|
class PlatformFilter(admin.SimpleListFilter):
|
||||||
|
"""
|
||||||
|
Display Platform shortname.
|
||||||
|
"""
|
||||||
|
title = _('platform')
|
||||||
|
parameter_name = 'collection'
|
||||||
|
|
||||||
|
def lookups(self, request, model_admin):
|
||||||
|
"""
|
||||||
|
Get all platforms
|
||||||
|
"""
|
||||||
|
return [(x.id, x.shortname) for x in Platform.objects.all()]
|
||||||
|
|
||||||
|
def queryset(self, request, queryset):
|
||||||
|
"""
|
||||||
|
Filter on 'shortname' field.
|
||||||
|
"""
|
||||||
|
if self.value():
|
||||||
|
return queryset.filter(collection__id=self.value())
|
||||||
|
else:
|
||||||
|
return queryset
|
||||||
|
|
||||||
|
|
||||||
class GameAdmin(admin.ModelAdmin):
|
class GameAdmin(admin.ModelAdmin):
|
||||||
list_display = ('name', 'get_platform', 'playing', 'status', 'wish')
|
list_display = ('name', 'get_platform', 'playing', 'status', 'wish')
|
||||||
list_filter = [StatusFilter, 'playing', 'wish']
|
list_filter = [StatusFilter, 'playing', 'wish', PlatformFilter]
|
||||||
search_fields = ('name', )
|
search_fields = ('name', )
|
||||||
fieldsets = [(_('Game Information'), {
|
fieldsets = [(_('Game Information'), {
|
||||||
'fields': [('name', 'collection')]
|
'fields': [('name', 'collection')]
|
||||||
|
Loading…
Reference in New Issue
Block a user