feature: implements repo deletion mechanism
This commit is contained in:
parent
203936cbd8
commit
d4cb542581
6 changed files with 56 additions and 32 deletions
|
|
@ -124,11 +124,8 @@ class RepoSettingsAdvancedView(RepoAppView):
|
|||
because of attached forks or other errors.
|
||||
"""
|
||||
_ = self.request.translate
|
||||
handle_forks = self.request.POST.get("forks", None)
|
||||
if handle_forks == "detach_forks":
|
||||
handle_forks = "detach"
|
||||
elif handle_forks == "delete_forks":
|
||||
handle_forks = "delete"
|
||||
|
||||
fork_action = self._get_fork_action()
|
||||
|
||||
repo_advanced_url = h.route_path("edit_repo_advanced", repo_name=self.db_repo_name, _anchor="advanced-delete")
|
||||
try:
|
||||
|
|
@ -137,13 +134,13 @@ class RepoSettingsAdvancedView(RepoAppView):
|
|||
delete_cache = True
|
||||
self._invalidate_remote_cache(delete=delete_cache)
|
||||
|
||||
RepoModel().delete(self.db_repo, forks=handle_forks)
|
||||
RepoModel().delete(self.db_repo, forks=fork_action)
|
||||
|
||||
_forks = self.db_repo.forks.count()
|
||||
if _forks and handle_forks:
|
||||
if handle_forks == "detach_forks":
|
||||
if _forks and fork_action:
|
||||
if fork_action is RepoModel.ForkAction.DETACH:
|
||||
h.flash(_("Detached %s forks") % _forks, category="success")
|
||||
elif handle_forks == "delete_forks":
|
||||
elif fork_action is RepoModel.ForkAction.DELETE:
|
||||
h.flash(_("Deleted %s forks") % _forks, category="success")
|
||||
|
||||
repo = audit_logger.RepoWrap(repo_id=None, repo_name=self.db_repo.repo_name)
|
||||
|
|
@ -199,6 +196,16 @@ class RepoSettingsAdvancedView(RepoAppView):
|
|||
|
||||
raise HTTPFound(h.route_path("home"))
|
||||
|
||||
def _get_fork_action(self):
|
||||
fork_action = self.request.POST.get("forks", None)
|
||||
if fork_action == "detach_forks":
|
||||
return RepoModel.ForkAction.DETACH
|
||||
|
||||
if fork_action == "delete_forks":
|
||||
return RepoModel.ForkAction.DELETE
|
||||
|
||||
return RepoModel.ForkAction.UNKNOWN
|
||||
|
||||
def _invalidate_remote_cache(self, delete: bool):
|
||||
log.debug(f"Invalidating remote cache, for repository: {self.db_repo_name}")
|
||||
scm_repo = self.db_repo.scm_instance(cache=False)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue