You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.4 KiB

  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package admin
  5. import (
  6. "github.com/gogits/gogs/models"
  7. "github.com/gogits/gogs/modules/base"
  8. "github.com/gogits/gogs/modules/context"
  9. "github.com/gogits/gogs/modules/log"
  10. "github.com/gogits/gogs/modules/setting"
  11. "github.com/gogits/gogs/routers"
  12. )
  13. const (
  14. REPOS base.TplName = "admin/repo/list"
  15. )
  16. func Repos(ctx *context.Context) {
  17. ctx.Data["Title"] = ctx.Tr("admin.repositories")
  18. ctx.Data["PageIsAdmin"] = true
  19. ctx.Data["PageIsAdminRepositories"] = true
  20. routers.RenderRepoSearch(ctx, &routers.RepoSearchOptions{
  21. Counter: models.CountRepositories,
  22. Ranger: models.Repositories,
  23. Private: true,
  24. PageSize: setting.UI.Admin.RepoPagingNum,
  25. OrderBy: "id ASC",
  26. TplName: REPOS,
  27. })
  28. }
  29. func DeleteRepo(ctx *context.Context) {
  30. repo, err := models.GetRepositoryByID(ctx.QueryInt64("id"))
  31. if err != nil {
  32. ctx.Handle(500, "GetRepositoryByID", err)
  33. return
  34. }
  35. if err := models.DeleteRepository(repo.MustOwner().ID, repo.ID); err != nil {
  36. ctx.Handle(500, "DeleteRepository", err)
  37. return
  38. }
  39. log.Trace("Repository deleted: %s/%s", repo.MustOwner().Name, repo.Name)
  40. ctx.Flash.Success(ctx.Tr("repo.settings.deletion_success"))
  41. ctx.JSON(200, map[string]interface{}{
  42. "redirect": setting.AppSubUrl + "/admin/repos?page=" + ctx.Query("page"),
  43. })
  44. }