summaryrefslogtreecommitdiff
path: root/news
diff options
context:
space:
mode:
Diffstat (limited to 'news')
-rw-r--r--news/views.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/news/views.py b/news/views.py
index 0b7b379e..887fe1dc 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: