~widelands-dev/widelands-website/trunk

« back to all changes in this revision

Viewing changes to wiki/views.py

  • Committer: Timo Wingender
  • Date: 2010-09-28 21:26:23 UTC
  • mto: This revision was merged to the branch mainline in revision 218.
  • Revision ID: timo.wingender@gmx.de-20100928212623-awo0wh3hcaptc0oj
add field to choose between markdown and bbcode as markup

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
from django.contrib.contenttypes.models import ContentType
15
15
from django.contrib.syndication.feeds import FeedDoesNotExist
16
16
 
17
 
from wiki.forms import ArticleForm
 
17
from wiki.forms import ArticleForm 
18
18
from wiki.models import Article, ChangeSet, dmp
19
19
from wiki.feeds import (RssArticleHistoryFeed, AtomArticleHistoryFeed,
20
20
                        RssHistoryFeed, AtomHistoryFeed)
21
 
from wiki.utils import get_ct
22
 
from django.contrib.auth.decorators import login_required
 
21
from wiki.utils import get_ct 
 
22
from django.contrib.auth.decorators import login_required 
23
23
 
24
24
from mainpage.templatetags.wl_markdown import do_wl_markdown
25
25
 
260
260
 
261
261
        form = ArticleFormClass(request.POST, instance=article)
262
262
 
263
 
        form.cache_old_content()
264
263
        if form.is_valid():
 
264
 
265
265
            if request.user.is_authenticated():
266
266
                form.editor = request.user
267
267
                if article is None:
307
307
    if not article:
308
308
        template_params = {'form': form, "new_article": True }
309
309
    else:
310
 
        template_params = {'form': form, "new_article": False,
 
310
        template_params = {'form': form, "new_article": False, 
311
311
            "content_type": ContentType.objects.get_for_model(Article).pk, "object_id": article.pk,
312
312
            "images": article.all_images(),
313
313
            "article": article,
534
534
        return HttpResponseForbidden()
535
535
 
536
536
    article = get_object_or_404(article_qs, **article_args)
537
 
 
 
537
    
538
538
    if not notification.is_observing(article, request.user):
539
539
        notification.observe(article, request.user,
540
540
           'wiki_observed_article_changed')
585
585
 
586
586
def article_preview( request ):
587
587
    """
588
 
    This is a AJAX function that previews the body of the
589
 
    article as it is currently displayed.
 
588
    This is a AJAX function that previews the body of the 
 
589
    article as it is currently displayed. 
590
590
 
591
591
    This function is actually pretty simple, it just
592
592
    runs the function through the view template and returns
597
597
 
598
598
def article_diff( request ):
599
599
    """
600
 
    This is a AJAX function that diffs the body of the
601
 
    article as it is currently displayed with the current version
 
600
    This is a AJAX function that diffs the body of the 
 
601
    article as it is currently displayed with the current version 
602
602
    of the article
603
603
    """
604
604
    current_article = get_object_or_404(Article, pk=int(request.POST["article"]))
605
605
    content = request.POST["body"]
606
 
 
 
606
    
607
607
    diffs = dmp.diff_main(current_article.content, content)
608
608
 
609
609
    return HttpResponse(dmp.diff_prettyHtml(diffs), mimetype="text/html")