Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notify the user when deleting a superproject #5596

Merged
merged 9 commits into from
May 20, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion readthedocs/projects/views/private.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ def project_delete(request, project_slug):
slug=project_slug,
)

context = {
'project': project,
'is_superproject': project.subprojects.all().exists()
}

if request.method == 'POST':
broadcast(
type='app',
Expand All @@ -254,7 +259,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):
Expand Down
14 changes: 14 additions & 0 deletions readthedocs/rtd_tests/tests/test_project_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.
This was a nice shortcut.
I have updated the PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

status code is also checked by assertContains ;)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default is already 200.
Should we write it here explictly?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default is fine

'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])
Expand Down
5 changes: 5 additions & 0 deletions readthedocs/templates/projects/project_delete.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
{% block content-header %}<h1>{% blocktrans with project.name as name %}Delete {{ name }}?{% endblocktrans %}</h1>{% endblock %}

{% block content %}

{% if is_superproject %}
<p>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.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should put a link to the subprojects page here has subprojects...

Also, the paragraph needs to be marked for translation

{% endif %}

<p>{% trans "You sure?" %} O_o</p>

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