Olivier DOSSMANN
242b0edff0
* utilisation de classes abstraites Django : Item et Collection * héritage de ces classes pour Game et Console * création d'un objet Timeline contenant le changement d'état des jeux * affichage de la Timeline sur l'interface Admin
52 lines
1.3 KiB
Python
52 lines
1.3 KiB
Python
from core.models import Collection, Item, Timeline as BaseTimeline
|
|
from django.db import models
|
|
from django.utils.translation import ugettext as _
|
|
|
|
|
|
class Console(Collection):
|
|
"""
|
|
All console, system or box that can be used to play video games.
|
|
"""
|
|
def __str__(self):
|
|
return '%s' % self.name
|
|
|
|
|
|
class Game(Item):
|
|
"""
|
|
A video game you will use on a specific Console.
|
|
"""
|
|
# class config
|
|
TARGET_MODEL = 'games.Console'
|
|
TARGET_VERBOSE_NAME = _('console')
|
|
RELATED_TARGET_NAME = 'games'
|
|
|
|
# Status choices
|
|
BEATEN = 'beaten'
|
|
COMPLETED = 'completed'
|
|
EXCLUDED = 'excluded'
|
|
MASTERED = 'mastered'
|
|
UNFINISHED = 'unfinished'
|
|
|
|
STATUS_CHOICES = (
|
|
(BEATEN, _('Beaten')),
|
|
(COMPLETED, _('Completed')),
|
|
(EXCLUDED, _('Excluded')),
|
|
(MASTERED, _('Mastered')),
|
|
(UNFINISHED, _('Unfinished')),
|
|
)
|
|
DEFAULT_CHOICE = UNFINISHED
|
|
|
|
# others
|
|
playing = models.BooleanField(default=False)
|
|
unplayed = models.BooleanField(default=False)
|
|
wish = models.BooleanField(default=False)
|
|
|
|
class Meta:
|
|
ordering = ('-playing', 'name')
|
|
|
|
|
|
class Timeline(BaseTimeline):
|
|
TARGET_MODEL = 'games.Game'
|
|
STATUS_CHOICES = Game.STATUS_CHOICES
|
|
DEFAULT_CHOICE = Item.DEFAULT_CHOICE
|