aboutsummaryrefslogtreecommitdiffstats
path: root/routers/admin/notice.go
diff options
context:
space:
mode:
authorUnknwon <joe2010xtmf@163.com>2014-10-08 18:29:18 -0400
committerUnknwon <joe2010xtmf@163.com>2014-10-08 18:29:18 -0400
commit1aa76bd27913e40780aa66fe6b6c1158e20b7bef (patch)
treeafd0979216a6a4a6f3fe72d4f8c391fc5b7ab0fe /routers/admin/notice.go
parent54c9844d665cdd554ae8945aae2ee966df5ddfc4 (diff)
downloadgitea-1aa76bd27913e40780aa66fe6b6c1158e20b7bef.tar.gz
gitea-1aa76bd27913e40780aa66fe6b6c1158e20b7bef.zip
Fix #532, add system notice
Diffstat (limited to 'routers/admin/notice.go')
-rw-r--r--routers/admin/notice.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/routers/admin/notice.go b/routers/admin/notice.go
new file mode 100644
index 0000000000..b431946366
--- /dev/null
+++ b/routers/admin/notice.go
@@ -0,0 +1,46 @@
+// Copyright 2014 The Gogs Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package admin
+
+import (
+ "github.com/Unknwon/com"
+
+ "github.com/gogits/gogs/models"
+ "github.com/gogits/gogs/modules/base"
+ "github.com/gogits/gogs/modules/log"
+ "github.com/gogits/gogs/modules/middleware"
+)
+
+const (
+ NOTICES base.TplName = "admin/notice"
+)
+
+func Notices(ctx *middleware.Context) {
+ ctx.Data["Title"] = ctx.Tr("admin.notices")
+ ctx.Data["PageIsAdmin"] = true
+ ctx.Data["PageIsAdminNotices"] = true
+
+ pageNum := 50
+ p := pagination(ctx, models.CountNotices(), pageNum)
+
+ notices, err := models.GetNotices(pageNum, (p-1)*pageNum)
+ if err != nil {
+ ctx.Handle(500, "GetNotices", err)
+ return
+ }
+ ctx.Data["Notices"] = notices
+ ctx.HTML(200, NOTICES)
+}
+
+func DeleteNotice(ctx *middleware.Context) {
+ id := com.StrTo(ctx.Params(":id")).MustInt64()
+ if err := models.DeleteNotice(id); err != nil {
+ ctx.Handle(500, "DeleteNotice", err)
+ return
+ }
+ log.Trace("System notice deleted by admin(%s): %d", ctx.User.Name, id)
+ ctx.Flash.Success(ctx.Tr("admin.notices.delete_success"))
+ ctx.Redirect("/admin/notices")
+}