コード例 #1
0
ファイル: signup.py プロジェクト: paulsc/lunchdiscussion
    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)
コード例 #2
0
ファイル: utils.py プロジェクト: paulsc/lunchdiscussion
	def initialize(self, request, response):
		self.currentuser = UserInfo.gql("WHERE user = :1", users.get_current_user()).get()
		path = request.path.lstrip('/')
		slashindex = path.find('/')
		if slashindex == -1:
			groupname = path
		else:
			groupname = path[:slashindex]
		self.currentgroup = Group.gql("WHERE shortname = :1", groupname).get()
		
		super(LDContextHandler, self).initialize(request, response)