Mercurial > public > sg101
comparison gpp/shoutbox/models.py @ 13:777451a98f9d
Shoutbox work: shouts now have absolute URLs. Shouts can now be flagged as abuse. Minor tweak to breadcrumbs css. Added flag date to comments admin.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Thu, 16 Apr 2009 02:00:17 +0000 |
parents | dbd703f7d63a |
children | e1d1a70d312d |
comparison
equal
deleted
inserted
replaced
12:f408971657b9 | 13:777451a98f9d |
---|---|
2 Models for the shoutbox application. | 2 Models for the shoutbox application. |
3 """ | 3 """ |
4 from django.db import models | 4 from django.db import models |
5 from django.contrib.auth.models import User | 5 from django.contrib.auth.models import User |
6 | 6 |
7 | |
7 class Shout(models.Model): | 8 class Shout(models.Model): |
8 user = models.ForeignKey(User) | 9 user = models.ForeignKey(User) |
9 shout_date = models.DateTimeField(auto_now_add=True) | 10 shout_date = models.DateTimeField(auto_now_add=True) |
10 shout = models.TextField() | 11 shout = models.TextField() |
11 | 12 |
12 def __unicode__(self): | 13 @models.permalink |
13 shout = self.shout[:60] | 14 def get_absolute_url(self): |
14 return u'Shout from %s: %s' % (self.user.username, shout) | 15 return ('shoutbox-view', [str(self.id)]) |
15 | 16 |
16 class Meta: | 17 def __unicode__(self): |
17 ordering = ('-shout_date', ) | 18 shout = self.shout[:60] |
19 return u'Shout from %s: %s' % (self.user.username, shout) | |
20 | |
21 class Meta: | |
22 ordering = ('-shout_date', ) | |
23 | |
24 | |
25 class ShoutFlag(models.Model): | |
26 """This model represents a user flagging a shout as inappropriate.""" | |
27 user = models.ForeignKey(User) | |
28 shout = models.ForeignKey(Shout) | |
29 flag_date = models.DateTimeField(auto_now_add=True) | |
30 | |
31 def __unicode__(self): | |
32 return u'Shout ID %s flagged by %s' % (self.shout_id, self.user.username) | |
33 | |
34 class Meta: | |
35 ordering = ('flag_date', ) | |
36 | |
37 def get_shout_url(self): | |
38 return '<a href="/admin/shoutbox/shout/%s">Shout</a>' % self.shout.id | |
39 get_shout_url.allow_tags = True | |
40 | |
41 # vim: ts=4 sw=4 |