Browse Source

#2063 Ability to delete repo from admin panel

pull/2110/head
Unknwon 9 years ago
parent
commit
ca8ce793d1
  1. 2
      README.md
  2. 3
      cmd/web.go
  3. 1
      conf/locale/locale_en-US.ini
  4. 2
      gogs.go
  5. 4
      modules/bindata/bindata.go
  6. 22
      routers/admin/repos.go
  7. 4
      routers/api/v1/admin/users.go
  8. 2
      routers/repo/setting.go
  9. 2
      templates/.VERSION
  10. 17
      templates/admin/repo/list.tmpl

2
README.md

@ -5,7 +5,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
![](public/img/gogs-large-resize.png) ![](public/img/gogs-large-resize.png)
##### Current version: 0.7.32 Beta ##### Current version: 0.7.33 Beta
| Web | UI | Preview | | Web | UI | Preview |
|:-------------:|:-------:|:-------:| |:-------------:|:-------:|:-------:|

3
cmd/web.go

@ -267,7 +267,8 @@ func runWeb(ctx *cli.Context) {
}) })
m.Group("/repos", func() { m.Group("/repos", func() {
m.Get("", admin.Repositories) m.Get("", admin.Repos)
m.Post("/delete", admin.DeleteRepo)
}) })
m.Group("/auths", func() { m.Group("/auths", func() {

1
conf/locale/locale_en-US.ini

@ -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_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_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.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.update_settings_success = Repository options has been updated successfully.
settings.transfer_owner = New Owner settings.transfer_owner = New Owner
settings.make_transfer = Make Transfer settings.make_transfer = Make Transfer

2
gogs.go

@ -17,7 +17,7 @@ import (
"github.com/gogits/gogs/modules/setting" "github.com/gogits/gogs/modules/setting"
) )
const APP_VER = "0.7.32.1205 Beta" const APP_VER = "0.7.33.1205 Beta"
func init() { func init() {
runtime.GOMAXPROCS(runtime.NumCPU()) runtime.GOMAXPROCS(runtime.NumCPU())

4
modules/bindata/bindata.go

File diff suppressed because one or more lines are too long

22
routers/admin/repos.go

@ -9,6 +9,7 @@ import (
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/modules/middleware" "github.com/gogits/gogs/modules/middleware"
"github.com/gogits/gogs/modules/setting" "github.com/gogits/gogs/modules/setting"
) )
@ -17,7 +18,7 @@ const (
REPOS base.TplName = "admin/repo/list" 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["Title"] = ctx.Tr("admin.repositories")
ctx.Data["PageIsAdmin"] = true ctx.Data["PageIsAdmin"] = true
ctx.Data["PageIsAdminRepositories"] = true ctx.Data["PageIsAdminRepositories"] = true
@ -39,3 +40,22 @@ func Repositories(ctx *middleware.Context) {
ctx.Data["Total"] = total ctx.Data["Total"] = total
ctx.HTML(200, REPOS) 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",
})
}

4
routers/api/v1/admin/users.go

@ -36,6 +36,7 @@ func parseLoginSource(ctx *middleware.Context, u *models.User, sourceID int64, l
u.LoginName = loginName 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) { func CreateUser(ctx *middleware.Context, form api.CreateUserOption) {
u := &models.User{ u := &models.User{
Name: form.Username, Name: form.Username,
@ -71,6 +72,7 @@ func CreateUser(ctx *middleware.Context, form api.CreateUserOption) {
ctx.JSON(201, to.ApiUser(u)) 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) { func EditUser(ctx *middleware.Context, form api.EditUserOption) {
u := user.GetUserByParams(ctx) u := user.GetUserByParams(ctx)
if ctx.Written() { if ctx.Written() {
@ -119,6 +121,7 @@ func EditUser(ctx *middleware.Context, form api.EditUserOption) {
ctx.JSON(200, to.ApiUser(u)) ctx.JSON(200, to.ApiUser(u))
} }
// https://github.com/gogits/go-gogs-client/wiki/Administration-Users#delete-a-user
func DeleteUser(ctx *middleware.Context) { func DeleteUser(ctx *middleware.Context) {
u := user.GetUserByParams(ctx) u := user.GetUserByParams(ctx)
if ctx.Written() { if ctx.Written() {
@ -139,6 +142,7 @@ func DeleteUser(ctx *middleware.Context) {
ctx.Status(204) 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) { func CreatePublicKey(ctx *middleware.Context, form api.CreateKeyOption) {
u := user.GetUserByParams(ctx) u := user.GetUserByParams(ctx)
if ctx.Written() { if ctx.Written() {

2
routers/repo/setting.go

@ -185,6 +185,8 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) {
return return
} }
log.Trace("Repository deleted: %s/%s", ctx.Repo.Owner.Name, repo.Name) 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()) ctx.Redirect(ctx.Repo.Owner.DashboardLink())
} }
} }

2
templates/.VERSION

@ -1 +1 @@
0.7.32.1205 Beta 0.7.33.1205 Beta

17
templates/admin/repo/list.tmpl

@ -20,6 +20,7 @@
<th>{{.i18n.Tr "admin.repos.stars"}}</th> <th>{{.i18n.Tr "admin.repos.stars"}}</th>
<th>{{.i18n.Tr "admin.repos.issues"}}</th> <th>{{.i18n.Tr "admin.repos.issues"}}</th>
<th>{{.i18n.Tr "admin.users.created"}}</th> <th>{{.i18n.Tr "admin.users.created"}}</th>
<th>{{.i18n.Tr "admin.notices.op"}}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -33,6 +34,7 @@
<td>{{.NumStars}}</td> <td>{{.NumStars}}</td>
<td>{{.NumIssues}}</td> <td>{{.NumIssues}}</td>
<td><span title="{{DateFmtLong .Created}}">{{DateFmtShort .Created}}</span></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> </tr>
{{end}} {{end}}
</tbody> </tbody>
@ -66,4 +68,19 @@
</div> </div>
</div> </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" .}} {{template "base/footer" .}}
Loading…
Cancel
Save