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. "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. repo_service "code.gitea.io/gitea/services/repository"
  13. )
  14. const (
  15. tplRepos base.TplName = "admin/repo/list"
  16. )
  17. // Repos show all the repositories
  18. func Repos(ctx *context.Context) {
  19. ctx.Data["Title"] = ctx.Tr("admin.repositories")
  20. ctx.Data["PageIsAdmin"] = true
  21. ctx.Data["PageIsAdminRepositories"] = true
  22. routers.RenderRepoSearch(ctx, &routers.RepoSearchOptions{
  23. Private: true,
  24. PageSize: setting.UI.Admin.RepoPagingNum,
  25. TplName: tplRepos,
  26. })
  27. }
  28. // DeleteRepo delete one repository
  29. func DeleteRepo(ctx *context.Context) {
  30. repo, err := models.GetRepositoryByID(ctx.QueryInt64("id"))
  31. if err != nil {
  32. ctx.ServerError("GetRepositoryByID", err)
  33. return
  34. }
  35. if err := repo_service.DeleteRepository(ctx.User, repo); err != nil {
  36. ctx.ServerError("DeleteRepository", err)
  37. return
  38. }
  39. log.Trace("Repository deleted: %s", repo.FullName())
  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") + "&sort=" + ctx.Query("sort"),
  43. })
  44. }