#2052 advanced select ops for system notices

This commit is contained in:
Unknwon 2015-12-05 01:09:14 -05:00
parent e82ee40e9e
commit f41360d864
13 changed files with 186 additions and 54 deletions

View file

@ -5,6 +5,7 @@
package admin
import (
"github.com/Unknwon/com"
"github.com/Unknwon/paginater"
"github.com/gogits/gogs/models"
@ -41,15 +42,23 @@ func Notices(ctx *middleware.Context) {
ctx.HTML(200, NOTICES)
}
func DeleteNotice(ctx *middleware.Context) {
id := ctx.ParamsInt64(":id")
if err := models.DeleteNotice(id); err != nil {
ctx.Handle(500, "DeleteNotice", err)
return
func DeleteNotices(ctx *middleware.Context) {
strs := ctx.QueryStrings("ids[]")
ids := make([]int64, 0, len(strs))
for i := range strs {
id := com.StrTo(strs[i]).MustInt64()
if id > 0 {
ids = append(ids, id)
}
}
if err := models.DeleteNoticesByIDs(ids); err != nil {
ctx.Flash.Error("DeleteNoticesByIDs: " + err.Error())
ctx.Status(500)
} else {
ctx.Flash.Success(ctx.Tr("admin.notices.delete_success"))
ctx.Status(200)
}
log.Trace("System notice deleted by admin (%s): %d", ctx.User.Name, id)
ctx.Flash.Success(ctx.Tr("admin.notices.delete_success"))
ctx.Redirect(setting.AppSubUrl + "/admin/notices")
}
func EmptyNotices(ctx *middleware.Context) {