From ee83a9076d780e249100f02ba9442478c1fc36ad Mon Sep 17 00:00:00 2001 From: dojutsu-user Date: Tue, 16 Apr 2019 18:18:59 +0530 Subject: [PATCH 1/9] Add message and test --- readthedocs/projects/views/private.py | 14 +++++++++++++- readthedocs/rtd_tests/tests/test_project_views.py | 14 ++++++++++++++ readthedocs/templates/projects/project_delete.html | 3 +++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/readthedocs/projects/views/private.py b/readthedocs/projects/views/private.py index 57e0d0761a3..5df5d298f7e 100644 --- a/readthedocs/projects/views/private.py +++ b/readthedocs/projects/views/private.py @@ -243,6 +243,18 @@ def project_delete(request, project_slug): slug=project_slug, ) + context = { + 'project': project, + } + + if project.subprojects.all().exists(): + context['message'] = _( + 'This project has subprojects under it. ' + 'Deleting this will make them as regular projects. ' + 'This will effect the URLs of the subprojects and ' + 'they will be served normally as other projects.' + ) + if request.method == 'POST': broadcast( type='app', @@ -254,7 +266,7 @@ def project_delete(request, project_slug): project_dashboard = reverse('projects_dashboard') return HttpResponseRedirect(project_dashboard) - return render(request, 'projects/project_delete.html', {'project': project}) + return render(request, 'projects/project_delete.html', context) class ImportWizardView(ProjectSpamMixin, PrivateViewMixin, SessionWizardView): diff --git a/readthedocs/rtd_tests/tests/test_project_views.py b/readthedocs/rtd_tests/tests/test_project_views.py index f561f78acd6..e6440bdb60e 100644 --- a/readthedocs/rtd_tests/tests/test_project_views.py +++ b/readthedocs/rtd_tests/tests/test_project_views.py @@ -414,6 +414,20 @@ def test_delete_project(self): args=[(project.doc_path,)], ) + def test_delete_superproject(self): + super_proj = get(Project, slug='pip', users=[self.user]) + sub_proj = get(Project, slug='test-sub-project', users=[self.user]) + + self.assertFalse(super_proj.subprojects.all().exists()) + super_proj.add_subproject(sub_proj) + + response = self.client.get('/dashboard/pip/delete/') + self.assertEqual(response.status_code, 200) + self.assertIn( + 'This project has subprojects under it. Deleting this will make them as regular projects. This will effect the URLs of the subprojects and they will be served normally as other projects.', + response.content.decode('utf-8') + ) + def test_subproject_create(self): project = get(Project, slug='pip', users=[self.user]) subproject = get(Project, users=[self.user]) diff --git a/readthedocs/templates/projects/project_delete.html b/readthedocs/templates/projects/project_delete.html index 33d78c19526..5d7e1825b0c 100644 --- a/readthedocs/templates/projects/project_delete.html +++ b/readthedocs/templates/projects/project_delete.html @@ -6,6 +6,9 @@ {% block content-header %}

{% blocktrans with project.name as name %}Delete {{ name }}?{% endblocktrans %}

{% endblock %} {% block content %} + {% if message %} +

{{ message }}

+ {% endif %}

{% trans "You sure?" %} O_o

