Пример #1
0
//Get sidebar bulletin information
func (this *PostListRouter) setSidebarBuilletinInfo() {
	var bulletins []models.Bulletin
	qs := models.Bulletins().OrderBy("Created")
	models.ListObjects(qs, &bulletins)

	var friendLinks []models.Bulletin
	var newComers []models.Bulletin
	var mobileApps []models.Bulletin
	var openSources []models.Bulletin

	for _, bulletin := range bulletins {
		switch bulletin.Type {
		case setting.BULLETIN_FRIEND_LINK:
			friendLinks = append(friendLinks, bulletin)
		case setting.BULLETIN_NEW_COMER:
			newComers = append(newComers, bulletin)
		case setting.BULLETIN_MOBILE_APP:
			mobileApps = append(mobileApps, bulletin)
		case setting.BULLETIN_OPEN_SOURCE:
			openSources = append(openSources, bulletin)
		}
	}
	this.Data["FriendLinks"] = friendLinks
	this.Data["NewComers"] = newComers
	this.Data["MobileApps"] = mobileApps
	this.Data["OpenSources"] = openSources
}
Пример #2
0
func (this *BulletinAdminRouter) List() {
	var bulletins []models.Bulletin
	qs := models.Bulletins().OrderBy("Type")
	if err := this.SetObjects(qs, &bulletins); err != nil {
		this.Data["Error"] = err
		beego.Error(err)
	}
}
Пример #3
0
func (this *BulletinAdminRouter) Delete() {
	if this.FormOnceNotMatch() {
		return
	}
	qs := models.Bulletins().Filter("Id", this.object.Id)
	cnt, _ := qs.Count()
	if cnt > 0 {
		// delete object
		if err := this.object.Delete(); err == nil {
			this.FlashRedirect("/admin/bulletin", 302, "DeleteSuccess")
			return
		} else {
			beego.Error(err)
			this.Data["Error"] = err
		}
	}

}
Пример #4
0
func (this *BaseAdminRouter) ObjectQs() orm.QuerySeter {
	return models.Bulletins()
}