from core.models import Collection, Item, Timeline as BaseTimeline from django.db import models from django.utils.translation import ugettext as _ class Platform(Collection): """ All platform, system or box that can be used to play video games. """ def __str__(self): return '%s' % self.name class Meta: ordering = ('name',) verbose_name = _('platform') verbose_name_plural = _('platforms') # Redefine help_text (for documentation, API, etc.) Platform._meta.get_field('name').help_text = _('Most used platform name.') class Game(Item): """ A video game you will use on a specific Platform. """ # class config TARGET_MODEL = 'games.Platform' TARGET_VERBOSE_NAME = _('platform') 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 # progression note = models.CharField( max_length=150, null=True, blank=True, verbose_name=_('Progress note'), help_text=_('Short note displayed to your followers.')) # others playing = models.BooleanField( default=False, verbose_name=_('playing?'), help_text=_('You\'re currently playing this game.')) unplayed = models.BooleanField( default=False, verbose_name=_('unplayed?'), help_text=_('You never played this game.')) wish = models.BooleanField( default=False, verbose_name=_('wish?'), help_text=_('You\'re waiting X-mas father offers you this game.')) class Meta: ordering = ('-playing', 'name') verbose_name = _('game') verbose_name_plural = _('games') # Redefine help_text (for documentation, API, etc.) Game._meta.get_field('name').help_text = _('Game title') Game._meta.get_field('collection').help_text = _('Game running platform') Game._meta.get_field('status').help_text = _('Game progression') class Timeline(BaseTimeline): TARGET_MODEL = 'games.Game' TARGET_VERBOSE_NAME = 'game' STATUS_CHOICES = Game.STATUS_CHOICES DEFAULT_CHOICE = Item.DEFAULT_CHOICE class Meta: ordering = ('-date',) verbose_name = _('Timeline') verbose_name_plural = _('Timelines') # Redefine help_text (for documentation, API, etc.) Timeline._meta.get_field('date').help_text = _('Status change date') Timeline._meta.get_field('item').help_text = _('Which game?') Timeline._meta.get_field('status').help_text = _( 'New status for this game at the given date')