Added the requested change. It should be good to go now.

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

It makes sense. Adding and XXX with guidelines for when we map the 
BugTask.ociprojectseries field.

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

_______________________________________________
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to     : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp

Reply via email to