summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Adam <yuv.adm@gmail.com>2014-01-27 22:16:25 +0200
committerYuval Adam <yuv.adm@gmail.com>2014-01-27 22:16:25 +0200
commitc89c8f490567bee5e6882ff5ae664df9f1cf9b1b (patch)
treed05cf7a682260c7f38b43fa9045bd9ea707929b5
parentdb06eb45db3554e68e2eab55aa38940d1c7ab1e1 (diff)
Add latest revisions pane
-rw-r--r--newsdiff/core/views.py11
-rw-r--r--newsdiff/templates/articles.html51
2 files changed, 45 insertions, 17 deletions
diff --git a/newsdiff/core/views.py b/newsdiff/core/views.py
index a66fc08..853ba0c 100644
--- a/newsdiff/core/views.py
+++ b/newsdiff/core/views.py
@@ -1,5 +1,6 @@
import reversion
+from django.contrib.contenttypes.models import ContentType
from django.views.generic import DetailView, ListView
from reversion.helpers import generate_patch_html
from reversion.models import Version
@@ -40,6 +41,16 @@ class ArticleListView(ListView):
template_name = 'articles.html'
paginate_by = 10
+ def _get_latest_revisions(self):
+ model_content_type = ContentType.objects.get_for_model(self.model)
+ versions = Version.objects.filter(content_type=model_content_type).order_by('-revision__date_created')
+ return versions
+
+ def get_context_data(self, **kwargs):
+ context = super(ArticleListView, self).get_context_data(**kwargs)
+ context['latest_revisions'] = self._get_latest_revisions()
+ return context
+
class HaaretzListView(ArticleListView):
model = HaaretzArticle
diff --git a/newsdiff/templates/articles.html b/newsdiff/templates/articles.html
index 964b7ea..40a755f 100644
--- a/newsdiff/templates/articles.html
+++ b/newsdiff/templates/articles.html
@@ -6,22 +6,39 @@
<title>{{ article.title }}</title>
</head>
<body dir="rtl">
- <h1>כתבות אחרונות</h1>
- <ul style="list-style-type: none;">
- {% for article in articles %}
- <li>
- <a href="{% url 'haaretz_article' article.haaretz_id %}">
- {% if article.images.all %}
- {% thumbnail article.images.all.0.image '60x60' as tim %}
- <img src="{{ tim.url }}">
- {% endthumbnail %}
- {% else %}
- <img src="http://placekitten.com/g/60/45">
- {% endif %}
- <span>{{ article.title }}</span>
- </a>
- </li>
- {% endfor %}
- </ul>
+ <div style="clear: both; overflow: hidden;">
+ <div style="width: 50%; float: right;">
+ <h1>כתבות אחרונות</h1>
+ <ul style="list-style-type: none;">
+ {% for article in articles %}
+ <li>
+ <a href="{% url 'haaretz_article' article.haaretz_id %}">
+ {% if article.images.all %}
+ {% thumbnail article.images.all.0.image '60x60' as tim %}
+ <img src="{{ tim.url }}">
+ {% endthumbnail %}
+ {% else %}
+ <img src="http://placekitten.com/g/60/45">
+ {% endif %}
+ <span>{{ article.title }}</span>
+ </a>
+ </li>
+ {% endfor %}
+ </ul>
+ </div>
+ <div style="width: 50%; float: right;">
+ <h1>שינויים אחרונים</h1>
+ <ul style="list-style-type: none;">
+ {% for revision in latest_revisions %}
+ <li>
+ <span>{{ revision.revision.date_created|date:'d/m/Y H:i' }}</span>
+ <a href="{% url 'haaretz_article' revision.field_dict.haaretz_id %}">
+ <span>{{ revision.field_dict.title }}</span>
+ </a>
+ </li>
+ {% endfor %}
+ </ul>
+ </div>
+ </div>
</body>
</html>