Ejemplo n.º 1
0
func (this *ReplyController) Delete() {
	tid := this.Ctx.Input.Param("0")
	id := this.Ctx.Input.Param("1")

	err := models.DeleteComment(id, tid)
	if err != nil {
		this.Redirect("/", 302)
		return
	}

	this.Data["Comments"], err = models.GetAllComments(tid)
	this.Redirect("/topic/view/"+tid, 302)
	return
}
Ejemplo n.º 2
0
func (this *ReplyController) Add() {
	tid := this.Input().Get("topicId")
	nickname := this.Input().Get("nickname")
	content := this.Input().Get("content")

	err := models.AddComment(tid, nickname, content)
	if err != nil {
		this.Redirect("/", 302)
		return
	}

	this.Data["Comments"], err = models.GetAllComments(tid)
	this.Redirect("/topic/view/"+tid, 302)
	return
}
Ejemplo n.º 3
0
func (this *TopicController) View() {
	this.Data["isLogin"] = checkCookie(this.Ctx)
	this.TplNames = "viewTopic.html"
	tid := this.Ctx.Input.Param("0")

	topic, err := models.QueryTopic(tid, false)
	if err != nil {
		beego.Error(err)
		this.Redirect("/", 302)
		return
	}

	this.Data["Topic"] = topic
	this.Data["Tid"] = this.Ctx.Input.Param("0")
	this.Data["Comments"], err = models.GetAllComments(tid)
	this.Data["Labels"] = strings.Split(topic.Labels, " ")
	if err != nil {
		beego.Error(err)
		this.Redirect("/", 302)
		return
	}
}