Source

indie-community / gamedb / models.py

Diff from to

File gamedb/models.py

 from django.db import models
 from django.contrib.auth.models import User
 from django.utils.text import slugify
+from tagging.fields import TagField
 
 class CustomComment(models.Model):
     owner = models.ForeignKey(User)
 
 class Game(models.Model):
     TYPE_LIST = (
-        (10, 'RPG Game'),
+        (10, 'RPG'),
         (20, 'Platformer'),
         (30, 'Tech Demo'),
         (40, 'Simulation'),
     disliked_by = models.ManyToManyField(User, blank=True, null=True, related_name='games_disliked')
     date_added = models.DateField(auto_now_add=True)
     updated_on = models.DateField(auto_now=True)
+    tags = TagField()
     def __unicode__(self):
         return u"%s" % self.title
     def save(self, **kwargs):
             self.author = self.owner.username
         return super(Game, self).save(**kwargs)
     def first_screenshot(self):
-        return self.screenshots.all()[0].image.url
+        try:
+            return self.screenshots.all()[0].image.url
+        except IndexError:
+            return ''
     @models.permalink
     def get_absolute_url(self):
         return ('game_detail', [self.slug])