Commits

Johnny Goodnow committed b68e53a

* Created new db schema and set up for query to store new models with lat and lon
currently = 0.

Comments (0)

Files changed (3)

geolocator/models.py

 class Person(models.Model):
 	pid = models.CharField(max_length = 50, primary_key = True)
 	display_name = models.CharField(max_length = 30)
-	address = models.CharField(max_length = 80)
-	city = models.CharField(max_length = 60)
-	state = models.CharField(max_length = 30)
-	zipcode = models.PositiveSmallIntegerField()
+	address = models.CharField(max_length = 120)
 	phone_number = models.PositiveIntegerField(null = True)
 	major = models.CharField(max_length = 30, null = True)
 	longitude = models.FloatField()

geolocator/views.py

             query = form.cleaned_data
             reader = Ldap_Reader(query['term'], query['filter_type'])
             response = reader.get()
+			for person in response:
+				personInfo = person[1]
+				uupid = personInfo['uupid'][0]
+				name = personInfo['displayName'][0]
+				addr = personInfo['localPostalAddress'][0]
+				try:
+					phone = personInfo['localPhone'][0]
+				except KeyError:
+					phone = None
+				try:
+					major = personInfo['major'][0]
+				except KeyError:
+					major = None
+				lng = 0 #Need to set to geolocated values
+				lat = 0 #Need to set to geolocated values
+				newPerson = models.Person(pid = uupid, display_name = name, address = addr, phone_number = phone, \
+					major = major, longitude = lng, latitude = lat)
+				newPerson.save()
+				
             return HttpResponseRedirect('/')
     else:
         form = forms.HokieFinderForm()

resources/database/hokiefinderdb.sqlite3

Binary file modified.