From ad162d74db6718b2ba7dd1ab2e1f21847a7c7744 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 6 Jul 2010 20:16:10 -0500 Subject: Format all news items using markdown Implements FS#13741. A preview function is also added so working with news items is easier to make sure you get the formatting right. This will result in some older news items looking a bit weird if they didn't put linebreaks in all the right places, we can fix a few of these as we notice them. Signed-off-by: Dan McGee --- news/views.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'news') diff --git a/news/views.py b/news/views.py index 0b7b379..887fe1d 100644 --- a/news/views.py +++ b/news/views.py @@ -1,10 +1,13 @@ from django import forms from django.contrib.auth.decorators import permission_required +from django.http import HttpResponse from django.shortcuts import render_to_response, redirect from django.template import RequestContext from django.views.decorators.cache import never_cache from django.views.generic import list_detail, create_update +import markdown + from main.models import News def view(request, newsid): @@ -57,4 +60,13 @@ def edit(request, newsid): form_class=NewsForm, template_name="news/add.html") +@permission_required('main.change_news') +@never_cache +def preview(request): + markup = '' + if request.POST: + data = request.POST.get('data', '') + markup = markdown.markdown(data) + return HttpResponse(markup) + # vim: set ts=4 sw=4 et: -- cgit v1.2.3-24-g4f1b