Exemple #1
0
func (this *TopicController) View() {
	this.TplNames = "topic_view.html"

	topic, err := models.GetTopic(this.Ctx.Input.Param("0"))

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

	replies, err := models.GetAllReplies(this.Ctx.Input.Param("0"))
	if err != nil {
		beego.Error(err)
		return
	}
	this.Data["Replies"] = replies
	this.Data["IsLogin"] = checkAccount(this.Ctx)

	categories, err := models.GetAllCategory()
	if err != nil {
		beego.Error(err)
	}
	this.Data["Categories"] = categories
}
Exemple #2
0
func (c *MainController) Get() {
	c.Data["IsHome"] = true
	c.TplNames = "home.html"
	var err error
	//beego.Debug("cate=", c.Input().Get("cate"))
	c.Data["Topics"], err = models.GetAllTopic(c.Input().Get("cate"), true)
	//beego.Debug("date=", c.Data["Topics"].Created)
	if err != nil {
		beego.Error(err)
	}

	c.Data["IsLogin"] = checkAccount(c.Ctx)

	categories, err := models.GetAllCategory()
	if err != nil {
		beego.Error(err)
	}
	c.Data["Categories"] = categories
}
Exemple #3
0
func (c *CategoryController) Get() {

	c.Data["IsLogin"] = checkAccount(c.Ctx)

	op := c.Input().Get("op")
	switch op {
	case "add":
		name := c.Input().Get("name")
		if len(name) == 0 {
			break
		}
		err := models.AddCategory(name)
		if err != nil {
			beego.Error(err)
		}
		c.Redirect("/category", 302)
	case "del":
		id := c.Input().Get("id")
		if len(id) == 0 {
			break
		}

		err := models.DelCategory(id)
		if err != nil {
			beego.Error(err)
		}
		c.Redirect("/category", 302)
	}

	c.Data["IsCategory"] = true
	c.TplNames = "category.html"

	var err error
	c.Data["Categories"], err = models.GetAllCategory()

	if err != nil {
		beego.Error(err)
	}
}