def get_profile_by_email(self, email): profiles = UserProfile.all() profiles.filter('knownEmail =', email) if profiles.count() == 0: return False for profile in profiles: return profile
def delete(self): user = users.get_current_user() if not user: self.error(400) return profile = UserProfile.get_or_insert(user.user_id()) if profile: profile.delete()
def put_sections_in_dict(self, user): sections = {} profile = UserProfile.get_by_key_name(user.user_id()) enrollments = Enrollment.all().ancestor(profile.currentSchedule) for enrollment in enrollments: section = enrollment.section sections[str(section.key())] = section return sections
def post(self): curUser = users.get_current_user() if not curUser: self.error(400) return json = self.request.get('json') if not json: self.error(400) dataDict = simplejson.loads(json) friendProfileKey = dataDict['friendProfileKey'] friendProfile = UserProfile.get(friendProfileKey) friendship = Friendship() friendship.user1 = UserProfile.get_by_key_name(curUser.user_id()) friendship.user2 = friendProfile friendship.put() self.response.out.write(str(friendship.key()))
def get(self): self.response.headers['Content-Type'] = 'application/json' curUser = users.get_current_user() if not curUser: self.error(400) return userID = curUser.user_id() profile = UserProfile.get_by_key_name(userID) objDict = None if profile: objDict = profile.to_dict() self.response.out.write(simplejson.dumps(objDict))
def post(self): user = users.get_current_user() if not user: self.error(400) return # Create the user's profile, with his ID as its key name profile = UserProfile.get_or_insert(user.user_id()) profile.set_defaults() profile.bind_to_user() json = self.request.get('json') if json: profileDict = simplejson.loads(json) profile.update_from_dict(profileDict) profile.put() self.response.out.write(str(profile.key()))