openbackloggery/collection/games/models.py
Olivier DOSSMANN 5cbef15a13 Game - ajout de propriétés pour :
* le fait d'avoir joué ou non au jeu
  * de le vouloir dans sa liste de souhaits
  * de donner l'état de progression dans le jeu parmi :
    * inachevé
    * globalement terminé
    * complètement terminé
    * maîtrisé
2017-08-17 22:42:48 +02:00

54 lines
1.2 KiB
Python

from django.db import models
from django.utils.translation import ugettext as _
class Console(models.Model):
"""
All console, system or box that can be used to play video games.
"""
name = models.CharField(max_length=254)
def __str__(self):
return '%s' % self.name
class Meta:
ordering = ('name',)
class Game(models.Model):
"""
A video game you will use on a specific Console.
"""
# Status choices
BEATEN = 0
COMPLETED = 1
EXCLUDED = 2
MASTERED = 3
UNFINISHED = 4
STATUS_CHOICES = (
(UNFINISHED, _('Unfinished')),
(BEATEN, _('Beaten')),
(COMPLETED, _('Completed')),
(EXCLUDED, _('Excluded')),
(MASTERED, _('Mastered')),
)
# required
name = models.CharField(max_length=254)
console = models.ForeignKey('games.Console')
status = models.IntegerField(
choices=STATUS_CHOICES,
default=UNFINISHED)
# others
playing = models.BooleanField(default=False)
unplayed = models.BooleanField(default=False)
wish = models.BooleanField(default=False)
def __str__(self):
return '%s' % self.name
class Meta:
ordering = ('-playing', 'name')