From 62bb3db8ada68a22c7a58f32b2e6bed63f19e53c Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 26 Oct 2012 17:36:12 -0500 Subject: Remove usages of 'django.contrib.markup' Switch to the news model being able to spit out the HTML version of the content, and don't use the markup contrib module. This is deprecated as of Django 1.5 so we can move off it now to save trouble down the road when it is fully removed. Signed-off-by: Dan McGee --- news/models.py | 7 +++++++ news/views.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'news') diff --git a/news/models.py b/news/models.py index 9123270..40238cd 100644 --- a/news/models.py +++ b/news/models.py @@ -1,6 +1,9 @@ +import markdown + from django.db import models from django.contrib.auth.models import User from django.contrib.sites.models import Site +from django.utils.safestring import mark_safe from django.utils.timezone import now @@ -17,6 +20,10 @@ class News(models.Model): def get_absolute_url(self): return '/news/%s/' % self.slug + def html(self): + return mark_safe(markdown.markdown( + self.content, safe_mode=True, enable_attributes=False)) + def __unicode__(self): return self.title diff --git a/news/views.py b/news/views.py index c0230f1..74bec05 100644 --- a/news/views.py +++ b/news/views.py @@ -76,7 +76,7 @@ def view_redirect(request, object_id): @require_POST def preview(request): data = request.POST.get('data', '') - markup = markdown.markdown(data, safe_mode=True) + markup = markdown.markdown(data, safe_mode=True, enable_attributes=False) return HttpResponse(markup) # vim: set ts=4 sw=4 et: -- cgit v1.2.3-24-g4f1b