コード例 #1
0
ファイル: user.py プロジェクト: kruser/zualoo
def updateProfile(profileVO):
	user = users.get_current_user()
	
	if user:
		# Does the profile already exist?
		if profileVO.key == None:
			# No, create a new profile.
			profile = UserProfile()
			#logging.info("Creating a new profile!")
		else:
			# Yes, get the existing profile from the data store.
			profile = UserProfile.get(profileVO.key)
			#logging.debug("Updating existing profile...")
			
		# Update and save the profile.
		profile.user = user
		profile.name = profileVO.name
		profile.url = profileVO.url
		
		try:
			profile.description = profileVO.description
		except AttributeError:
			#logging.info("Profile description was empty, so we're skipping it.")
			pass

		profile.save()
			
		return {'name': profile.name, 'url': profile.url, 'description': profile.description, 'key': profileVO.key}
	
	return False
コード例 #2
0
ファイル: photo.py プロジェクト: kruser/zualoo
def uploadByteArray(byteArray):
    """ 
	Allows the upload of a PNG encoded as a ByteArray from Flash for 
	authenticated users. (This is used to upload cropped images from Flash.)
	"""
    user = users.get_current_user()

    # Does a photo entry exist for this user?
    photo = Photo.all().filter("user ="******"Cropped bytearray"
    photo.fileSize = len(byteArray)
    photo.fileType = "PNG"
    photo.authToken = ""
    photo.put()

    userProfile = UserProfile.all().filter("user = ", user).get()

    userProfile.hasPhoto = True
    userProfile.photo = photo
    userProfile.put()
コード例 #3
0
ファイル: photo.py プロジェクト: kruser/zualoo
	def post(self):
		authToken = self.request.get('authToken')
		
		photo = Photo.all().filter("authToken = ", authToken).get()

		#if photo == None:
		#	photo = Photo()
		#	photo.user = user

		if photo:
			logging.info("Storing photo...")
			photo.ip = self.request.remote_addr
		
			image = self.request.get('upload')

			photo.fileBlob = db.Blob(image)	
			photo.put()
			
			# Until the user crops the photo, set their hasPhoto to false 
			# so that uncropped photos don't show up in the stream.
			userProfile = UserProfile.all().filter("user = "******"Error: No such photo.")
			# Unauthorized	
			self.error(401)
コード例 #4
0
ファイル: user.py プロジェクト: kruser/zualoo
def getRecentUsersWithPhotos():
	
	# Profiles with photos created in the last 12 hours.
	# last12Hours = datetime.utcnow()-timedelta(hours=12)
	# .filter('modifiedAt > ', last12Hours)
	userProfileQuery = UserProfile.all().filter('hasPhoto = ', True).order('-modifiedAt')
	
	# Get the last 10.
	results = userProfileQuery.fetch(10)
	
	# Make an array of the results (PyAMF is currently choking on result sets from the
	# DataStore)
	resultsArray = [];	
	for result in results:
		resultsArray.append({'name': result.name, 'url': result.url, 'description': result.description, 'photo': amf3.ByteArray(result.photo.fileBlob)})

	# An ArrayCollection is even better :) 
	resultsArrayCollection = flex.ArrayCollection(resultsArray)

	return resultsArrayCollection
	
	
	
コード例 #5
0
ファイル: user.py プロジェクト: kruser/zualoo
def login(base_url, login_return_url):
		
	user = users.get_current_user()

	# The user value object (VO) contains login and logout URLs.
	# (With /gateway stripped out so that it returns to the SWF). 
	
	urls = getUrls(base_url, login_return_url)
	
	user_vo = {
		'login': urls['login'],
		'logout': urls['logout'],
		'auth': False
	}
	
	if user:
		# Add the user object to the user VO.
		user_vo['user'] = user
		user_vo['auth'] = True
		
		# Get the user's profile from the database
		profile = UserProfile.all().filter('user ='******'profile'] = {
			'name': profile.name,
			'url': profile.url,
			'description': profile.description,
			'key': str(profile.key())
		}

	return user_vo