Ejemplo n.º 1
0
	def post(self):
		action = self.request.get("action")
		# logging.info("action = %s", action)
		if action == "":
			name = self.request.get("name", "")
			desc = self.request.get("desc", "")

			if name == "":
				self.redirect('/groups/')
				return

			group = Group.new_group(name=name, desc=desc, )
			if group is None:
				# group already existed and you are not the owner
				return self.redirect('/mygroups/')

			self.redirect('/group/?name=%s' % group.name)
			return
		elif action == "delete":
			name = self.request.get("name")
			group = Group.get_by_key_name(name)
			if group is None:
				self.redirect('/groups/')

			user = UserData.current()
			# only the owner can delete the group
			if group.owner.user_id == user.user_id:
				group.delete()

		self.redirect('/groups/')
		return
Ejemplo n.º 2
0
	def get(self):
		name = self.request.get('name', "")
		if name is None or name == "":
			self.redirect('/groups/')
			return
		# key = db.Key.from_path("Group", name)
		# group = db.get(key)
		group = Group.get_by_key_name(name)
		if group is None:
			self.redirect('/groups/')
			return
		self.render("groupview.html", group=group)