Mercurial > public > sg101
comparison gpp/news/models.py @ 213:65016249bf35
See #31; undid attempts to clear template tag caching when saving news and bulletins, as we don't know the cache key (it is mangled).
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Mon, 10 May 2010 02:58:19 +0000 |
parents | b4305e18d3af |
children | 6dbb8faef085 |
comparison
equal
deleted
inserted
replaced
212:fad7548b7f6e | 213:65016249bf35 |
---|---|
3 """ | 3 """ |
4 | 4 |
5 import datetime | 5 import datetime |
6 from django.db import models | 6 from django.db import models |
7 from django.contrib.auth.models import User | 7 from django.contrib.auth.models import User |
8 from django.core.cache import cache | |
9 from tagging.fields import TagField | 8 from tagging.fields import TagField |
10 | 9 |
11 | 10 |
12 class Category(models.Model): | 11 class Category(models.Model): |
13 """News stories belong to categories""" | 12 """News stories belong to categories""" |
73 | 72 |
74 def can_comment_on(self): | 73 def can_comment_on(self): |
75 now = datetime.datetime.now() | 74 now = datetime.datetime.now() |
76 delta = now - self.date_submitted | 75 delta = now - self.date_submitted |
77 return self.allow_comments and delta.days < 30 | 76 return self.allow_comments and delta.days < 30 |
78 | |
79 def save(self, *args, **kwargs): | |
80 super(Story, self).save(*args, **kwargs) | |
81 cache.delete('home_news') | |
82 |