Merge ~pappacena/launchpad:allow-delete-gitrepo-while-creating into launchpad:master

Proposed by Thiago F. Pappacena
Status: Merged
Approved by: Thiago F. Pappacena
Approved revision: c328a1c8f3c5b81a6fe94324744ca7b8126f11f9
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~pappacena/launchpad:allow-delete-gitrepo-while-creating
Merge into: launchpad:master
Diff against target: 94 lines (+5/-39)
3 files modified
lib/lp/code/browser/gitrepository.py (+1/-9)
lib/lp/code/browser/tests/test_gitrepository.py (+4/-23)
lib/lp/code/templates/gitrepository-delete.pt (+0/-7)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+400490@code.launchpad.net

Commit message

Allowing users to delete git repositories while they are creating

Description of the change

We don't have any strong constraint on allowing users to delete on Launchpad a repository that is being created on Turnip side. If that happens, the repository confirmation on Turnip will fail, and the forked repository should be deleted from filesystem correctly.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve
c200545... by Thiago F. Pappacena

Removing unsued attribute

Revision history for this message
Thiago F. Pappacena (pappacena) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/code/browser/gitrepository.py b/lib/lp/code/browser/gitrepository.py
2index 76606cd..25fd6de 100644
3--- a/lib/lp/code/browser/gitrepository.py
4+++ b/lib/lp/code/browser/gitrepository.py
5@@ -1,4 +1,4 @@
6-# Copyright 2015-2020 Canonical Ltd. This software is licensed under the
7+# Copyright 2015-2021 Canonical Ltd. This software is licensed under the
8 # GNU Affero General Public License version 3 (see the file LICENSE).
9
10 """Git repository views."""
11@@ -1376,8 +1376,6 @@ class GitRepositoryDeletionView(LaunchpadFormView):
12
13 Uses display_deletion_requirements as its source data.
14 """
15- if self.context.status == GitRepositoryStatus.CREATING:
16- return False
17 return len([item for item, action, reason, allowed in
18 self.display_deletion_requirements if not allowed]) == 0
19
20@@ -1418,12 +1416,6 @@ class GitRepositoryDeletionView(LaunchpadFormView):
21 def cancel_url(self):
22 return canonical_url(self.context)
23
24- @property
25- def warning_message(self):
26- if self.context.status == GitRepositoryStatus.CREATING:
27- return "This repository is being created and cannot be deleted."
28- return None
29-
30
31 class GitRepositoryActivityView(LaunchpadView):
32
33diff --git a/lib/lp/code/browser/tests/test_gitrepository.py b/lib/lp/code/browser/tests/test_gitrepository.py
34index 5a17f6e..8dadb9d 100644
35--- a/lib/lp/code/browser/tests/test_gitrepository.py
36+++ b/lib/lp/code/browser/tests/test_gitrepository.py
37@@ -1,4 +1,4 @@
38-# Copyright 2015-2020 Canonical Ltd. This software is licensed under the
39+# Copyright 2015-2021 Canonical Ltd. This software is licensed under the
40 # GNU Affero General Public License version 3 (see the file LICENSE).
41
42 """Unit tests for GitRepositoryView."""
43@@ -2016,30 +2016,11 @@ class TestGitRepositoryDeletionView(BrowserTestCase):
44 delete_link = browser.getLink("Delete repository")
45 self.assertEqual(delete_url, delete_link.url)
46
47- def test_creating_warning_message_is_present(self):
48- # If the repository is not being created, we should show the
49- # warning message, and suppress the "delete" button.
50- repository = removeSecurityProxy(self.factory.makeGitRepository())
51- repository.status = GitRepositoryStatus.CREATING
52- browser = self.getViewBrowser(
53- repository, "+delete", rootsite="code", user=repository.owner)
54-
55- # Warning message is present.
56- tag = find_tags_by_class(browser.contents, "warning message", True)
57- self.assertIsNotNone(tag)
58- self.assertIn(
59- "This repository is being created and cannot be deleted.",
60- ' '.join(tag.contents))
61- # Delete button is not present
62- tag = find_tag_by_id(
63- browser.contents, "field.actions.delete_repository")
64- self.assertIsNone(tag)
65-
66- def test_creating_warning_message_is_not_shown(self):
67- # If the repository is not being created, we should not show the
68+ def test_can_delete_creating_repository(self):
69+ # Even if the repository is being created, we should not show the
70 # warning message, and the "delete" button should be present.
71 repository = removeSecurityProxy(self.factory.makeGitRepository())
72- repository.status = GitRepositoryStatus.AVAILABLE
73+ repository.status = GitRepositoryStatus.CREATING
74 browser = self.getViewBrowser(
75 repository, "+delete", rootsite="code", user=repository.owner)
76
77diff --git a/lib/lp/code/templates/gitrepository-delete.pt b/lib/lp/code/templates/gitrepository-delete.pt
78index 3e92b6b..2405139 100644
79--- a/lib/lp/code/templates/gitrepository-delete.pt
80+++ b/lib/lp/code/templates/gitrepository-delete.pt
81@@ -8,13 +8,6 @@
82 <body>
83
84 <div metal:fill-slot="main">
85- <div class="top-portlet" style="padding-top:0.5em;">
86- <p tal:condition="view/warning_message"
87- style="clear: right;" class="warning message"
88- tal:content="view/warning_message">
89- There is a warning here.
90- </p>
91- </div>
92
93 <tal:deletelist condition="view/repository_deletion_actions/delete">
94 The following items must be <em>deleted</em>: