diff --git a/gracedb/forms.py b/gracedb/forms.py index 650b9d779731213c15a82f2ac74325eddfe235af..b9c905b5e772e813bdc0107f47ebb9290ebb74a1 100644 --- a/gracedb/forms.py +++ b/gracedb/forms.py @@ -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): diff --git a/gracedb/query.py b/gracedb/query.py index 6e7952db562b6d9d053ee812a525fe32de204964..d54e6035e9891463cf644cf8bb4ec3c17db8b6ed 100644 --- a/gracedb/query.py +++ b/gracedb/query.py @@ -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: diff --git a/gracedb/views.py b/gracedb/views.py index 14bf006d35f1259ab48dd0dda52e8ce18944b586..fc84b60747661f6b16600fb055c19bba71b38ac6 100644 --- a/gracedb/views.py +++ b/gracedb/views.py @@ -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)) diff --git a/static/css/style.css b/static/css/style.css index 7d43311a0276f5796e9f451d8dc531ee8680e9c1..268f6f7f9d010987cbcaf2fe4eadebac91d2996f 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -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 */ diff --git a/templates/base.html b/templates/base.html index df80171f9508abd62b75675cb4b4275555bd3f6f..f9eec575d1aba079a5c7d27d8730603ecf10cb99 100644 --- a/templates/base.html +++ b/templates/base.html @@ -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> diff --git a/urls.py b/urls.py index 021b2905cc1d3bf4377a8382784b68c6d89dc4f4..3f5836eba315011dc1e84b7a39d6d56b0d7c1c34 100644 --- a/urls.py +++ b/urls.py @@ -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')),