← Back to team overview

launchpad-reviewers team mailing list archive

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

 

Added the check to prevent deletion when there are bugs associated with the OCI project.

It should be good for another review round now.

Diff comments:

> diff --git a/lib/lp/registry/model/ociproject.py b/lib/lp/registry/model/ociproject.py
> index e98b3ea..da0bb98 100644
> --- a/lib/lp/registry/model/ociproject.py
> +++ b/lib/lp/registry/model/ociproject.py
> @@ -297,6 +298,28 @@ class OCIProject(BugTargetBase, StormBase):
>          namespace = getUtility(IGitNamespaceSet).get(person, oci_project=self)
>          return namespace.name
>  
> +    def destroySelf(self):
> +        """See `IOCIProject`."""
> +        from lp.oci.model.ocirecipe import OCIRecipe
> +        from lp.code.model.gitrepository import GitRepository
> +
> +        exists_recipes = not IStore(OCIRecipe).find(
> +            OCIRecipe,
> +            OCIRecipe.oci_project == self).is_empty()
> +        if exists_recipes:
> +            raise CannotDeleteOCIProject("This OCI recipe contains recipes.")

Absolutely! Fixing it.

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