history page

This commit is contained in:
James Turk 2010-03-30 13:52:45 -04:00
parent ade62a74c1
commit 6cfe053a19
5 changed files with 42 additions and 24 deletions

View File

@ -1,10 +0,0 @@
{% if article %}
<h2>Editing Article "{{title}}"</h2>
{% else %}
<h2>Creating Article "{{title}}"</h2>
{% endif %}
<form method="POST" action=".">
{{ form.as_ul }}
<input type="submit">
</form>

View File

@ -17,9 +17,11 @@
{% if article.editable %}
<a href="{% url edit_article article.title %}">edit article</a> |
{% endif %}
<a href="{% url article_history article.title %}">view history</a>
{% if article %}
<a href="{% url article_history article.title %}">view history</a>
{% endif %}
{% if form %}
{% if article and form %}
<form method="POST" action="{% url update_article_status article.title %}">
{{form.status.label_tag}} {{ form.status }}
<input type="submit" />

View File

@ -0,0 +1,16 @@
{% extends "markupwiki/article.html" %}
{% block article_title %}
{% if article %}
Editing "{{title}}"
{% else %}
Creating New Article "{{title}}"
{% endif %}
{% endblock article_title %}
{% block article_body %}
<form method="POST" action=".">
{{ form.as_ul }}
<input type="submit">
</form>
{% endblock %}

View File

@ -1,11 +1,17 @@
{% extends "markupwiki/article.html" %}
<h2>History {{article.title}}</h2>
{% block article_title %}
{{article.title}} [History]
{% endblock %}
{% block article_meta %} {% endblock %}
{% block article_body %}
<table>
<tr>
<th>Version</th>
<th>Author</th>
<th>Date</th>
<th>Timestamp</th>
<th>Compare From</th>
<th>Compare To</th>
</tr>
@ -15,13 +21,13 @@
<tr>
<td><a href="{{version.get_absolute_url}}">
{% ifequal version.number 0 %}
Initial Version
Initial
{% else %}
Revision {{version.number}}
{% endifequal %}
</a></td>
<td>{{version.author}}</td>
<td><a href="{{version.get_absolute_url}}">{{version.timestamp}}</a></td>
<td><a href="{{version.get_absolute_url}}">{{version.timestamp|date:"Y-m-d H:i:s"}}</a></td>
<td><input type="radio" name="from" value="{{version.number}}"></td>
<td><input type="radio" name="to" value="{{version.number}}"></td>
</tr>
@ -30,3 +36,4 @@
<input type="submit">
</form>
{% endblock %}

View File

@ -75,8 +75,9 @@ def edit_article(request, title):
except Article.DoesNotExist:
article = None
if article and article.is_locked():
return render_to_response('locked_article.html', {'article': article})
if article and article.is_locked() and not user.is_staff:
return render_to_response('locked_article.html', {'article': article},
context_instance=RequestContext(request))
if request.method == 'GET':
# either get an empty ArticleForm or one based on latest version
@ -108,9 +109,9 @@ def edit_article(request, title):
# redirect to view article on save
return redirect(article)
return render_to_response('edit_article.html', {'title':title,
'article':article,
'form': form})
return render_to_response('markupwiki/edit_article.html',
{'title':title, 'article':article, 'form': form},
context_instance=RequestContext(request))
@require_POST
@ -129,8 +130,9 @@ def article_status(request, title):
def article_history(request, title):
article = get_object_or_404(Article, title=title)
versions = article.versions.filter(removed=False)
return render_to_response('history.html', {'article':article,
'versions':versions})
return render_to_response('markupwiki/history.html',
{'article':article, 'versions':versions},
context_instance=RequestContext(request))
@title_check
def article_diff(request, title):
@ -143,4 +145,5 @@ def article_diff(request, title):
from_body = from_version.body.raw.split('\n')
to_body = to_version.body.raw.split('\n')
table = differ.make_table(from_body, to_body)
return render_to_response('article_diff.html', {'table':table})
return render_to_response('article_diff.html', {'table':table},
context_instance=RequestContext(request))