openbackloggery/collection/games/models.py
Olivier DOSSMANN 5820bdc63a Amélioration de l'interface d'ajout de jeux vidéos :
Modification de  :

  * ajout de champs d'aide sur les champs booléens
  * création des fichiers de migration pour ces champs d'aide
  * choix de l'ordre des champs dans l'interface admin de Games
2017-08-24 20:43:58 +02:00

58 lines
1.5 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,
help_text=_('You\'re currently playing this game.'))
unplayed = models.BooleanField(
default=False,
help_text=_('You never played this game.'))
wish = models.BooleanField(
default=False,
help_text=_('You\'re waiting X-mas father offers you this game.'))
class Meta:
ordering = ('-playing', 'name')
class Timeline(BaseTimeline):
TARGET_MODEL = 'games.Game'
STATUS_CHOICES = Game.STATUS_CHOICES
DEFAULT_CHOICE = Item.DEFAULT_CHOICE