mirror of
https://github.com/go-gitea/gitea
synced 2024-12-22 03:07:55 +01:00
#2063 Ability to delete repo from admin panel
This commit is contained in:
parent
978dc00305
commit
ca8ce793d1
@ -5,7 +5,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
|
||||
|
||||
![](public/img/gogs-large-resize.png)
|
||||
|
||||
##### Current version: 0.7.32 Beta
|
||||
##### Current version: 0.7.33 Beta
|
||||
|
||||
| Web | UI | Preview |
|
||||
|:-------------:|:-------:|:-------:|
|
||||
|
@ -267,7 +267,8 @@ func runWeb(ctx *cli.Context) {
|
||||
})
|
||||
|
||||
m.Group("/repos", func() {
|
||||
m.Get("", admin.Repositories)
|
||||
m.Get("", admin.Repos)
|
||||
m.Post("/delete", admin.DeleteRepo)
|
||||
})
|
||||
|
||||
m.Group("/auths", func() {
|
||||
|
@ -582,6 +582,7 @@ settings.delete_notices_2 = - This operation will permanently delete the everyth
|
||||
settings.delete_notices_fork_1 = - If this repository is public, all forks will be became independent after deletion.
|
||||
settings.delete_notices_fork_2 = - If this repository is private, all forks will be removed at the same time.
|
||||
settings.delete_notices_fork_3 = - If you want to keep all forks after deletion, please change visibility of this repository to public first.
|
||||
settings.deletion_success = Repository has been deleted successfully!
|
||||
settings.update_settings_success = Repository options has been updated successfully.
|
||||
settings.transfer_owner = New Owner
|
||||
settings.make_transfer = Make Transfer
|
||||
|
2
gogs.go
2
gogs.go
@ -17,7 +17,7 @@ import (
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
const APP_VER = "0.7.32.1205 Beta"
|
||||
const APP_VER = "0.7.33.1205 Beta"
|
||||
|
||||
func init() {
|
||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||
|
File diff suppressed because one or more lines are too long
@ -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())
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
0.7.32.1205 Beta
|
||||
0.7.33.1205 Beta
|
@ -20,6 +20,7 @@
|
||||
<th>{{.i18n.Tr "admin.repos.stars"}}</th>
|
||||
<th>{{.i18n.Tr "admin.repos.issues"}}</th>
|
||||
<th>{{.i18n.Tr "admin.users.created"}}</th>
|
||||
<th>{{.i18n.Tr "admin.notices.op"}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -33,6 +34,7 @@
|
||||
<td>{{.NumStars}}</td>
|
||||
<td>{{.NumIssues}}</td>
|
||||
<td><span title="{{DateFmtLong .Created}}">{{DateFmtShort .Created}}</span></td>
|
||||
<td><a class="delete-button" href="" data-url="{{$.Link}}/delete" data-id="{{.ID}}"><i class="trash icon text red"></i></a></td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
@ -66,4 +68,19 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ui small basic delete modal">
|
||||
<div class="ui icon header">
|
||||
<i class="trash icon"></i>
|
||||
{{.i18n.Tr "repo.settings.delete"}}
|
||||
</div>
|
||||
<div class="content">
|
||||
<p>{{.i18n.Tr "repo.settings.delete_desc"}}</p>
|
||||
<p>{{.i18n.Tr "repo.settings.delete_notices_2"}}</p>
|
||||
<p>{{.i18n.Tr "repo.settings.delete_notices_fork_1"}}</p>
|
||||
<p>{{.i18n.Tr "repo.settings.delete_notices_fork_2"}}</p>
|
||||
<p>{{.i18n.Tr "repo.settings.delete_notices_fork_3"}}</p>
|
||||
</div>
|
||||
{{template "base/delete_modal_actions" .}}
|
||||
</div>
|
||||
{{template "base/footer" .}}
|
Loading…
Reference in New Issue
Block a user