community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1745369 - in /comdev/nearby_people: lib/geoname.py nearby/forms.py nearby/views.py templates/people.html
Date Tue, 24 May 2016 14:44:46 GMT
Author: nick
Date: Tue May 24 14:44:45 2016
New Revision: 1745369

URL: http://svn.apache.org/viewvc?rev=1745369&view=rev
Log:
Better form defaults, and make the search type clearer in the results page

Modified:
    comdev/nearby_people/lib/geoname.py
    comdev/nearby_people/nearby/forms.py
    comdev/nearby_people/nearby/views.py
    comdev/nearby_people/templates/people.html

Modified: comdev/nearby_people/lib/geoname.py
URL: http://svn.apache.org/viewvc/comdev/nearby_people/lib/geoname.py?rev=1745369&r1=1745368&r2=1745369&view=diff
==============================================================================
--- comdev/nearby_people/lib/geoname.py (original)
+++ comdev/nearby_people/lib/geoname.py Tue May 24 14:44:45 2016
@@ -8,7 +8,10 @@ import urllib2
 try:
     from simplejson import loads as json_parse
 except ImportError:
-    from json import read as json_parse
+    try:
+        from json import loads as json_parse
+    except ImportError:
+        from json import read as json_parse
 
 DOMAIN = 'http://api.geonames.org/'
 USERNAME = '' #enter your geonames username here

Modified: comdev/nearby_people/nearby/forms.py
URL: http://svn.apache.org/viewvc/comdev/nearby_people/nearby/forms.py?rev=1745369&r1=1745368&r2=1745369&view=diff
==============================================================================
--- comdev/nearby_people/nearby/forms.py (original)
+++ comdev/nearby_people/nearby/forms.py Tue May 24 14:44:45 2016
@@ -17,20 +17,24 @@
 
 from django import forms
 
-class PlaceForm(forms.Form):
-    place_name = forms.CharField()
-    type = forms.TypedChoiceField(choices=(
+types_field = forms.TypedChoiceField(choices=(
         ('','Default (Local Mentors)'), ('lm','Local Mentors'),
         ('sp','Speakers'),
-      ), 
-      required=False,
-      widget=forms.HiddenInput,
-      label="Type of Person",
-    )
-    rows = forms.IntegerField(
-      required = False, 
-      initial = 10, 
-      widget=forms.HiddenInput,)
+    ), 
+    required=False,
+    widget=forms.HiddenInput,
+    label="Type of Person"
+)
+rows_field = forms.IntegerField(
+    required = False, 
+    initial = 10, 
+    widget=forms.HiddenInput
+)
+
+class PlaceForm(forms.Form):
+    place_name = forms.CharField()
+    type = types_field
+    rows = rows_field
     
     def set_type(self, type):
       for opt,name in self.fields["type"].choices:
@@ -45,4 +49,5 @@ class PlaceForm(forms.Form):
 class LocationForm(forms.Form):
     latitude = forms.FloatField()
     longitude = forms.FloatField()
-
+    type = types_field
+    rows = rows_field

Modified: comdev/nearby_people/nearby/views.py
URL: http://svn.apache.org/viewvc/comdev/nearby_people/nearby/views.py?rev=1745369&r1=1745368&r2=1745369&view=diff
==============================================================================
--- comdev/nearby_people/nearby/views.py (original)
+++ comdev/nearby_people/nearby/views.py Tue May 24 14:44:45 2016
@@ -89,14 +89,14 @@ def retrieve_people_data(form):
    # What do they want?
    foaf = comdev_foaf
    people_type = "Local Mentors"
-   if form.data["type"] == "sp":
+   if form.data.get("type",None) == "sp":
       foaf = speakers_foaf
       people_type = "Speakers"
 
    search_data = form.data
    search_latitude = float(search_data["latitude"])
    search_longitude = float(search_data["longitude"])
-   rows = int(search_data["rows"])
+   rows = int(search_data.get("rows", form.fields["rows"].initial))
    people = foaf.get_nearby(search_latitude, search_longitude, rows)
 
    # Work out the people.apache.org links for people

Modified: comdev/nearby_people/templates/people.html
URL: http://svn.apache.org/viewvc/comdev/nearby_people/templates/people.html?rev=1745369&r1=1745368&r2=1745369&view=diff
==============================================================================
--- comdev/nearby_people/templates/people.html (original)
+++ comdev/nearby_people/templates/people.html Tue May 24 14:44:45 2016
@@ -2,8 +2,8 @@
 {% load distances %}
 {% load emails %}
 
-{% block title %}People Near You{% endblock %}
-{% block heading %}People Near You{% endblock %}
+{% block title %}- {{people_type}} Near You{% endblock %}
+{% block heading %}Apache {{people_type}} Near You{% endblock %}
 {% block bodyclass %}people{% endblock %}
 {% block extrahead %}
 



Mime
View raw message