← Back to team overview

launchpad-reviewers team mailing list archive

Re: [Merge] ~pappacena/launchpad:delete-oci-project into launchpad:master

 


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()

Although we already have it prepared at database level, we are not currently supporting bugs for OCIProjectSeries (the database column is not even mapped at the BugTask model, since we don't have a UI to manage that today).

> +        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)

I agree. And we have a reasonable way of listing those git repositories in the UI already. I'll remove this.

> +        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