0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-11-28 18:12:53 +01:00

#2052 Ability to batch delete system notices

This commit is contained in:
Unknwon 2015-12-01 23:33:08 -05:00
parent 834d38a8fb
commit 0be8b1b1a1
9 changed files with 32 additions and 6 deletions

View file

@ -5,7 +5,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
![](public/img/gogs-large-resize.png)
##### Current version: 0.7.24 Beta
##### Current version: 0.7.25 Beta
<table>
<tr>

View file

@ -338,6 +338,7 @@ func runWeb(ctx *cli.Context) {
m.Group("/notices", func() {
m.Get("", admin.Notices)
m.Get("/:id:int/delete", admin.DeleteNotice)
m.Get("/empty", admin.EmptyNotices)
})
}, adminReq)
// ***** END: Admin *****

View file

@ -983,6 +983,7 @@ monitor.start = Start Time
monitor.execute_time = Execution Time
notices.system_notice_list = System Notices
notices.empty_all = Remove All Notices
notices.type = Type
notices.type_1 = Repository
notices.desc = Description

View file

@ -17,7 +17,7 @@ import (
"github.com/gogits/gogs/modules/setting"
)
const APP_VER = "0.7.24.1201 Beta"
const APP_VER = "0.7.25.1202 Beta"
func init() {
runtime.GOMAXPROCS(runtime.NumCPU())

View file

@ -61,3 +61,13 @@ func DeleteNotice(id int64) error {
_, err := x.Id(id).Delete(new(Notice))
return err
}
// DeleteNotices deletes all notices with ID from start to end (inclusive).
func DeleteNotices(start, end int64) error {
sess := x.Where("id >= ?", start)
if end > 0 {
sess.And("id <= ?", end)
}
_, err := sess.Delete(new(Notice))
return err
}

File diff suppressed because one or more lines are too long

View file

@ -47,7 +47,18 @@ func DeleteNotice(ctx *middleware.Context) {
ctx.Handle(500, "DeleteNotice", err)
return
}
log.Trace("System notice deleted by admin(%s): %d", ctx.User.Name, id)
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) {
if err := models.DeleteNotices(0, 0); err != nil {
ctx.Handle(500, "DeleteNotices", err)
return
}
log.Trace("System notices deleted by admin (%s): [start: %d]", ctx.User.Name, 0)
ctx.Flash.Success(ctx.Tr("admin.notices.delete_success"))
ctx.Redirect(setting.AppSubUrl + "/admin/notices")
}

View file

@ -1 +1 @@
0.7.24.1201 Beta
0.7.25.1202 Beta

View file

@ -7,6 +7,9 @@
{{template "base/alert" .}}
<h4 class="ui top attached header">
{{.i18n.Tr "admin.notices.system_notice_list"}} ({{.i18n.Tr "admin.total" .Total}})
<div class="ui right">
<a class="ui red tiny button" href="{{AppSubUrl}}/admin/notices/empty">{{.i18n.Tr "admin.notices.empty_all"}}</a>
</div>
</h4>
<div class="ui attached table segment">
<table class="ui very basic striped table">