community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgard...@apache.org
Subject svn commit: r894453 - in /comdev/nearby_people: nearby/views.py templates/pick_place.html
Date Tue, 29 Dec 2009 17:40:51 GMT
Author: rgardler
Date: Tue Dec 29 17:40:51 2009
New Revision: 894453

URL: http://svn.apache.org/viewvc?rev=894453&view=rev
Log:
Prevent the user seeing an error when no location is found with the suggested name.

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

Modified: comdev/nearby_people/nearby/views.py
URL: http://svn.apache.org/viewvc/comdev/nearby_people/nearby/views.py?rev=894453&r1=894452&r2=894453&view=diff
==============================================================================
--- comdev/nearby_people/nearby/views.py (original)
+++ comdev/nearby_people/nearby/views.py Tue Dec 29 17:40:51 2009
@@ -50,19 +50,22 @@
 						lang="EN",
 						maxRows=10,
 			)
-			for res in result.geoname:
-				places.append({
-					'name':res.name,
-					'latitude':res.lat,
-					'longitude':res.lng,
-					'country':res.countryCode
-				})
+			if hasattr(result, "geoname"):
+				for res in result.geoname:
+					places.append({
+						'name':res.name,
+						'latitude':res.lat,
+						'longitude':res.lng,
+						'country':res.countryCode
+					})
+			else:
+				message = "We can't work out the locatoin you mean, please check your request."
 	else:
 		form = PlaceForm()
         form.set_type( request.GET.get("type","") )
 
 	return render(request, "pick_place.html", {
-		'form': form, 'places': places
+		'form': form, 'places': places, "message": message
 	})
 
 def find_people(request):

Modified: comdev/nearby_people/templates/pick_place.html
URL: http://svn.apache.org/viewvc/comdev/nearby_people/templates/pick_place.html?rev=894453&r1=894452&r2=894453&view=diff
==============================================================================
--- comdev/nearby_people/templates/pick_place.html (original)
+++ comdev/nearby_people/templates/pick_place.html Tue Dec 29 17:40:51 2009
@@ -5,6 +5,8 @@
 {% block bodyclass %}pick_place{% endblock %}
 {% block content %}
 
+
+
 {% if places %}
 	<h3>We found several places with that name, we've sorted them by popularity</h3>
 	<h4>Please tell us which one you want?</h4>
@@ -15,7 +17,11 @@
 	{% endfor %}
 	</ul>
 {% else %}
-	<p>To begin, please pick your location.</p>
+    {% if message %}
+      <p>{{message}}</p>
+    {% else %}
+	  <p>To begin, please enter your location.</p>
+	{% endif %}
 {% endif %}
 
 <form action="/pick_place/" method="post">



Mime
View raw message