Skip to content

Commit 79e6151

Browse files
authored
Merge pull request #5596 from dojutsu-user/delete-super-project
Notify the user when deleting a superproject
2 parents c7ec857 + 507db1a commit 79e6151

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

readthedocs/projects/views/private.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,11 @@ def project_delete(request, project_slug):
209209
slug=project_slug,
210210
)
211211

212+
context = {
213+
'project': project,
214+
'is_superproject': project.subprojects.all().exists()
215+
}
216+
212217
if request.method == 'POST':
213218
broadcast(
214219
type='app',
@@ -220,7 +225,7 @@ def project_delete(request, project_slug):
220225
project_dashboard = reverse('projects_dashboard')
221226
return HttpResponseRedirect(project_dashboard)
222227

223-
return render(request, 'projects/project_delete.html', {'project': project})
228+
return render(request, 'projects/project_delete.html', context)
224229

225230

226231
class ImportWizardView(ProjectSpamMixin, PrivateViewMixin, SessionWizardView):

readthedocs/rtd_tests/tests/test_project_views.py

+18
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,24 @@ def test_delete_project(self):
414414
args=[(project.doc_path,)],
415415
)
416416

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+
417435
def test_subproject_create(self):
418436
project = get(Project, slug='pip', users=[self.user])
419437
subproject = get(Project, users=[self.user])

readthedocs/templates/projects/project_delete.html

+12
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@
66
{% block content-header %}<h1>{% blocktrans with project.name as name %}Delete {{ name }}?{% endblocktrans %}</h1>{% endblock %}
77

88
{% 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+
921
<p>{% trans "You sure?" %} O_o</p>
1022

1123
<form method="post" action=".">{% csrf_token %}

0 commit comments

Comments
 (0)