Commits

David Mazary committed ca8b4ea

Fallback to email when PID is hidden. Try telephoneNumber if localPhone hidden.

Comments (0)

Files changed (1)

                 personList = []
                 for person in response:
                     personInfo = person[1]
-                    uupid = personInfo['uupid'][0]
+                    try:
+                        uupid = personInfo['uupid'][0]
+                    except KeyError:
+                        try:
+                            uupid = personInfo['mail'][0].partition('@')[0]
+                        except KeyError:
+                            continue  # Person does not have PID or email
                     name = personInfo['displayName'][0]
                     addr = personInfo['localPostalAddress'][0]
                     geo_loc = google_geocoding.get_location(addr)
                     try:
                         phone = personInfo['localPhone'][0]
                     except KeyError:
-                        phone = None
+                        try:
+                            phone = personInfo['telephoneNumber'][0]
+                        except KeyError:
+                            phone = None
                     try:
                         major = personInfo['major'][0]
                     except KeyError:
                         major = None
-                    newPerson = models.Person(pid = uupid, display_name = name, address = addr, phone_number = phone, \
+                    newPerson = models.Person( \
+                        pid = uupid, display_name = name, \
+                        address = addr, phone_number = phone, \
                         major = major, longitude = lng, latitude = lat)
                     newPerson.save()
                     personList.append(newPerson)