{% csrf_token %} From 6a518a817c26ab8f462647cf1c1a37a3cf2a9856 Mon Sep 17 00:00:00 2001 From: dojutsu-user Date: Wed, 24 Apr 2019 23:42:33 +0530 Subject: [PATCH 2/9] add improvements --- readthedocs/projects/views/private.py | 9 +-------- readthedocs/templates/projects/project_delete.html | 6 ++++-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/readthedocs/projects/views/private.py b/readthedocs/projects/views/private.py index 5df5d298f7e..255bef7c9b4 100644 --- a/readthedocs/projects/views/private.py +++ b/readthedocs/projects/views/private.py @@ -245,16 +245,9 @@ def project_delete(request, project_slug): context = { 'project': project, + 'is_superproject': project.subprojects.all().exists() } - if project.subprojects.all().exists(): - context['message'] = _( - 'This project has subprojects under it. ' - 'Deleting this will make them as regular projects. ' - 'This will effect the URLs of the subprojects and ' - 'they will be served normally as other projects.' - ) - if request.method == 'POST': broadcast( type='app', diff --git a/readthedocs/templates/projects/project_delete.html b/readthedocs/templates/projects/project_delete.html index 5d7e1825b0c..79dac40f9cc 100644 --- a/readthedocs/templates/projects/project_delete.html +++ b/readthedocs/templates/projects/project_delete.html @@ -6,9 +6,11 @@ {% block content-header %}

{% blocktrans with project.name as name %}Delete {{ name }}?{% endblocktrans %}

{% endblock %} {% block content %} - {% if message %} -

{{ message }}

+ + {% if is_superproject %} +

This project has subprojects under it. Deleting this will make them as regular projects. This will effect the URLs of the subprojects and they will be served normally as other projects.

{% endif %} +

{% trans "You sure?" %} O_o

{% csrf_token %} From 01766a820853c8b4f276f2386b5d5c6f366bb9b0 Mon Sep 17 00:00:00 2001 From: dojutsu-user Date: Thu, 25 Apr 2019 00:12:40 +0530 Subject: [PATCH 3/9] use blocktrans --- readthedocs/rtd_tests/tests/test_project_views.py | 2 +- readthedocs/templates/projects/project_delete.html | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/readthedocs/rtd_tests/tests/test_project_views.py b/readthedocs/rtd_tests/tests/test_project_views.py index e6440bdb60e..fb0140c6839 100644 --- a/readthedocs/rtd_tests/tests/test_project_views.py +++ b/readthedocs/rtd_tests/tests/test_project_views.py @@ -424,7 +424,7 @@ def test_delete_superproject(self): response = self.client.get('/dashboard/pip/delete/') self.assertEqual(response.status_code, 200) self.assertIn( - 'This project has subprojects under it. Deleting this will make them as regular projects. This will effect the URLs of the subprojects and they will be served normally as other projects.', + 'This project has subprojects under it. Deleting this will make them as regular projects. This will effect the URLs of the subprojects and they will be served normally as other projects.', response.content.decode('utf-8') ) diff --git a/readthedocs/templates/projects/project_delete.html b/readthedocs/templates/projects/project_delete.html index 79dac40f9cc..3295d801e27 100644 --- a/readthedocs/templates/projects/project_delete.html +++ b/readthedocs/templates/projects/project_delete.html @@ -8,7 +8,12 @@ {% block content %} {% if is_superproject %} -

This project has subprojects under it. Deleting this will make them as regular projects. This will effect the URLs of the subprojects and they will be served normally as other projects.

+ {% url "projects_subprojects" project.slug as subproject_url %} +

+ {% blocktrans %} + This project has subprojects under it. Deleting this will make them as regular projects. This will effect the URLs of the subprojects and they will be served normally as other projects. + {% endblocktrans %} +

{% endif %}

{% trans "You sure?" %} O_o

From ea536fc9d8e22fcdcbfcb8f95e3c33b7c50bb699 Mon Sep 17 00:00:00 2001 From: dojutsu-user Date: Thu, 25 Apr 2019 00:50:49 +0530 Subject: [PATCH 4/9] improve msg readability --- readthedocs/rtd_tests/tests/test_project_views.py | 7 +++++-- readthedocs/templates/projects/project_delete.html | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/readthedocs/rtd_tests/tests/test_project_views.py b/readthedocs/rtd_tests/tests/test_project_views.py index fb0140c6839..356317ea7e9 100644 --- a/readthedocs/rtd_tests/tests/test_project_views.py +++ b/readthedocs/rtd_tests/tests/test_project_views.py @@ -423,9 +423,12 @@ def test_delete_superproject(self): response = self.client.get('/dashboard/pip/delete/') self.assertEqual(response.status_code, 200) + resp_content = response.content.decode('utf-8') self.assertIn( - 'This project has subprojects under it. Deleting this will make them as regular projects. This will effect the URLs of the subprojects and they will be served normally as other projects.', - response.content.decode('utf-8') + 'This project has subprojects under it. ' + 'Deleting this will make them as regular projects. ' + 'This will effect the URLs of the subprojects and they will be served normally as other projects.', + ' '.join(resp_content.split()) # this is done to remove all escapte sequences and new lines characters. ) def test_subproject_create(self): diff --git a/readthedocs/templates/projects/project_delete.html b/readthedocs/templates/projects/project_delete.html index 3295d801e27..c70c3030dea 100644 --- a/readthedocs/templates/projects/project_delete.html +++ b/readthedocs/templates/projects/project_delete.html @@ -11,7 +11,9 @@ {% url "projects_subprojects" project.slug as subproject_url %}

{% blocktrans %} - This project has subprojects under it. Deleting this will make them as regular projects. This will effect the URLs of the subprojects and they will be served normally as other projects. + This project has subprojects under it. + Deleting this will make them as regular projects. + This will effect the URLs of the subprojects and they will be served normally as other projects. {% endblocktrans %}

{% endif %} From 06ae425a80dbe0c403d9358864d66fb0f4f039cc Mon Sep 17 00:00:00 2001 From: dojutsu-user Date: Thu, 25 Apr 2019 01:00:35 +0530 Subject: [PATCH 5/9] use trimmed with blocktrans --- readthedocs/rtd_tests/tests/test_project_views.py | 3 +-- readthedocs/templates/projects/project_delete.html | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/readthedocs/rtd_tests/tests/test_project_views.py b/readthedocs/rtd_tests/tests/test_project_views.py index 356317ea7e9..cfbcb817184 100644 --- a/readthedocs/rtd_tests/tests/test_project_views.py +++ b/readthedocs/rtd_tests/tests/test_project_views.py @@ -423,12 +423,11 @@ def test_delete_superproject(self): response = self.client.get('/dashboard/pip/delete/') self.assertEqual(response.status_code, 200) - resp_content = response.content.decode('utf-8') self.assertIn( 'This project has subprojects under it. ' 'Deleting this will make them as regular projects. ' 'This will effect the URLs of the subprojects and they will be served normally as other projects.', - ' '.join(resp_content.split()) # this is done to remove all escapte sequences and new lines characters. + response.content.decode('utf-8') ) def test_subproject_create(self): diff --git a/readthedocs/templates/projects/project_delete.html b/readthedocs/templates/projects/project_delete.html index c70c3030dea..a6a0fc553da 100644 --- a/readthedocs/templates/projects/project_delete.html +++ b/readthedocs/templates/projects/project_delete.html @@ -10,7 +10,7 @@ {% if is_superproject %} {% url "projects_subprojects" project.slug as subproject_url %}

- {% blocktrans %} + {% blocktrans trimmed %} This project has subprojects under it. Deleting this will make them as regular projects. This will effect the URLs of the subprojects and they will be served normally as other projects. From dbfe52f16d1faaf2fa671f730d989e90db2a82cc Mon Sep 17 00:00:00 2001 From: dojutsu-user Date: Thu, 25 Apr 2019 01:17:59 +0530 Subject: [PATCH 6/9] use assertContains --- readthedocs/rtd_tests/tests/test_project_views.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/readthedocs/rtd_tests/tests/test_project_views.py b/readthedocs/rtd_tests/tests/test_project_views.py index cfbcb817184..d1deb532da9 100644 --- a/readthedocs/rtd_tests/tests/test_project_views.py +++ b/readthedocs/rtd_tests/tests/test_project_views.py @@ -423,11 +423,13 @@ def test_delete_superproject(self): response = self.client.get('/dashboard/pip/delete/') self.assertEqual(response.status_code, 200) - self.assertIn( + self.assertContains( + response, 'This project has subprojects under it. ' 'Deleting this will make them as regular projects. ' 'This will effect the URLs of the subprojects and they will be served normally as other projects.', - response.content.decode('utf-8') + count=1, + html=True, ) def test_subproject_create(self): From 6d9a1b93530c1a4d4bb48b03362ab2be4a78139f Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Mon, 20 May 2019 12:00:49 +0200 Subject: [PATCH 7/9] Update copy Mention that all the subproject's URLs will break. --- readthedocs/templates/projects/project_delete.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readthedocs/templates/projects/project_delete.html b/readthedocs/templates/projects/project_delete.html index a6a0fc553da..aa11fe3a297 100644 --- a/readthedocs/templates/projects/project_delete.html +++ b/readthedocs/templates/projects/project_delete.html @@ -12,8 +12,8 @@

{% blocktrans trimmed %} This project has subprojects under it. - Deleting this will make them as regular projects. - This will effect the URLs of the subprojects and they will be served normally as other projects. + Deleting this project will make them to be become regular projects. + This will break the URLs of all its subprojects and they will be served normally as other projects. {% endblocktrans %}

{% endif %} From 6f991758e8211d8df291289fc8ddcc63f7e24f93 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Mon, 20 May 2019 12:08:14 +0200 Subject: [PATCH 8/9] Update copy on test --- readthedocs/rtd_tests/tests/test_project_views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readthedocs/rtd_tests/tests/test_project_views.py b/readthedocs/rtd_tests/tests/test_project_views.py index d1deb532da9..a06be95f77f 100644 --- a/readthedocs/rtd_tests/tests/test_project_views.py +++ b/readthedocs/rtd_tests/tests/test_project_views.py @@ -426,8 +426,8 @@ def test_delete_superproject(self): self.assertContains( response, 'This project has subprojects under it. ' - 'Deleting this will make them as regular projects. ' - 'This will effect the URLs of the subprojects and they will be served normally as other projects.', + 'Deleting this project will make them to become regular projects. ' + 'This will break the URLs of all its subprojects and they will be served normally as other projects.', count=1, html=True, ) From 507db1ae62ebe5307bafc264f9e90a98ff8772d0 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Mon, 20 May 2019 12:27:30 +0200 Subject: [PATCH 9/9] Fix --- readthedocs/templates/projects/project_delete.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readthedocs/templates/projects/project_delete.html b/readthedocs/templates/projects/project_delete.html index aa11fe3a297..150c90facff 100644 --- a/readthedocs/templates/projects/project_delete.html +++ b/readthedocs/templates/projects/project_delete.html @@ -12,7 +12,7 @@

{% blocktrans trimmed %} This project has subprojects under it. - Deleting this project will make them to be become regular projects. + Deleting this project will make them to become regular projects. This will break the URLs of all its subprojects and they will be served normally as other projects. {% endblocktrans %}