Browse Source

#2052 Ability to batch delete system notices

pull/2086/head
Unknwon 9 years ago
parent
commit
0be8b1b1a1
  1. 2
      README.md
  2. 1
      cmd/web.go
  3. 1
      conf/locale/locale_en-US.ini
  4. 2
      gogs.go
  5. 10
      models/admin.go
  6. 4
      modules/bindata/bindata.go
  7. 11
      routers/admin/notice.go
  8. 2
      templates/.VERSION
  9. 3
      templates/admin/notice.tmpl

2
README.md

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

1
cmd/web.go

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

1
conf/locale/locale_en-US.ini

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

2
gogs.go

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

10
models/admin.go

@ -61,3 +61,13 @@ func DeleteNotice(id int64) error {
_, err := x.Id(id).Delete(new(Notice)) _, err := x.Id(id).Delete(new(Notice))
return err 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
}

4
modules/bindata/bindata.go

File diff suppressed because one or more lines are too long

11
routers/admin/notice.go

@ -51,3 +51,14 @@ func DeleteNotice(ctx *middleware.Context) {
ctx.Flash.Success(ctx.Tr("admin.notices.delete_success")) ctx.Flash.Success(ctx.Tr("admin.notices.delete_success"))
ctx.Redirect(setting.AppSubUrl + "/admin/notices") 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")
}

2
templates/.VERSION

@ -1 +1 @@
0.7.24.1201 Beta 0.7.25.1202 Beta

3
templates/admin/notice.tmpl

@ -7,6 +7,9 @@
{{template "base/alert" .}} {{template "base/alert" .}}
<h4 class="ui top attached header"> <h4 class="ui top attached header">
{{.i18n.Tr "admin.notices.system_notice_list"}} ({{.i18n.Tr "admin.total" .Total}}) {{.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> </h4>
<div class="ui attached table segment"> <div class="ui attached table segment">
<table class="ui very basic striped table"> <table class="ui very basic striped table">

Loading…
Cancel
Save