From 8bcf29c8e52ad58349c883071439ea14f23ce5a5 Mon Sep 17 00:00:00 2001 From: James Turk Date: Tue, 30 Mar 2010 16:17:42 -0400 Subject: [PATCH] add markup_type options --- markupwiki/forms.py | 7 ++++++- markupwiki/models.py | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/markupwiki/forms.py b/markupwiki/forms.py index 790c57a..8918264 100644 --- a/markupwiki/forms.py +++ b/markupwiki/forms.py @@ -1,10 +1,15 @@ +from django.conf import settings from django import forms from markupwiki.models import Article, ArticleVersion +MARKUP_TYPE_EDITABLE = getattr(settings, 'MARKUPWIKI_MARKUP_TYPE_EDITABLE', False) + class ArticleForm(forms.ModelForm): class Meta: model = ArticleVersion - fields = ['body', 'body_markup_type'] + fields = ['body'] + if MARKUP_TYPE_EDITABLE: + fields.append('body_markup_type') class StaffModerationForm(forms.ModelForm): class Meta: diff --git a/markupwiki/models.py b/markupwiki/models.py index 762761e..a188387 100644 --- a/markupwiki/models.py +++ b/markupwiki/models.py @@ -1,8 +1,11 @@ from django.db import models +from django.conf import settings from django.contrib.auth.models import User from django.core.urlresolvers import reverse from markupfield.fields import MarkupField +DEFAULT_MARKUP_TYPE = getattr(settings, 'MARKUPWIKI_DEFAULT_MARKUP_TYPE', 'plain') + PUBLIC, LOCKED, DELETED = range(3) ARTICLE_STATUSES = ( (PUBLIC, 'Public'), # public - no restrictions on viewing/editing @@ -43,7 +46,7 @@ class ArticleVersion(models.Model): number = models.PositiveIntegerField() timestamp = models.DateTimeField(auto_now_add=True) removed = models.BooleanField(default=False) - body = MarkupField() + body = MarkupField(default_markup_type=DEFAULT_MARKUP_TYPE) class Meta: ordering = ['timestamp']