예제 #1
0
func DevCommentSave(w http.ResponseWriter, r *http.Request, c *web.Context) {
	if !c.CheckAuth(w, r, "/login", "admin", "developer") {
		return
	}
	comment := service.FindOneComment(c.GetPathVar("id"))
	closed, _ := strconv.ParseBool(r.FormValue("closed"))
	comment.Closed = closed
	service.SaveComment(comment)
	http.Redirect(w, r, "/dev/comment", 303)
}
예제 #2
0
func PostComment(w http.ResponseWriter, r *http.Request, c *web.Context) {
	comment := service.Comment{
		Id:     util.UUID4(),
		Com:    r.FormValue("comment"),
		Url:    r.FormValue("return"),
		Name:   r.FormValue("name"),
		Closed: false,
	}
	service.SaveComment(comment)
	c.SetFlash("alertSuccess", "Successfully save your comment")
	http.Redirect(w, r, r.FormValue("return"), 303)
}