Example #1
0
	def post(self):
		user		= utils.get_current_user()
		name		= self.request.get('name', '')
		unix_name	= utils.unix_string(name)
		profile		= Profile.get(self.request.get('profile_key'))
		world		= stores.World.get_by_key_name('w:%s' % unix_name)

		if not name or not profile or not world:
			self.flash.msg = "Unknown World: %s" % name
			self.redirect(self.request.headers['REFERER'])
			return

		page_admin = utils.page_admin(profile.author.user)
		if not page_admin or not world.user_can_post(self.udata):
			self.flash.msg = "Access Denied"
			self.redirect(profile.url)
			return

		connections = profile.worldconnection_set.fetch(6)
		if len(connections) >= 6:
			self.flash.msg = "Profile: %s in too many worlds (Max = 5)" % profile.name
			self.redirect(profile.url)
			return

		if not self.add_profile(world, profile):
			self.flash.msg = "Profile: %s already in World: %s" % (profile.name, world.name)
		else:
			self.flash.msg = "Profile: %s joined World: %s" % (profile.name, world.name)

		self.redirect(profile.url)
Example #2
0
	def post(self, username, name):
		adata	= UserData.load_from_nickname(username)
		author		= adata.user

		choice	= self.request.get('choice')
		name_check	= self.request.get('name_check')
		profile_key = self.request.get('profile_key', '')

		profile = Profile.get(profile_key)

		if not profile:
			self.flash.msg = "Unknown Profile"
			self.redirect(adata.url)
			return

		# Only let admins and the author delete a profile
		if not self.page_admin(self.user):
			self.flash.msg = "Access Denied."
			self.redirect(profile.url)
			return

		if name_check != profile.name or choice != 'Confirm':
			self.flash.msg = "%s: Preserved" % profile.name
			self.redirect(profile.url)
			return

		query = Comment.all()
		query.filter('host =', profile)
		for comment in query:
			comment.delete()
		for conn in profile.worldconnection_set:
			conn.delete()
		# Clear the profile from the memcache.
		#Profile.unload(adata.key_name, profile.unix_name)
		profile.delete()

		c = counter.Counter('TotalProfiles')
		c.increment(-1)
		c = counter.Counter('%sProfiles' % profile.author.key_name, 1)
		c.increment(-1)

		logging.info("%s(%s) deleted %s's Profile (%s)." % (
					 self.user.email(), self.udata.nickname,
					 profile.author.user.email(), profile.name
		))

		framework.unmemoize('/manage/', 'profile_listing', adata.nickname)
		framework.unmemoize('/', 'profile_listing')
		framework.unmemoize('/discover/', 'profile_listing')
		framework.unmemoize('/discover/', 'profile_feed')
		framework.unmemoize(profile.author.url, 'profile_listing')
		framework.unmemoize(profile.author.url, 'profile_feed')

		self.flash.msg = "%s Deleted Sucessfully" % profile.name
		self.redirect(profile.author.url)