From 4e5406afef4c707f21f94b9b19974dbd755bdffd Mon Sep 17 00:00:00 2001
From: Branson Stephens <stephenb@uwm.edu>
Date: Tue, 23 Jul 2013 15:26:02 -0500
Subject: [PATCH] fixed ordering of log message digests

---
 gracedb/models.py   | 18 +++++++++++++++++-
 settings/default.py |  2 +-
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/gracedb/models.py b/gracedb/models.py
index 2aefbeaca..c54a7efc1 100644
--- a/gracedb/models.py
+++ b/gracedb/models.py
@@ -194,7 +194,23 @@ class Event(models.Model):
             for tag in tagset:
                 taglist.append(tag)
         # Eliminate duplicates
-        return list(set(taglist))
+        taglist = list(set(taglist))
+        # Ordering should match the ordering of blessed tags list.
+        # XXX Possibly, there are smarter ways of doing this.
+        if settings.BLESSED_TAGS:
+            availableTags = []
+            for blessed_tag in settings.BLESSED_TAGS:
+                for tag in taglist:
+                    if tag.name == blessed_tag:
+                        taglist.remove(tag)
+                        availableTags.append(tag)
+            # Append any remaining tags at the end of the list
+            if len(taglist)>0:
+                for tag in taglist:
+                    availableTags.append(tag)
+        else:
+            availableTags = taglist
+        return availableTags
 
     def getLogsForTag(self,tagname):
         loglist = []
diff --git a/settings/default.py b/settings/default.py
index 411bfd1c7..af71a26a4 100644
--- a/settings/default.py
+++ b/settings/default.py
@@ -40,13 +40,13 @@ XMPP_ALERT_CHANNELS = [
                       ]
 
 BLESSED_TAGS = [
+                 'analyst_comments',
                  'psd',
                  'sky_loc',
                  'strain',
                  'tfplots',
                  'sig_info',
                  'audio',
-                 'analyst_comments',
                ]
 
 DATABASES = {
-- 
GitLab