Example #1
0
	def get(self, nickname):

		if nickname == '':

			self.redirect('/')

		else:

			profile = AccountIO()
			profile.getFromNickname( nickname )

			# Called user doesn't exist
			if not profile.account:

				self.redirect('/')

			else:

				user = AccountIO()
				user.getFromSession()

				posts = PostRead()

				'''if isOwner:
					token = Token()
					token.account = account.key()
					avatar_token  = string.join( random.sample( string.letters + string.digits, 30  ), '' )
					token.code    = avatar_token
					expires = datetime.now() + timedelta( hours = 1 )
					token.expires = expires
					token.put()
				else:
					avatar_token = '' '''


				# Template values
				template_values = {
					'user': user.account,
					'profile': profile.account,
					'profileFollowing': user.isFollowing( profile ),
					'profileFolled': user.isFollowing( profile ),
					'profileMessages': posts.getSentMessages( profile.account ),
					'profileFollowed': profile.getFollowed(),
					'profileFollowers': profile.getFollowers()
				}

				# We get the template path then show it
				path = os.path.join(os.path.dirname(__file__), '../views/profile.html')
				self.response.out.write(template.render(path, template_values))
Example #2
0
	def post(self, follow_nick):
		# Toggle following a user or not
		# Query: User's account & friend's nickname

		user_account = AccountIO()
		user_account.getFromSession()

		# Does that user exist?
		follow_account = AccountIO()
		follow_account.getFromSession()
		if follow_account.account and user_account.account:
			if user_account.isFollowing( follow_account.account ):
				user_account.account.following.remove(follow_account.account.key())
			else:
				user_account.account.following.append(follow_account.account.key())
			user_account.account.put()

		self.redirect('/user/'+follow_nick)