Exemple #1
0
// view for list model data
func (this *CategoryAdminRouter) List() {
	var cats []models.Category
	qs := models.Categories().RelatedSel()
	if err := this.SetObjects(qs, &cats); err != nil {
		this.Data["Error"] = err
		beego.Error(err)
	}
}
Exemple #2
0
func (form *CategoryAdminForm) Valid(v *validation.Validation) {
	qs := models.Categories()

	if models.CheckIsExist(qs, "Name", form.Name, form.Id) {
		v.SetError("Name", "admin.field_need_unique")
	}

	if models.CheckIsExist(qs, "Slug", form.Slug, form.Id) {
		v.SetError("Slug", "admin.field_need_unique")
	}
}
Exemple #3
0
func ListCategories(cats *[]models.Category) (int64, error) {
	return models.Categories().OrderBy("-order").All(cats)
}
Exemple #4
0
func (this *CategoryAdminRouter) ObjectQs() orm.QuerySeter {
	return models.Categories().RelatedSel()
}