notice.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package admin
  5. import (
  6. "net/http"
  7. "github.com/unknwon/com"
  8. "github.com/unknwon/paginater"
  9. log "unknwon.dev/clog/v2"
  10. "gogs.io/gogs/internal/conf"
  11. "gogs.io/gogs/internal/context"
  12. "gogs.io/gogs/internal/db"
  13. )
  14. const (
  15. NOTICES = "admin/notice"
  16. )
  17. func Notices(c *context.Context) {
  18. c.Title("admin.notices")
  19. c.Data["PageIsAdmin"] = true
  20. c.Data["PageIsAdminNotices"] = true
  21. total := db.CountNotices()
  22. page := c.QueryInt("page")
  23. if page <= 1 {
  24. page = 1
  25. }
  26. c.Data["Page"] = paginater.New(int(total), conf.UI.Admin.NoticePagingNum, page, 5)
  27. notices, err := db.Notices(page, conf.UI.Admin.NoticePagingNum)
  28. if err != nil {
  29. c.Error(err, "list notices")
  30. return
  31. }
  32. c.Data["Notices"] = notices
  33. c.Data["Total"] = total
  34. c.Success(NOTICES)
  35. }
  36. func DeleteNotices(c *context.Context) {
  37. strs := c.QueryStrings("ids[]")
  38. ids := make([]int64, 0, len(strs))
  39. for i := range strs {
  40. id := com.StrTo(strs[i]).MustInt64()
  41. if id > 0 {
  42. ids = append(ids, id)
  43. }
  44. }
  45. if err := db.DeleteNoticesByIDs(ids); err != nil {
  46. c.Flash.Error("DeleteNoticesByIDs: " + err.Error())
  47. c.Status(http.StatusInternalServerError)
  48. } else {
  49. c.Flash.Success(c.Tr("admin.notices.delete_success"))
  50. c.Status(http.StatusOK)
  51. }
  52. }
  53. func EmptyNotices(c *context.Context) {
  54. if err := db.DeleteNotices(0, 0); err != nil {
  55. c.Error(err,"delete notices")
  56. return
  57. }
  58. log.Trace("System notices deleted by admin (%s): [start: %d]", c.User.Name, 0)
  59. c.Flash.Success(c.Tr("admin.notices.delete_success"))
  60. c.Redirect(conf.Server.Subpath + "/admin/notices")
  61. }
PANIC: session(release): write data/sessions/6/3/63c84501851f8c79: no space left on device

PANIC

session(release): write data/sessions/6/3/63c84501851f8c79: no space left on device
github.com/go-macaron/session@v0.0.0-20190805070824-1a3cdc6f5659/session.go:199 (0x8b2934)
gopkg.in/macaron.v1@v1.3.9/context.go:79 (0x83d0a0)
github.com/go-macaron/inject@v0.0.0-20160627170012-d8a0b8677191/inject.go:157 (0x80ab07)
github.com/go-macaron/inject@v0.0.0-20160627170012-d8a0b8677191/inject.go:135 (0x80a8a8)
gopkg.in/macaron.v1@v1.3.9/context.go:121 (0x83d1f8)
gopkg.in/macaron.v1@v1.3.9/context.go:112 (0x84fdb5)
gopkg.in/macaron.v1@v1.3.9/recovery.go:161 (0x84fda8)
gopkg.in/macaron.v1@v1.3.9/logger.go:40 (0x840c73)
github.com/go-macaron/inject@v0.0.0-20160627170012-d8a0b8677191/inject.go:157 (0x80ab07)
github.com/go-macaron/inject@v0.0.0-20160627170012-d8a0b8677191/inject.go:135 (0x80a8a8)
gopkg.in/macaron.v1@v1.3.9/context.go:121 (0x83d1f8)
gopkg.in/macaron.v1@v1.3.9/router.go:187 (0x850fc6)
gopkg.in/macaron.v1@v1.3.9/router.go:303 (0x8493e5)
gopkg.in/macaron.v1@v1.3.9/macaron.go:220 (0x841fca)
net/http/server.go:2836 (0x7a79b2)
net/http/server.go:1924 (0x7a341b)
runtime/asm_amd64.s:1373 (0x46f9f0)