Commits

David Mazary  committed 443d455

Show results count. Does not combine cached and new results.

  • Participants
  • Parent commits 742ca63

Comments (0)

Files changed (3)

File geolocator/views.py

 from hokiefinder.geolocator.ldap_reader import Ldap_Reader
 
 
-# TODO Pass query to ldap reader
+# Pass query to ldap reader
 # Store results in database, check if we have cached geocoded results
 # Geocode results not yet geocoded in cache
 # Build Google Maps JS calls from geocoded results and stored results
 # If 'Next' button is pressed, get next page of results, repeat above
 def hokie_finder_view(request):
-    personList = None
+    personList = []
     if request.method == 'POST':
         form = forms.HokieFinderForm(request.POST)
         if form.is_valid():
                 queryList = models.Person.objects.filter(pid__icontains=query['term'])
             elif query['filter_type'] == 'displayName':
                 queryList = models.Person.objects.filter(display_name__icontains=query['term'])
-            if queryList != None:
-                return render_to_response('index.html', {'form': form, 'results': queryList},
+            if queryList is not None:
+                return render_to_response('index.html', {'form': form, 'results': personList,
+                                            'count': queryList.count()},
                                             context_instance=RequestContext(request))                                
             else:
                 reader = Ldap_Reader(query['filter_type'], query['term'])
                     personList.append(newPerson)
     else:
         form = forms.HokieFinderForm()
-    return render_to_response("index.html", {'form': form, 'results': personList},
-                              context_instance=RequestContext(request))
+    return render_to_response("index.html", {'form': form, 'results': personList,
+                                'count': len(personList)},
+                                context_instance=RequestContext(request))
 
 def user_invalid_view(request):
     return render_to_response("invalid.html")

File resources/database/hokiefinderdb.sqlite3

Binary file modified.

File resources/templates/index.html

     </form>
     {% if results %}
         <div id="results">
-            Found {{results.count}} Hokie{{results|pluralize}}
-            {% if results.count == 10 %}
+            Found {{count}} Hokie{{results|pluralize}}
+            {% if count >= 10 %}
             <button>Show 10 more</button>
             {% endif %}
         </div>