revert & comment
This commit is contained in:
parent
16052c9612
commit
5392d7b429
@ -2,12 +2,12 @@ from django.conf import settings
|
|||||||
from django import forms
|
from django import forms
|
||||||
from markupwiki.models import Article, ArticleVersion
|
from markupwiki.models import Article, ArticleVersion
|
||||||
|
|
||||||
MARKUP_TYPE_EDITABLE = getattr(settings, 'MARKUPWIKI_MARKUP_TYPE_EDITABLE', False)
|
MARKUP_TYPE_EDITABLE = getattr(settings, 'MARKUPWIKI_MARKUP_TYPE_EDITABLE', True)
|
||||||
|
|
||||||
class ArticleForm(forms.ModelForm):
|
class ArticleForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ArticleVersion
|
model = ArticleVersion
|
||||||
fields = ['body']
|
fields = ['body', 'comment']
|
||||||
if MARKUP_TYPE_EDITABLE:
|
if MARKUP_TYPE_EDITABLE:
|
||||||
fields.append('body_markup_type')
|
fields.append('body_markup_type')
|
||||||
|
|
||||||
|
@ -57,9 +57,11 @@ class ArticleVersion(models.Model):
|
|||||||
article = models.ForeignKey(Article, related_name='versions')
|
article = models.ForeignKey(Article, related_name='versions')
|
||||||
author = models.ForeignKey(User, related_name='article_versions')
|
author = models.ForeignKey(User, related_name='article_versions')
|
||||||
number = models.PositiveIntegerField()
|
number = models.PositiveIntegerField()
|
||||||
|
body = MarkupField(default_markup_type=DEFAULT_MARKUP_TYPE)
|
||||||
|
comment = models.CharField(max_length=200, blank=True)
|
||||||
|
|
||||||
timestamp = models.DateTimeField(auto_now_add=True)
|
timestamp = models.DateTimeField(auto_now_add=True)
|
||||||
removed = models.BooleanField(default=False)
|
removed = models.BooleanField(default=False)
|
||||||
body = MarkupField(default_markup_type=DEFAULT_MARKUP_TYPE)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['timestamp']
|
ordering = ['timestamp']
|
||||||
|
@ -140,6 +140,21 @@ def article_status(request, title):
|
|||||||
|
|
||||||
return redirect(article)
|
return redirect(article)
|
||||||
|
|
||||||
|
@require_POST
|
||||||
|
@user_passes_test(lambda u: u.is_staff)
|
||||||
|
@title_check
|
||||||
|
def revert(request, title):
|
||||||
|
''' POST-only view to revert article to a specific revision
|
||||||
|
'''
|
||||||
|
article = get_object_or_404(Article, title=title)
|
||||||
|
revision_id = int(request.POST['revision'])
|
||||||
|
revision = get_object_or_404(revision, number=revision_id)
|
||||||
|
ArticleVersion.objects.create(article=article, author=request.user,
|
||||||
|
number=article.versions.latest().number,
|
||||||
|
body=revision.body)
|
||||||
|
|
||||||
|
return redirect(article)
|
||||||
|
|
||||||
@title_check
|
@title_check
|
||||||
def article_history(request, title):
|
def article_history(request, title):
|
||||||
article = get_object_or_404(Article, title=title)
|
article = get_object_or_404(Article, title=title)
|
||||||
|
Loading…
Reference in New Issue
Block a user