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 ""
|
||||
"Project-Id-Version: 0.1\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"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
@ -17,23 +17,23 @@ msgstr ""
|
||||
"Content-Transfer-Encoding: 8bit\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"
|
||||
msgstr "nom"
|
||||
|
||||
#: core/models.py:9
|
||||
#: core/models.py:10
|
||||
msgid "shortname"
|
||||
msgstr "nom court"
|
||||
|
||||
#: core/models.py:25
|
||||
#: core/models.py:26
|
||||
msgid "New"
|
||||
msgstr "Nouveau"
|
||||
|
||||
#: core/models.py:48 core/models.py:79
|
||||
#: core/models.py:49 core/models.py:82
|
||||
msgid "status"
|
||||
msgstr "état"
|
||||
|
||||
#: core/models.py:65
|
||||
#: core/models.py:68
|
||||
msgid "date"
|
||||
msgstr "date"
|
||||
|
||||
@ -73,22 +73,22 @@ msgstr "Progression de la figurine"
|
||||
msgid "state"
|
||||
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"
|
||||
msgstr "Information du jeu"
|
||||
|
||||
#: games/admin.py:42
|
||||
#: games/admin.py:65
|
||||
msgid "Progress"
|
||||
msgstr "Progression"
|
||||
|
||||
#: games/admin.py:56
|
||||
#: games/admin.py:79
|
||||
msgid "Platform"
|
||||
msgstr "Plateforme"
|
||||
|
||||
#: games/models.py:15 games/models.py:29
|
||||
msgid "platform"
|
||||
msgstr "plateforme"
|
||||
|
||||
#: games/models.py:16
|
||||
msgid "platforms"
|
||||
msgstr "plateformes"
|
||||
|
@ -33,9 +33,32 @@ class StatusFilter(admin.SimpleListFilter):
|
||||
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):
|
||||
list_display = ('name', 'get_platform', 'playing', 'status', 'wish')
|
||||
list_filter = [StatusFilter, 'playing', 'wish']
|
||||
list_filter = [StatusFilter, 'playing', 'wish', PlatformFilter]
|
||||
search_fields = ('name', )
|
||||
fieldsets = [(_('Game Information'), {
|
||||
'fields': [('name', 'collection')]
|
||||
|
Loading…
Reference in New Issue
Block a user