add markup_type options

This commit is contained in:
James Turk 2010-03-30 16:17:42 -04:00
parent 1af18276b3
commit 8bcf29c8e5
2 changed files with 10 additions and 2 deletions

View File

@ -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:

View File

@ -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']