Esempio n. 1
0
func (this *AdminTopicController) Edit() {

	id := this.Input().Get("id")

	if len(id) == 0 {
		return
	}

	var err error
	this.Data["Topic"], err = models.GetOneTopic(id)

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

	this.Data["Categories"], err = models.GetAllCategories()

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

	this.Data["PageTitle"] = "Eidt Topic"
	this.Data["IsTopic"] = true
	this.Layout = "layout/admin_layout.tpl"
	this.TplNames = "admin_topic/edit.tpl"
}
Esempio n. 2
0
func (this *HomeController) Get() {

	var err error
	this.Data["Topics"], err = models.GetAllTopic()

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

	this.Data["Categories"], err = models.GetAllCategories()

	if err != nil {
		beego.Error(err)
	}
	this.Data["PageTitle"] = "Home"
	this.Layout = "layout/layout.tpl"
	this.TplNames = "home/index.tpl"
}
Esempio n. 3
0
func (this *CategoryController) Get() {

	var err error
	this.Data["Categories"], err = models.GetAllCategories()

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

	this.Data["Topics"], err = models.GetTopicByCategoryId(this.Input().Get("id"), "")

	if err != nil {
		beego.Error(err)
	}
	this.Data["PageTitle"] = "Category List"
	this.Layout = "layout/layout.tpl"
	this.TplNames = "category/index.tpl"
}
Esempio n. 4
0
func (this *CategoryController) Get() {

	op := this.Input().Get("op")
	switch op {
	case "add":
		name := this.Input().Get("name")
		if len(name) == 0 {
			break
		}

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

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

	}

	this.Data["IsCategory"] = true
	this.TplName = "category.html"
	this.Data["IsLogin"] = checkAccount(this.Ctx)

	var err error
	this.Data["Categories"], err = models.GetAllCategories()
	if err != nil {
		beego.Error(err)
	}
}
Esempio n. 5
0
func (this *AdminTopicController) Add() {

	if isSignIn, admin := CheckAccount(this.Ctx); isSignIn {
		var err error
		this.Data["Categories"], err = models.GetAllCategories()

		if err != nil {

			beego.Error(err)
		}

		this.Data["Admin"] = admin
		this.Data["IsTopic"] = true
		this.Data["PageTitle"] = "Add Topic"
		this.Layout = "layout/admin_layout.tpl"
		this.TplNames = "admin_topic/add.tpl"
	} else {
		this.Redirect("/adminhome", 301)
	}

}
Esempio n. 6
0
func (this *AdminCategoryController) Get() {

	if isSignIn, admin := CheckAccount(this.Ctx); isSignIn {

		op := this.Input().Get("op")

		switch op {

		case "add":

			title := this.Input().Get("title")

			if len(title) == 0 {
				break
			}

			err := models.AddCategory(title)

			if err != nil {

				beego.Error(err)
			}

			this.Redirect("./admincategory", 301)
			return

		case "del":

			id := this.Input().Get("id")

			if len(id) == 0 {
				break
			}

			err := models.DelCategory(id)

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

			this.Redirect("./admincategory", 301)
			return
		}

		this.Data["PageTitle"] = "CategoryManager"
		this.Data["Admin"] = admin
		this.Data["IsCategory"] = true

		var err error
		this.Data["Categories"], err = models.GetAllCategories()

		if err != nil {

			beego.Error(err)
		}

		this.Layout = "layout/admin_layout.tpl"
		this.TplNames = "admin_category/index.tpl"
	} else {

		this.Redirect("/adminlogin", 301)
		return
	}
}