diff --git a/gracedb/forms.py b/gracedb/forms.py index 6458883f59bdea314a3b9b6ab039a55c95a4ee62..7341c2aaf9ad2538b162edd2fe2b637d406d1d25 100644 --- a/gracedb/forms.py +++ b/gracedb/forms.py @@ -79,6 +79,12 @@ class EventSearchForm(forms.Form): required=False) get_neighbors = forms.BooleanField(required=False) + offline = forms.NullBooleanField( + required=False, + help_text=("Select \"Unknown\" to search for both online and offline " + "events.") + ) + class SignoffForm(ModelForm): class Meta: model = Signoff diff --git a/gracedb/views.py b/gracedb/views.py index afb52eb8870a50aafbf4f9a6b22c2656b2bfc9f4..89df60bfe5a7858bf8ded443f5fbffe89c95cf72 100644 --- a/gracedb/views.py +++ b/gracedb/views.py @@ -581,9 +581,14 @@ def oldsearch(request): gpsStart = form.cleaned_data['gpsStart'] gpsEnd = form.cleaned_data['gpsEnd'] get_neighbors = form.cleaned_data['get_neighbors'] + offline = form.cleaned_data['offline'] textQuery = [] + # XXX: this whole thing could be redone by defining Q objects + # and doing a single query. I think that might simplify the + # database queries. (Tanner) + if not groupname: # don't show test events unless explicitly requested # Scales? Or should we find test group and do group= ? @@ -591,25 +596,6 @@ def oldsearch(request): else: objects = Event.objects.all() - # XXX Note, the uid field doesn't exist anymore. I'm not sure why this - # stuff is in here. (Branson) -# if start: -# if start[0] != 'G': -# # XXX This is the deprecated uid stuff. Take it out when uid is gone. -# objects = objects.filter(uid__gte=start) -# objects = objects.filter(uid__startswith="0") -# else: -# objects = objects.filter(id__gte=int(start[1:])) -# objects = objects.filter(uid="") -# if end: -# if end[0] != 'G': -# # XXX This is the deprecated uid stuff. Take it out when uid is gone. -# objects = objects.filter(uid__lte=end) -# objects = objects.filter(uid__startswith="0") -# else: -# objects = objects.filter(id__lte=int(end[1:])) -# objects = objects.filter(uid="") - if start: if start[0] in 'GEHMT': objects = objects.filter(id__gte=int(start[1:])) @@ -669,6 +655,11 @@ def oldsearch(request): # Need this because events with multiple labels can appear multiple times! objects = objects.distinct() + # Offline + if offline is not None: + objects = objects.filter(offline=offline) + textQuery.append("offline: \"{0}\"".format(offline)) + # Filter for user. objects = filter_events_for_user(objects, request.user, 'view')