Exemple #1
0
 def location(self):
     loc = Location.get_by_key_name(self.location_id)
     
     if loc:
         return loc.name
     else:
         return ""
Exemple #2
0
 def get_all_locations(self):
     locations = []
     points = []
     
     for user in User.all():
         if user.location_id != 0 and not user.location_id in locations:
             locations.append(str(user.location_id))
     
     locations = [loc for loc in Location.get_by_key_name(locations) if loc != None]
     
     for location in locations:
         points.append({
             "point": [location.lat(), location.lng()],
             "name": location.name
         })
         
     return simplejson.dumps(points)
Exemple #3
0
 def create(self, facebook):
     me = facebook.api(u'/me', {u'fields': USER_FIELDS})
     friends = [user[u'id'] for user in me[u'friends'][u'data']]
     
     location = me.get(u'location')
     hometown = me.get(u'hometown')
     
     if location:
         location_id = int(location[u'id'])
     elif hometown:
         location_id = int(hometown[u'id'])
     else:
         location_id = 0
         
     location_id = str(location_id)
     
     if location_id != "0" and not Location.get_by_key_name(location_id):
         Location.create(location_id, facebook)
     
     user = User(
         key_name=facebook.user_id,
         user_id=facebook.user_id,
         dirty=False,
         
         name=me.get(u'name'),
         first_name=me.get(u'first_name'),
         last_name=me.get(u'last_name'),
         gender=me.get(u'gender'),
         
         username=me.get(u'username'),
         email=me.get(u'email'),
         picture=me.get(u'picture'),
         link=me.get(u'link'),
         
         friends=friends,
         location_id=location_id,
         access_token=facebook.access_token,
     )
     user.put()
     
     return user