diff options
| -rw-r--r-- | newsdiff/core/views.py | 11 | ||||
| -rw-r--r-- | newsdiff/templates/articles.html | 51 |
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> |
