mirror of
https://github.com/go-gitea/gitea
synced 2025-07-23 02:38:35 +00:00
#2063 Ability to delete repo from admin panel
This commit is contained in:
@@ -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",
|
||||
})
|
||||
}
|
||||
|
@@ -36,6 +36,7 @@ func parseLoginSource(ctx *middleware.Context, u *models.User, sourceID int64, l
|
||||
u.LoginName = loginName
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Administration-Users#create-a-new-user
|
||||
func CreateUser(ctx *middleware.Context, form api.CreateUserOption) {
|
||||
u := &models.User{
|
||||
Name: form.Username,
|
||||
@@ -71,6 +72,7 @@ func CreateUser(ctx *middleware.Context, form api.CreateUserOption) {
|
||||
ctx.JSON(201, to.ApiUser(u))
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Administration-Users#edit-an-existing-user
|
||||
func EditUser(ctx *middleware.Context, form api.EditUserOption) {
|
||||
u := user.GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
@@ -119,6 +121,7 @@ func EditUser(ctx *middleware.Context, form api.EditUserOption) {
|
||||
ctx.JSON(200, to.ApiUser(u))
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Administration-Users#delete-a-user
|
||||
func DeleteUser(ctx *middleware.Context) {
|
||||
u := user.GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
@@ -139,6 +142,7 @@ func DeleteUser(ctx *middleware.Context) {
|
||||
ctx.Status(204)
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Administration-Users#create-a-public-key-for-user
|
||||
func CreatePublicKey(ctx *middleware.Context, form api.CreateKeyOption) {
|
||||
u := user.GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
|
@@ -185,6 +185,8 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) {
|
||||
return
|
||||
}
|
||||
log.Trace("Repository deleted: %s/%s", ctx.Repo.Owner.Name, repo.Name)
|
||||
|
||||
ctx.Flash.Success(ctx.Tr("repo.settings.deletion_success"))
|
||||
ctx.Redirect(ctx.Repo.Owner.DashboardLink())
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user