diff options
author | Unknwon <u@gogs.io> | 2015-12-05 01:09:14 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-12-05 01:09:14 -0500 |
commit | f41360d864bfa3fb850d669a0a8321820fc550de (patch) | |
tree | 5450285739bd0be98258474f45d62991dd1429ee /routers/admin/notice.go | |
parent | e82ee40e9e667797099edc05ec1b774f65310464 (diff) | |
download | gitea-f41360d864bfa3fb850d669a0a8321820fc550de.tar.gz gitea-f41360d864bfa3fb850d669a0a8321820fc550de.zip |
#2052 advanced select ops for system notices
Diffstat (limited to 'routers/admin/notice.go')
-rw-r--r-- | routers/admin/notice.go | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/routers/admin/notice.go b/routers/admin/notice.go index 30e3aa6755..39d0abc736 100644 --- a/routers/admin/notice.go +++ b/routers/admin/notice.go @@ -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) { |