summaryrefslogtreecommitdiff
path: root/news/models.py
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-04-21 02:22:44 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-04-21 02:22:44 -0400
commit03fa7e4f27bdb39a8f8f5ed91a87d18bf8357b47 (patch)
treec67eafcbda55706f18400b3115a2b8a5be318394 /news/models.py
parent91c451821ce7000cbc268cec8427d208a6cedd7e (diff)
parentb8ee7b1ee281b45b245fb454228b8ad847c56200 (diff)
Merge branch 'archweb' into archweb-generic2
Conflicts: devel/views.py feeds.py public/views.py settings.py sitestatic/archweb.js templates/base.html templates/devel/profile.html templates/mirrors/status.html templates/news/view.html templates/packages/flaghelp.html templates/packages/opensearch.xml templates/public/download.html templates/public/feeds.html templates/public/index.html templates/registration/login.html templates/releng/results.html templates/todolists/public_list.html
Diffstat (limited to 'news/models.py')
-rw-r--r--news/models.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/news/models.py b/news/models.py
index 95026e1d..d51db7c7 100644
--- a/news/models.py
+++ b/news/models.py
@@ -1,8 +1,10 @@
+import markdown
+
from django.db import models
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
-
-from main.utils import utc_now
+from django.utils.safestring import mark_safe
+from django.utils.timezone import now
class News(models.Model):
@@ -14,10 +16,15 @@ class News(models.Model):
title = models.CharField(max_length=255)
guid = models.CharField(max_length=255, editable=False)
content = models.TextField()
+ safe_mode = models.BooleanField(default=True)
def get_absolute_url(self):
return '/news/%s/' % self.slug
+ def html(self):
+ return mark_safe(markdown.markdown(
+ self.content, safe_mode=self.safe_mode, enable_attributes=False))
+
def __unicode__(self):
return self.title
@@ -25,17 +32,18 @@ class News(models.Model):
db_table = 'news'
verbose_name_plural = 'news'
get_latest_by = 'postdate'
- ordering = ['-postdate']
+ ordering = ('-postdate',)
+
def set_news_fields(sender, **kwargs):
news = kwargs['instance']
- now = utc_now()
- news.last_modified = now
+ current_time = now()
+ news.last_modified = current_time
if not news.postdate:
- news.postdate = now
+ news.postdate = current_time
# http://diveintomark.org/archives/2004/05/28/howto-atom-id
news.guid = 'tag:%s,%s:%s' % (Site.objects.get_current(),
- now.strftime('%Y-%m-%d'), news.get_absolute_url())
+ current_time.strftime('%Y-%m-%d'), news.get_absolute_url())
# connect signals needed to keep cache in line with reality
from main.utils import refresh_latest