diff options
author | Unknwon <u@gogs.io> | 2015-12-05 17:39:29 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-12-05 17:39:29 -0500 |
commit | ca8ce793d15b3991eb4766939e9a0a7cf086fa6f (patch) | |
tree | 9460c1e8b16d59d31834a4cda12f821a5372f112 /routers/admin/repos.go | |
parent | 978dc00305f1af705ae8900977529bac6fa4c72b (diff) | |
download | gitea-ca8ce793d15b3991eb4766939e9a0a7cf086fa6f.tar.gz gitea-ca8ce793d15b3991eb4766939e9a0a7cf086fa6f.zip |
#2063 Ability to delete repo from admin panel
Diffstat (limited to 'routers/admin/repos.go')
-rw-r--r-- | routers/admin/repos.go | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/routers/admin/repos.go b/routers/admin/repos.go index 474d3db959..62e5b5c6e1 100644 --- a/routers/admin/repos.go +++ b/routers/admin/repos.go @@ -9,6 +9,7 @@ import ( "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/base" + "github.com/gogits/gogs/modules/log" "github.com/gogits/gogs/modules/middleware" "github.com/gogits/gogs/modules/setting" ) @@ -17,7 +18,7 @@ const ( REPOS base.TplName = "admin/repo/list" ) -func Repositories(ctx *middleware.Context) { +func Repos(ctx *middleware.Context) { ctx.Data["Title"] = ctx.Tr("admin.repositories") ctx.Data["PageIsAdmin"] = true ctx.Data["PageIsAdminRepositories"] = true @@ -39,3 +40,22 @@ func Repositories(ctx *middleware.Context) { ctx.Data["Total"] = total ctx.HTML(200, REPOS) } + +func DeleteRepo(ctx *middleware.Context) { + repo, err := models.GetRepositoryByID(ctx.QueryInt64("id")) + if err != nil { + ctx.Handle(500, "GetRepositoryByID", err) + return + } + + if err := models.DeleteRepository(repo.MustOwner().Id, repo.ID); err != nil { + ctx.Handle(500, "DeleteRepository", err) + return + } + log.Trace("Repository deleted: %s/%s", repo.MustOwner().Name, repo.Name) + + ctx.Flash.Success(ctx.Tr("repo.settings.deletion_success")) + ctx.JSON(200, map[string]interface{}{ + "redirect": setting.AppSubUrl + "/admin/repos", + }) +} |