Esempio n. 1
0
func (c *TopicController) Modify() {
	// account, err := c.Ctx.Request.Cookie("account")
	// if err != nil {
	// 	beego.Error(err)
	// 	c.Redirect("/login", 301)
	// 	return
	// }

	c.TplNames = "topic_modify.html"
	tid := c.Input().Get("tid")
	//c.Data["IsLogin"] = checkAccount(c.Ctx)
	topic, err := models.GetTopicByID(tid)
	if err != nil {
		beego.Error(err)
		c.Redirect("/", 302)
		return
	}

	account := fmt.Sprintf("%v", c.GetSession("account"))
	name, _ := models.GetUserName(account)
	if len(name) == 0 {
		c.Redirect("/login?exit=true", 302)
	}
	c.Data["Name"] = name

	c.Data["Topic"] = topic
	c.Data["Tid"] = tid
	// c.Data["Account"] = account.Value
}
Esempio n. 2
0
func (c *TopicController) View() {
	c.TplNames = "topic_view.html"
	c.Data["IsLogin"] = checkAccount(c.Ctx)

	topic, err := models.GetTopicByID(c.Ctx.Input.Param("0"))
	if err != nil {
		beego.Error(err)
		c.Redirect("/", 302)
	}

	account := fmt.Sprintf("%v", c.GetSession("account"))
	name, _ := models.GetUserName(account)
	if len(name) == 0 {
		name = "游客"
	}
	c.Data["Name"] = name

	fmt.Printf("account = %v\ttopic.account = %v\n", account, topic.Account)
	if account == topic.Account {
		c.Data["Ishost"] = true
	} else {
		c.Data["Ishost"] = false
	}

	c.Data["Topic"] = topic
	c.Data["Tid"] = c.Ctx.Input.Param("0")

	replys, err := models.GetTopicReplys(c.Ctx.Input.Param("0"))
	if err != nil {
		beego.Error(err)
		c.Redirect("/", 302)
	}

	c.Data["Replys"] = replys
}