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 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): 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()))