Merge pull request #1 from jcarbaugh/master

fix redirect_to and make revert work
This commit is contained in:
James Turk 2012-01-05 08:47:01 -08:00
commit d40076186b
4 changed files with 31 additions and 3 deletions

View File

@ -36,7 +36,7 @@ class Article(models.Model):
title = models.CharField(max_length=200)
creator = models.ForeignKey(User, related_name='wiki_articles', blank=True, null=True)
status = models.IntegerField(choices=ARTICLE_STATUSES, default=PUBLIC)
redirect_to = models.ForeignKey('self', null=True)
redirect_to = models.ForeignKey('self', blank=True, null=True)
def __unicode__(self):
return self.title

View File

@ -12,6 +12,32 @@
{% endblock %}
{% block article_body %}
<form action="{% url revert article.title %}" method="post">
{% csrf_token %}
<label for="revert-version">Revert to</label>
<select name="revision" id="revert-version">
{% for version in versions reversed %}
{% if not forloop.first %}
<option value="{{ version.number }}">
{% if version.number == 0 %}
Initial
{% else %}
{{ version.number }}
{% endif %}
</option>
{% endif %}
{% endfor %}
</select>
<button class="compareBtn" type="submit">
<span>Revert to version</span>
</button>
</form>
<table>
<thead> <tr>
<th>Version</th>
@ -46,4 +72,5 @@
<span>Compare Selected Versions</span>
</button>
</form>
{% endblock %}

View File

@ -12,5 +12,6 @@ urlpatterns = patterns('markupwiki.views',
url(WIKI_REGEX + '/history/$', 'article_history', name='article_history'),
url(WIKI_REGEX + '/history/(?P<n>\d+)/$', 'view_article', name='article_version'),
url(WIKI_REGEX + '/diff/$', 'article_diff', name='article_diff'),
url(WIKI_REGEX + '/revert/$', 'revert', name='revert'),
url(WIKI_REGEX + '/$', 'view_article', name='view_article'),
)

View File

@ -8,7 +8,7 @@ from django.contrib import messages
from django.http import Http404
from django.template import RequestContext
from django.utils.functional import wraps
from markupwiki.models import Article, PUBLIC, DELETED, LOCKED
from markupwiki.models import Article, ArticleVersion, PUBLIC, DELETED, LOCKED
from markupwiki.forms import ArticleForm, StaffModerationForm, ArticleRenameForm
CREATE_MISSING_ARTICLE = getattr(settings,
@ -169,7 +169,7 @@ def revert(request, title):
'''
article = get_object_or_404(Article, title=title)
revision_id = int(request.POST['revision'])
revision = get_object_or_404(revision, number=revision_id)
revision = get_object_or_404(article.versions, number=revision_id)
ArticleVersion.objects.create(article=article, author=request.user,
number=article.versions.latest().number,
comment='reverted to r%s' % revision_id,