community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgard...@apache.org
Subject svn commit: r894728 - in /comdev/nearby_people: nearby/foaf.py nearby/forms.py nearby/views.py templates/pick_place.html
Date Wed, 30 Dec 2009 22:39:21 GMT
Author: rgardler
Date: Wed Dec 30 22:39:20 2009
New Revision: 894728

URL: http://svn.apache.org/viewvc?rev=894728&view=rev
Log:
Allow us to limit the number of people returned in the search.

Modified:
    comdev/nearby_people/nearby/foaf.py
    comdev/nearby_people/nearby/forms.py
    comdev/nearby_people/nearby/views.py
    comdev/nearby_people/templates/pick_place.html

Modified: comdev/nearby_people/nearby/foaf.py
URL: http://svn.apache.org/viewvc/comdev/nearby_people/nearby/foaf.py?rev=894728&r1=894727&r2=894728&view=diff
==============================================================================
--- comdev/nearby_people/nearby/foaf.py (original)
+++ comdev/nearby_people/nearby/foaf.py Wed Dec 30 22:39:20 2009
@@ -37,7 +37,7 @@
         self.people = {}
         self.updated_at = None
 
-    def get_nearby(self, lat, long):
+    def get_nearby(self, lat, long, rows = 10):
         self.ensure_data()
 
         dists = [
@@ -45,7 +45,7 @@
             for f in self.people.values()
         ]
         dists.sort( lambda x,y: int(x[0]-y[0]) )
-        return dists[:20]
+        return dists[:rows]
 
     def ensure_data(self):    
         if not self.people:

Modified: comdev/nearby_people/nearby/forms.py
URL: http://svn.apache.org/viewvc/comdev/nearby_people/nearby/forms.py?rev=894728&r1=894727&r2=894728&view=diff
==============================================================================
--- comdev/nearby_people/nearby/forms.py (original)
+++ comdev/nearby_people/nearby/forms.py Wed Dec 30 22:39:20 2009
@@ -26,15 +26,22 @@
       required=False,
       widget=forms.HiddenInput,
     )
+    rows = forms.IntegerField(
+      required = False, 
+      initial = 10, 
+      widget=forms.HiddenInput,)
+    
     def set_type(self, type):
       for opt,name in self.fields["type"].choices:
          if opt == type:
             self.initial["type"] = opt
+    
     def enableTypeField(self):
       self.fields["type"].widget = forms.Select(
            choices=self.fields["type"].choices
       )
 
 class LocationForm(forms.Form):
-	latitude = forms.FloatField()
-	longitude = forms.FloatField()
+    latitude = forms.FloatField()
+    longitude = forms.FloatField()
+

Modified: comdev/nearby_people/nearby/views.py
URL: http://svn.apache.org/viewvc/comdev/nearby_people/nearby/views.py?rev=894728&r1=894727&r2=894728&view=diff
==============================================================================
--- comdev/nearby_people/nearby/views.py (original)
+++ comdev/nearby_people/nearby/views.py Wed Dec 30 22:39:20 2009
@@ -82,10 +82,11 @@
 	if form.data["type"] == "sp":
 		foaf = speakers_foaf
 
-	location = form.data
-	search_latitude = float(location["latitude"])
-	search_longitude = float(location["longitude"])
-	people = foaf.get_nearby(search_latitude, search_longitude)
+	search_data = form.data
+	search_latitude = float(search_data["latitude"])
+	search_longitude = float(search_data["longitude"])
+	rows = int(search_data["rows"])
+	people = foaf.get_nearby(search_latitude, search_longitude, rows)
 
 	# Work out the people.apache.org links for people
 	for d,person in people:
@@ -101,7 +102,7 @@
 	center_long = (min_long+max_long)/2
 
 	data = {
-		'location': location, 'people':people,
+		'location': search_data, 'people':people,
 		'center_lat': center_lat, 'center_long': center_long,
 		'bl_lat': min_lat, 'bl_long': min_long,
 		'tr_lat': max_lat, 'tr_long': max_long,

Modified: comdev/nearby_people/templates/pick_place.html
URL: http://svn.apache.org/viewvc/comdev/nearby_people/templates/pick_place.html?rev=894728&r1=894727&r2=894728&view=diff
==============================================================================
--- comdev/nearby_people/templates/pick_place.html (original)
+++ comdev/nearby_people/templates/pick_place.html Wed Dec 30 22:39:20 2009
@@ -13,7 +13,7 @@
 
 	<ul>
 	{% for p in places %}
-		<li><a href="/find_people/?latitude={{p.latitude}}&longitude={{p.longitude}}&type={{form.data.type}}"
title="{{p.latitude|floatformat:4}} {{p.longitude|floatformat:4}}">{{p.name}} ({{p.country}})</a></li>
+		<li><a href="/find_people/?latitude={{p.latitude}}&longitude={{p.longitude}}&type={{form.data.type}}&rows={{form.data.rows}}"
title="{{p.latitude|floatformat:4}} {{p.longitude|floatformat:4}}">{{p.name}} ({{p.country}})</a></li>
 	{% endfor %}
 	</ul>
 {% else %}



Mime
View raw message