File tree 3 files changed +36
-1
lines changed
3 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -209,6 +209,11 @@ def project_delete(request, project_slug):
209
209
slug = project_slug ,
210
210
)
211
211
212
+ context = {
213
+ 'project' : project ,
214
+ 'is_superproject' : project .subprojects .all ().exists ()
215
+ }
216
+
212
217
if request .method == 'POST' :
213
218
broadcast (
214
219
type = 'app' ,
@@ -220,7 +225,7 @@ def project_delete(request, project_slug):
220
225
project_dashboard = reverse ('projects_dashboard' )
221
226
return HttpResponseRedirect (project_dashboard )
222
227
223
- return render (request , 'projects/project_delete.html' , { 'project' : project } )
228
+ return render (request , 'projects/project_delete.html' , context )
224
229
225
230
226
231
class ImportWizardView (ProjectSpamMixin , PrivateViewMixin , SessionWizardView ):
Original file line number Diff line number Diff line change @@ -414,6 +414,24 @@ def test_delete_project(self):
414
414
args = [(project .doc_path ,)],
415
415
)
416
416
417
+ def test_delete_superproject (self ):
418
+ super_proj = get (Project , slug = 'pip' , users = [self .user ])
419
+ sub_proj = get (Project , slug = 'test-sub-project' , users = [self .user ])
420
+
421
+ self .assertFalse (super_proj .subprojects .all ().exists ())
422
+ super_proj .add_subproject (sub_proj )
423
+
424
+ response = self .client .get ('/dashboard/pip/delete/' )
425
+ self .assertEqual (response .status_code , 200 )
426
+ self .assertContains (
427
+ response ,
428
+ 'This project <a href="/dashboard/pip/subprojects/">has subprojects</a> under it. '
429
+ 'Deleting this project will make them to become regular projects. '
430
+ 'This will break the URLs of all its subprojects and they will be served normally as other projects.' ,
431
+ count = 1 ,
432
+ html = True ,
433
+ )
434
+
417
435
def test_subproject_create (self ):
418
436
project = get (Project , slug = 'pip' , users = [self .user ])
419
437
subproject = get (Project , users = [self .user ])
Original file line number Diff line number Diff line change 6
6
{% block content-header %}< h1 > {% blocktrans with project.name as name %}Delete {{ name }}?{% endblocktrans %}</ h1 > {% endblock %}
7
7
8
8
{% block content %}
9
+
10
+ {% if is_superproject %}
11
+ {% url "projects_subprojects" project.slug as subproject_url %}
12
+ < p >
13
+ {% blocktrans trimmed %}
14
+ This project < a href ="{{ subproject_url }} "> has subprojects</ a > under it.
15
+ Deleting this project will make them to become regular projects.
16
+ This will break the URLs of all its subprojects and they will be served normally as other projects.
17
+ {% endblocktrans %}
18
+ </ p >
19
+ {% endif %}
20
+
9
21
< p > {% trans "You sure?" %} O_o</ p >
10
22
11
23
< form method ="post " action =". "> {% csrf_token %}
You can’t perform that action at this time.
0 commit comments