gremmie@1: """ gremmie@1: Models for the shoutbox application. gremmie@1: """ gremmie@1: from django.db import models gremmie@1: from django.contrib.auth.models import User gremmie@1: bgneal@13: gremmie@1: class Shout(models.Model): bgneal@13: user = models.ForeignKey(User) bgneal@13: shout_date = models.DateTimeField(auto_now_add=True) bgneal@13: shout = models.TextField() gremmie@1: bgneal@13: @models.permalink bgneal@13: def get_absolute_url(self): bgneal@13: return ('shoutbox-view', [str(self.id)]) gremmie@1: bgneal@13: def __unicode__(self): bgneal@13: shout = self.shout[:60] bgneal@13: return u'Shout from %s: %s' % (self.user.username, shout) bgneal@13: bgneal@13: class Meta: bgneal@13: ordering = ('-shout_date', ) bgneal@13: bgneal@13: bgneal@13: class ShoutFlag(models.Model): bgneal@13: """This model represents a user flagging a shout as inappropriate.""" bgneal@13: user = models.ForeignKey(User) bgneal@13: shout = models.ForeignKey(Shout) bgneal@13: flag_date = models.DateTimeField(auto_now_add=True) bgneal@13: bgneal@13: def __unicode__(self): bgneal@13: return u'Shout ID %s flagged by %s' % (self.shout_id, self.user.username) bgneal@13: bgneal@13: class Meta: bgneal@13: ordering = ('flag_date', ) bgneal@13: bgneal@13: def get_shout_url(self): bgneal@13: return 'Shout' % self.shout.id bgneal@13: get_shout_url.allow_tags = True bgneal@13: bgneal@13: # vim: ts=4 sw=4