Omission de l'état 'Nouveau' (CREATED) dans les formulaires et le filtre
This commit is contained in:
parent
84e1baa64b
commit
6319f24499
@ -1,10 +1,12 @@
|
|||||||
Current version (0.2) :
|
Current version (0.2) :
|
||||||
|
|
||||||
|
- Omission de l'état "Nouveau" pour les jeux
|
||||||
- Traduction de l'interface en Français
|
- Traduction de l'interface en Français
|
||||||
- Aide contextuelle sur l'interface admin d'un jeu vidéo
|
- Aide contextuelle sur l'interface admin d'un jeu vidéo
|
||||||
|
|
||||||
Version 0.1 :
|
Version 0.1 :
|
||||||
|
|
||||||
|
- Application de la licence EUPL v1.2
|
||||||
- Utilisation possible de l'application par Docker
|
- Utilisation possible de l'application par Docker
|
||||||
- Interface web d'administration
|
- Interface web d'administration
|
||||||
- Liste de jeux joués
|
- Liste de jeux joués
|
||||||
|
@ -1,12 +1,37 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
from django.utils.translation import ugettext as _
|
||||||
|
from games.forms import GameForm
|
||||||
from games.models import Console, Game, Timeline
|
from games.models import Console, Game, Timeline
|
||||||
|
|
||||||
|
|
||||||
|
class StatusFilter(admin.SimpleListFilter):
|
||||||
|
"""
|
||||||
|
Remove CREATED status.
|
||||||
|
"""
|
||||||
|
title = _('state')
|
||||||
|
parameter_name = 'status'
|
||||||
|
|
||||||
|
def lookups(self, request, model_admin):
|
||||||
|
"""
|
||||||
|
Return only games choices (not CREATED from Item abstract class).
|
||||||
|
"""
|
||||||
|
return Game.STATUS_CHOICES
|
||||||
|
|
||||||
|
def queryset(self, request, queryset):
|
||||||
|
"""
|
||||||
|
Filter on 'status' field.
|
||||||
|
"""
|
||||||
|
if self.value():
|
||||||
|
return queryset.filter(status=self.value())
|
||||||
|
else:
|
||||||
|
return queryset
|
||||||
|
|
||||||
|
|
||||||
class GameAdmin(admin.ModelAdmin):
|
class GameAdmin(admin.ModelAdmin):
|
||||||
list_display = (
|
list_display = (
|
||||||
'name', 'playing', 'status', 'wish')
|
'name', 'playing', 'status', 'wish')
|
||||||
list_filter = [
|
list_filter = [
|
||||||
'status',
|
StatusFilter,
|
||||||
'playing',
|
'playing',
|
||||||
'wish']
|
'wish']
|
||||||
search_fields = ('name',)
|
search_fields = ('name',)
|
||||||
@ -19,6 +44,8 @@ class GameAdmin(admin.ModelAdmin):
|
|||||||
'wish'
|
'wish'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
form = GameForm
|
||||||
|
|
||||||
|
|
||||||
class TimelineAdmin(admin.ModelAdmin):
|
class TimelineAdmin(admin.ModelAdmin):
|
||||||
list_display = (
|
list_display = (
|
||||||
|
12
collection/games/forms.py
Normal file
12
collection/games/forms.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
from django import forms
|
||||||
|
from games.models import Game
|
||||||
|
|
||||||
|
|
||||||
|
class GameForm(forms.ModelForm):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
"""
|
||||||
|
Do not display CREATED status.
|
||||||
|
"""
|
||||||
|
super(GameForm, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
self.fields['status'].choices = Game.STATUS_CHOICES
|
Loading…
Reference in New Issue
Block a user