Fork to maintain patches against the official gitea for https://code.ceondo.com https://github.com/go-gitea/gitea

repos.go 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. "code.gitea.io/gitea/models"
  7. "code.gitea.io/gitea/modules/base"
  8. "code.gitea.io/gitea/modules/context"
  9. "code.gitea.io/gitea/modules/log"
  10. "code.gitea.io/gitea/modules/setting"
  11. "code.gitea.io/gitea/routers"
  12. )
  13. const (
  14. tplRepos base.TplName = "admin/repo/list"
  15. )
  16. // Repos show all the repositories
  17. func Repos(ctx *context.Context) {
  18. ctx.Data["Title"] = ctx.Tr("admin.repositories")
  19. ctx.Data["PageIsAdmin"] = true
  20. ctx.Data["PageIsAdminRepositories"] = true
  21. routers.RenderRepoSearch(ctx, &routers.RepoSearchOptions{
  22. Private: true,
  23. PageSize: setting.UI.Admin.RepoPagingNum,
  24. TplName: tplRepos,
  25. })
  26. }
  27. // DeleteRepo delete one repository
  28. func DeleteRepo(ctx *context.Context) {
  29. repo, err := models.GetRepositoryByID(ctx.QueryInt64("id"))
  30. if err != nil {
  31. ctx.Handle(500, "GetRepositoryByID", err)
  32. return
  33. }
  34. if err := models.DeleteRepository(ctx.User, repo.MustOwner().ID, repo.ID); err != nil {
  35. ctx.Handle(500, "DeleteRepository", err)
  36. return
  37. }
  38. log.Trace("Repository deleted: %s/%s", repo.MustOwner().Name, repo.Name)
  39. ctx.Flash.Success(ctx.Tr("repo.settings.deletion_success"))
  40. ctx.JSON(200, map[string]interface{}{
  41. "redirect": setting.AppSubURL + "/admin/repos?page=" + ctx.Query("page"),
  42. })
  43. }