Ejemplo n.º 1
0
func (this *TopicController) Modify() {
	if !checkCookie(this.Ctx) {
		this.Redirect("/login", 302)
		return
	}
	this.Data["isLogin"] = "******"
	tid := this.Ctx.Input.Param("0")
	var err error
	this.Data["Topic"], err = models.QueryTopic(tid, true)
	this.Data["Categories"], err = models.QueryCategories(true)
	if err != nil {
		beego.Error(err)
		this.Redirect("/", 302)
		return
	}

	this.TplNames = "modifyTopic.html"
	this.Data["Tid"] = tid
}
Ejemplo n.º 2
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
	}
}