Browse files

Add contrib view of the latest changes

  • Loading branch information...
1 parent bf5cc47 commit 9622865985fa8ceb28da0d6be7c4be0e79bbba86 @emesik committed Mar 11, 2013
Showing with 47 additions and 0 deletions.
  1. 0 djiki/contrib/__init__.py
  2. +10 −0 djiki/contrib/views.py
  3. +37 −0 djiki/templates/djiki/latest_changes.html
View
0 djiki/contrib/__init__.py
No changes.
View
10 djiki/contrib/views.py
@@ -0,0 +1,10 @@
+from django.db.models import Max
+from django.template.response import TemplateResponse
+
+from .. import models
+
+def latest_changes(request, limit=50):
+ latest = models.Page.objects\
+ .annotate(latest_change=Max('revisions__created'))\
+ .order_by('-latest_change')[:limit]
+ return TemplateResponse(request, 'djiki/latest_changes.html', {'latest': latest})
View
37 djiki/templates/djiki/latest_changes.html
@@ -0,0 +1,37 @@
+{% extends 'djiki/base.html' %}
+{% load i18n djiki_tags %}
+{% block title %}{% trans "Latest changes" %} | {{ block.super }}{% endblock %}
+{% block djiki_main %}
+<div class="page latest grid_12">
+ <div class="content">
+ <h1>{% trans "Latest changes" %}</h1>
+ <table>
+ <thead>
+ <tr>
+ <th>{% trans "Page" %}</th>
+ <th>{% trans "Modification time" %}</th>
+ <th>{% trans "Author" %}</th>
+ <th>{% trans "Description" %}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for page in latest %}
+ <tr>
+ <td>
+ <a href="{% url 'djiki-page-view' page.title|urlize_title %}">{{ page.title }}</a>
+ </td>
+ <td>
+ {% blocktrans with page.latest_change|timesince as timesince %}{{ timesince }} ago{% endblocktrans %}
+ </td>
+ <td>
+ {% if revision.author %}{{ page.last_revision.author }}
+ {% else %}<em>{% trans "anonymous" %}</em>{% endif %}
+ </td>
+ <td>{{ page.last_revision.description }}</td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ </div>
+</div>
+{% endblock %}

0 comments on commit 9622865

Please sign in to comment.