From e27408eb79e4a5a3612ffa951246e42fe712f935 Mon Sep 17 00:00:00 2001
From: Brian Moe <brian.moe@ligo.org>
Date: Mon, 4 Jun 2012 16:29:09 -0500
Subject: [PATCH] Minor tweaking

---
 gracedb/views.py              |   4 ++
 templates/gracedb/latest.html | 114 ++++++++++++++++++++++++++++++++--
 2 files changed, 114 insertions(+), 4 deletions(-)

diff --git a/gracedb/views.py b/gracedb/views.py
index fc84b6074..ef8f504bc 100644
--- a/gracedb/views.py
+++ b/gracedb/views.py
@@ -944,10 +944,14 @@ def latest(request):
         form = SimpleSearchForm(request.POST)
 
     context['form'] = form
+    context['rawquery'] = request.GET.get('query') or request.POST.get('query') or ""
 
     if form.is_valid():
         query = form.cleaned_data['query']
         context['objects'] = Event.objects.filter(query).distinct().order_by("-created")[:10]
+        context['error'] = False
+    else:
+        context['error'] = True
 
     return render_to_response(
             'gracedb/latest.html',
diff --git a/templates/gracedb/latest.html b/templates/gracedb/latest.html
index 6a560dbcb..f87f7afef 100644
--- a/templates/gracedb/latest.html
+++ b/templates/gracedb/latest.html
@@ -1,9 +1,90 @@
 {% extends "base.html" %}
 
+{% load timeutil %}
+{% load scientific %}
+
 {% block title %}Latest{% endblock %}
 {% block heading %}Latest{% endblock %}
 {% block pageid %}latest{% endblock %}
 
+{% block jscript %}
+
+{% if not error %}
+    {% if rawquery %}
+        <meta http-equiv="refresh" content="300;url={% url latest %}/?query={{rawquery|urlencode}}">
+    {% else %}
+        <meta http-equiv="refresh" content="300;url={% url latest %}">
+    {% endif %}
+{% endif %}
+
+
+    <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.7.1/dojo/dojo.js" type="text/javascript"></script>
+    <script type="text/javascript">
+        dojo.require("dojox.image.LightboxNano");
+        dojo.require("dojo.parser");
+        dojo.ready(function(){
+            dojo.parser.parse();
+        });
+    </script>
+    <style>
+        a:hover .dojoxEnlarge {
+            display: block !important;
+        }
+        .dojoxEnlarge {
+            background: url(images/enlarge.png) no-repeat 0 0;
+            top: -5px;
+            left: -5px;
+            margin: 0 !important;
+            width: 16px;
+            height: 16px;
+        }
+        .dojoxLoading {
+            background: #333 url(images/loading-dark.gif) no-repeat center center;
+            border-radius: 5px;
+            -moz-border-radius: 5px;
+            -webkit-border-radius: 5px;
+            border: 2px solid #000;
+            height: 24px;
+            opacity: 0.8;
+            filter: alpha(opacity=80);
+            padding: 6px;
+            width: 24px;
+        }
+    </style>
+
+    <style>
+    .summary .graceid {
+        border-top: 1px solid #CBC9C7;
+        width: 100%;
+        font-size: 150%;
+        font-family: "Century Schoolbook L", "Georgia", serif;
+        font-weight: 700;
+        padding-top: 10px;
+        padding-bottom: 10px;
+    }
+    .summary .labels {
+        padding-bottom: 5px;
+        padding-left: 5px;
+    }
+    .summary .group {
+        font-weight: 500;
+        padding-top: 5px;
+        padding-bottom: 5px;
+    }
+    .summary {
+        clear: both;
+        padding: 20px;
+    }
+    .summary .skymap {
+        float: right;
+    }
+    .summary-data {
+    }
+    </style>
+
+{% endblock %}
+
+
 {% block content %}
 
 <form method="POST">
@@ -15,10 +96,35 @@
 {% if objects %}
     <hr/>
     {% for item in objects %}
-        <div>
-            {{ item.graceid }}
-        </div>
-        <hr/>
+        <div class="summary">
+            <div class="graceid">
+                <a href="{% url view item.graceid %}">{{ item.graceid }}</a>
+                |
+                {{item.group}}
+                {{item.get_analysisType_display}}
+            </div>
+            {% for log in item.eventlog_set.iterator %}
+                {% if log.hasImage %}
+                    <div class="skymap">
+                        <a href="{{ log.fileurl }}" dojoType="dojox.image.LightboxNano"><img height="130" src="{{ log.fileurl }}"></a>
+                    </div>
+                {% endif %}
+            {% endfor %}
+
+            <div class="labels">
+            {% for labelling in item.labelling_set.all %}
+               <span class="label" title="{{labelling.creator.name}}  {{labelling.created|utc}}" style="color: {{labelling.label.defaultColor}}">{{ labelling.label.name }}</span>
+            {% endfor %}
+            </div>
+
+            <table>
+                <tr><th>FAR:</th><td> {{ item.far|scientific }} Hz</td></tr>
+                <tr><th>GPS Time:</th><td> {{ item.gpstime }} </td></tr>
+                <tr><th>Latency:</th><td> {{ item.reportingLatency }} seconds</td></tr>
+                <tr><th>Created:</th><td> {{ item.created }} </td></tr>
+            </table>
+
+        </div><!-- class summary -->
     {% endfor %}
 {% endif %}
 
-- 
GitLab