示例#1
0
	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
示例#2
0
	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()
示例#3
0
	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
示例#4
0
	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()))
示例#5
0
	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))
示例#6
0
	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()))