Skip to content
Snippets Groups Projects
Commit 241f37c2 authored by Brian Moe's avatar Brian Moe
Browse files

stab at latest page

parent 96f47a6f
No related branches found
No related tags found
No related merge requests found
......@@ -28,7 +28,7 @@ class GraceQueryField(forms.CharField):
raise forms.ValidationError(str(e))
class SimpleSearchForm(forms.Form):
query = GraceQueryField(required=True, widget=forms.TextInput(attrs={'size':60}))
query = GraceQueryField(required=False, widget=forms.TextInput(attrs={'size':60}))
class CreateEventForm(forms.Form):
......
......@@ -161,6 +161,9 @@ q = (hasfarQ | gidQ | hidQ | tidQ | labelQ | atypeQ | groupQ | gpsQ | createdQ |
def parseQuery(s):
d={}
if not s:
# Empty query return everything not in Test group
return ~Q(group__name="Test")
for (tag, qval) in (stringStart + OneOrMore(q) + stringEnd).parseString(s).asList():
d[tag] = d.get(tag,Q()) | qval
if s.find("Test") < 0 and "tid" not in d:
......
......@@ -934,3 +934,22 @@ Initial Entry for %s
os.chmod(pname, 0644)
os.chmod(rcsname, 0444)
def latest(request):
context = {}
if request.method == "GET":
form = SimpleSearchForm(request.GET)
else:
form = SimpleSearchForm(request.POST)
context['form'] = form
if form.is_valid():
query = form.cleaned_data['query']
context['objects'] = Event.objects.filter(query).distinct().order_by("-created")[:10]
return render_to_response(
'gracedb/latest.html',
context,
context_instance=RequestContext(request))
......@@ -149,6 +149,7 @@ span.coinc-0,
#lab #nav-lab a,
#reviews #nav-reviews a,
#userprofile #nav-userprofile a,
#latest #nav-latest a,
#contact #nav-contact a {
background: #a9b0ba; /* Nav selected color */
/* color:#fff; / * Use if bg is dark */
......@@ -165,6 +166,7 @@ span.coinc-0,
#lab #nav-lab a:hover,
#reviews #nav-reviews a:hover,
#userprofile #nav-userprofile a:hover,
#latest #nav-latest a:hover,
#contact #nav-contact a:hover {
/* background:#e35a00; */
background: #a9b0ba; /* Nav selected color */
......
......@@ -35,6 +35,7 @@ function changeTime(obj, label) {
<li id="nav-create"><a href="{% url create %}">Create</a></li>
<li id="nav-reports"><a href="{% url reports %}">Reports</a></li>
<li id="nav-feeds"><a href="{% url feeds %}">RSS</a></li>
<li id="nav-latest"><a href="{% url latest %}">Latest</a></li>
<li id="nav-userprofile"><a href="{% url userprofile-home %}">Options</a></li>
{% if ligouser %}<li id="nav-user">Authenticated as: {{ ligouser.name }}</li>{% endif %}
</ul>
......
......@@ -31,6 +31,8 @@ urlpatterns = patterns('',
(r'^reports/(?P<path>.+)$', 'django.views.static.serve',
{'document_root': settings.LATENCY_REPORT_DEST_DIR}),
url (r'^latest', 'gracedb.views.latest', name="latest"),
# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment