Пример #1
0
func (this *TopicController) Edit() {
	if checkLogin(this.Ctx) {
		id := this.Ctx.Input.Param("0")
		topic, err := models.GetTopic(id)
		if err != nil {
			beego.Error(err)
		}
		categories, err := models.AllCategories(true)
		if err != nil {
			beego.Error(err)
		}
		this.TplNames = "topicForm.html"
		this.Data["headerTitle"] = "Edit Topic"
		this.Data["headerPrefix"] = "修改"
		this.Data["Topic"] = topic
		this.Data["isTopic"] = true
		this.Data["isLogin"] = checkLogin(this.Ctx)
		this.Data["Categories"] = categories
	} else {
		this.Redirect("/login", 302)
	}
}
Пример #2
0
func (this *TopicController) View() {
	this.TplNames = "topicView.html"
	this.Data["headerTitle"] = "View Topics"
	this.Data["isLogin"] = checkLogin(this.Ctx)
	this.Data["isTopic"] = true

	id := this.Ctx.Input.Param("0")
	topic, err := models.GetTopic(id)
	if err != nil {
		beego.Error(err)
	}
	comments, err := models.QueryCommentsByTid(id)
	if err != nil {
		beego.Error(err)
	}
	this.Data["Topic"] = topic
	this.Data["Comments"] = comments
	this.Data["Tags"], err = models.AllTags()
	if err != nil {
		beego.Error(err)
	}
}