コード例 #1
0
ファイル: worlds.py プロジェクト: PatrickKennedy/Sybil
	def get(self):
		logging.info('PROFILE KEY: %r' % self.request.get('profile_key'))
		profile		= Profile.get_by_key_name(self.request.get('profile_key'))
		world 		= World.get_by_key_name(self.request.get('world_key'))

		if not profile:
			self.flash.msg = "Error: Unable to load profile"
			self.redirect('/')
			return

		if not world:
			self.flash.msg = "Error: Unable to load World"
			self.redirect('/')
			return

		page_admin = utils.page_admin(profile.author.user)
		if not page_admin:
			self.flash.msg = "Access Denied"
			self.redirect(self.request.headers['REFERER'])
			return

		self.remove_profile(world, profile)

		self.flash.msg = "Profile: %s removed from World: %s" % (profile.name, world.name)
		self.redirect(profile.url)
コード例 #2
0
ファイル: discover.py プロジェクト: PatrickKennedy/Sybil
		def __fetch_feed_data():
			# Orders the profiles most recently created first.
			q = World.all()
			q.filter('public =', True)
			q.order('-created')

			return q.fetch(12)
コード例 #3
0
ファイル: discover.py プロジェクト: PatrickKennedy/Sybil
	def get(self):
		user = utils.get_current_user()
		sort = self.request.get('sort', 'Time')
		page = self.request.get_range('page', min_value=1, default=1)
		items_per_page = self.request.get_range('items', min_value=1,
												max_value=25, default=10)
		offset = ((page - 1) * items_per_page)
		last_page = True

		link_template = '<a href="%s">%s</a>'
		sort_links = [link_template % (self.filter_args(['sort', 'page'], sort='Time'), 'Time')]
		for letter in string.ascii_uppercase:
			sort_links.append(link_template % (self.filter_args(['sort', 'page'], sort=letter), letter))

		world_list = []
		query = World.all()
		query.filter('public =', True)
		if sort == 'Time':
			query.order('-created')
		else:
			query.filter('name >', sort)
			query.filter('name <', sort+'\x77\x78\x79')

		world_list = query.fetch((items_per_page + 1), offset)
		if len(world_list) > items_per_page:
			last_page = False
			world_list.pop()

		self.render(['discover', 'discoverworld'], locals())
コード例 #4
0
ファイル: update.py プロジェクト: PatrickKennedy/Sybil
	def world_members(self, who):
		world = World.get(who)
		counter_data = self.counter_data

		cls = stores.WorldMember
		counter_data['cls'] = cls
		counter_data['counter_name'] = '%sWorldMembers' % world.key_name
		counter_data['counter_shards'] = 1
		counter_data['flash_msg'] = "%s's Members Counted" % world.name

		def init_logic():
			"""Return a seed object to use a key from."""
			return cls.gql(
				'WHERE world = :1 ORDER BY __key__', world).get()

		def query_logic(last_key):
			"""Return a query."""
			return cls.gql(
				'WHERE world = :1 AND __key__ >= :2 ORDER BY __key__',
				world, last_key
			)

		counter_data['init_logic'] = init_logic
		counter_data['query_logic'] = query_logic
		self.generic_counter()
		self.generic_counter()
コード例 #5
0
ファイル: discover.py プロジェクト: PatrickKennedy/Sybil
	def get(self):
		query = Profile.all()
		query.filter('public =', True)
		query.order('-created')
		recent_profiles = query.fetch(5)

		query = World.all()
		query.filter('public =', True)
		query.order('-created')
		recent_worlds = query.fetch(5)

		self.render(['index', 'indexdiscover'], locals())
コード例 #6
0
ファイル: main.py プロジェクト: PatrickKennedy/Sybil
		def __fetch_world_data():
			query = World.all()
			query.filter('public =', True)
			query.order('-created')
			return query.fetch(5)
コード例 #7
0
ファイル: worlds.py プロジェクト: PatrickKennedy/Sybil
	def get(self, action):
		get = self.request.get
		key_name = get('key_name')
		world = World.get_by_key_name(key_name)

		if not world:
			self.flash.msg = "Unknown World"
			self.redirect('/')
			return

		if get("submit_action", "") == "Cancel":
			self.flash.msg = "%s: Changes Not Saved" % world.name
			self.redirect(world.url)
			return

		if not utils.page_admin(world.author.user) and action != "dismiss_members":
			self.flash.msg = "Access Denied"
			self.redirect(world.url)
			return

		if action == 'add_members':
			members = self.request.get('members', '').split(' ')
			for member in members:
				if member:
					result = self.add_member(world, member)
					if result ==  "Unknown User":
						self.flash.msg = "Unknown User: %s" % member
						self.redirect(world.url)
						return

			self.flash.msg = "User: %s added to World: %s" % (', '.join(members), world.name)
			self.redirect(world.url)
			return

		elif action == 'dismiss_members':
			removed = []
			members = self.request.get('members', '').split(' ')
			for member in members:
				if member:
					result = self.remove_member(world, member)
					if result is True:
						removed.append(member)
					# Silly Easter Egg message to Amanda
					elif result == 'Amanda':
						logging.info('Amanda Message')
						self.flash.msg = "You just can\\\'t get rid of me, Amanda &lt;3"
						self.redirect(world.url)
						return

			self.flash.msg = "User: %s removed from World: %s" % (', '.join(removed), world.name)
			self.redirect(world.url)
			return

		get = self.request.get
		world.about = get('about', '')
		world.links = get('links', '')
		world.common = get('common', '')
		world.open	= get('open', 'True') == 'True'
		world.public = get('public', 'True') == 'True'
		world.markup = get('markup', 'Textile')
		world.put()

		self.flash.msg = "World: %s Saved" % world.name
		self.redirect(world.url)