示例#1
0
// post function
func (self *ManageBlogWaitress) Post(w http.ResponseWriter, r *http.Request, c appengine.Context) {
	// get blog name, noRight
	r.ParseForm()
	blogName := r.FormValue("blogname")
	noRight := false
	if r.FormValue("noRight") == "1" {
		noRight = true
	}
	// set blog name
	blogCube, _ := ds.GetBlogCube(c)
	if blogCube == nil {
		// add a new one
		blogCube = &M.BlogCube{
			BlogName: blogName,
			NoRight:  noRight,
			ID:       "",
		}
		err := ds.AddBlogCube(blogCube, c)
		oops(err, w)
	} else {
		//! edit
		blogCube.BlogName = blogName
		blogCube.NoRight = noRight
		err := ds.EditBlogCube(blogCube, c)
		oops(err, w)
	}
	//
	self.GetApp().GetAppCube()["BlogCube"] = blogCube
	// print success
	printSuccessPage(self.GetApp(), w, r, "更改成功!")
}
示例#2
0
func (self *AppCubeFilter) Filte(w http.ResponseWriter, r *http.Request, c appengine.Context) bool {
	c.Warningf("app cube filte")
	// (self.App.GetAppCube())["BlogName"] = "Core"
	if _, ok := (self.App.GetAppCube())["BlogCube"]; !ok {
		cube, _ := ds.GetBlogCube(c)
		if cube == nil {
			cube = &M.BlogCube{}
			cube.BlogName = "Blog"
			cube.NoRight = false
			ds.AddBlogCube(cube, c)
		}
		self.App.GetAppCube()["BlogCube"] = cube
	}

	return true
}