Esempio n. 1
0
    def post(self):
        group_shortname = cgi.escape(self.request.get("group_shortname"))

        if re.match(RE_GROUPNAME, group_shortname) == None:
            self.error("groups short name has to be alphanumeric with " "underscores and at least 3 characters long")
            return

        group = Group.gql("WHERE shortname=:1", group_shortname).get()

        if group != None:
            self.error("group name in use")
            return

        group_fullname = cgi.escape(self.request.get("group_fullname"))
        if group_fullname == "":
            context = {"group_shortname": group_shortname}
            self.render("create_group", context)
            return

        userinfo = self.currentuser
        if userinfo == None:
            userinfo = UserInfo()
            userinfo.put()

        group = Group(shortname=group_shortname, fullname=group_fullname, creator=userinfo)
        group.put()

        relationship = GroupUserInfo(group=group, user=userinfo, groupname=group.shortname)
        relationship.put()

        if userinfo.lastposted == None:
            self.redirect("/profile")
            return

        self.redirect("/" + group.shortname)
Esempio n. 2
0
	def get(self, uuid):
		invite = InviteCode.gql("WHERE uuid=:1", uuid).get()
		if invite == None:
			logging.error("invite not found: " + uuid)
			self.error(500)
			return

		if self.currentuser == None:
			self.currentuser = UserInfo(user=users.get_current_user())
			self.currentuser.put()
			
		relationship = GroupUserInfo.gql("WHERE user=:1 AND group=:2", self.currentuser, invite.group).get()
		if relationship == None:
			relationship = GroupUserInfo(user=self.currentuser, group=invite.group, 
										 groupname=invite.group.shortname)
			relationship.put()
			
		invite.delete()
			
		if is_empty(self.currentuser.nickname):
			self.render('edit_profile')
			return
		
		self.redirect('/' + invite.group.shortname)