From b9e269ee51b0b113c5b22f5f37fdd6f414fc7a8e Mon Sep 17 00:00:00 2001
From: Tor-Einar Skog <tor-einar.skog@bioforsk.no>
Date: Wed, 15 Jun 2016 14:16:55 +0200
Subject: [PATCH] Ensure proper ordering of messages

---
 applefruitmoth/templates/applefruitmoth/index.html | 2 +-
 applefruitmoth/views.py                            | 2 +-
 vips_messages/models.py                            | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/applefruitmoth/templates/applefruitmoth/index.html b/applefruitmoth/templates/applefruitmoth/index.html
index 99d75007..d34197b4 100644
--- a/applefruitmoth/templates/applefruitmoth/index.html
+++ b/applefruitmoth/templates/applefruitmoth/index.html
@@ -31,7 +31,7 @@
 		<div class="col-md-6">
 			<p>{% trans "Description of apple fruit moth forecasting"%}</p>
 			<h2>{% trans "Messages" %}</h2>
-			{% for message in vips_messages %}
+			{% for message in vips_messages|dictsort:"date_pub" reversed %}
 			<div class="panel-group" id="accordion">
 			  <div class="panel panel-default">
 			    <div class="panel-heading">
diff --git a/applefruitmoth/views.py b/applefruitmoth/views.py
index 23230136..2636be88 100644
--- a/applefruitmoth/views.py
+++ b/applefruitmoth/views.py
@@ -1,7 +1,7 @@
 from django.shortcuts import render
 
 # Create your views here.
-from vips_messages.models import Message, MessageTag
+from vips_messages.models import Message
 
 def index(request):
     vips_messages = Message.get_messages_by_tag(4) # Getting apple fruit moth messages
diff --git a/vips_messages/models.py b/vips_messages/models.py
index f9a657f6..7bc4a291 100644
--- a/vips_messages/models.py
+++ b/vips_messages/models.py
@@ -88,7 +88,7 @@ class Message:
         self.illustration_caption = illustration_caption
         self.created_by = created_by
         self.message_crop_organism_ids = message_crop_organism_ids
-        
+    
     def get_illustration_url(self):
         return "http://%s/static/images/messages/%s/%s" % (settings.VIPSLOGIC_SERVER_NAME,self.organization_id,self.illustration_file_name)
     
-- 
GitLab