launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #26977
Re: [Merge] ~pappacena/launchpad:delete-oci-project into launchpad:master
Review: Approve
Diff comments:
> diff --git a/lib/lp/registry/model/ociproject.py b/lib/lp/registry/model/ociproject.py
> index 3cf675f..15f552c 100644
> --- a/lib/lp/registry/model/ociproject.py
> +++ b/lib/lp/registry/model/ociproject.py
> @@ -299,6 +300,36 @@ class OCIProject(BugTargetBase, StormBase):
> return []
> return BRANCH_POLICY_ALLOWED_TYPES[self.pillar.branch_sharing_policy]
>
> + def destroySelf(self):
> + """See `IOCIProject`."""
> + from lp.bugs.model.bugtask import BugTask
> + from lp.code.model.gitrepository import GitRepository
> + from lp.oci.model.ocirecipe import OCIRecipe
> +
> + # Cannot delete this OCI project if it has recipes associated if it.
> + exists_recipes = not IStore(OCIRecipe).find(
> + OCIRecipe,
> + OCIRecipe.oci_project == self).is_empty()
> + if exists_recipes:
> + raise CannotDeleteOCIProject("This OCI project contains recipes.")
> +
> + # Cannot delete this OCI project if it has bugs associated with it.
> + exists_bugs = not IStore(BugTask).find(
> + BugTask, BugTask.ociproject == self).is_empty()
Or possibly also BugTask.ociprojectseries, since that and BugTask.ociproject are mutually-exclusive?
> + if exists_bugs:
> + raise CannotDeleteOCIProject("This OCI project contains bugs.")
> +
> + git_repos = IStore(GitRepository).find(
> + GitRepository, GitRepository.oci_project == self)
> + if not git_repos.is_empty():
> + repos = ", ".join(repo.display_name for repo in git_repos)
> + raise CannotDeleteOCIProject(
> + "There are git repositories associated with this OCI project: "
> + + repos)
Hm, maybe. I think I might be wary of listing all the repositories in the exception message, since that could potentially get quite long.
> + for series in self.series:
> + series.destroySelf()
> + IStore(self).remove(self)
> +
>
> @implementer(IOCIProjectSet)
> class OCIProjectSet:
--
https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/401424
Your team Launchpad code reviewers is subscribed to branch ~pappacena/launchpad:delete-oci-project.
References