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

Don't allow to create a subproject of a project itself #3571

Merged
merged 5 commits into from
Feb 15, 2018
Merged
Changes from 1 commit
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
Next Next commit
Validate for parent and child
stsewd committed Feb 2, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 6a4a0f194ff132dc827ee62b3660a60a80594bbe
7 changes: 7 additions & 0 deletions readthedocs/projects/forms.py
Original file line number Diff line number Diff line change
@@ -270,6 +270,13 @@ def clean_parent(self):
_('Subproject nesting is not supported'))
return self.project

def clean_child(self):
child = self.cleaned_data['child']
if child == self.project:
Copy link
Member Author

Choose a reason for hiding this comment

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

This would not normally happen, unless someone does it manually.

raise forms.ValidationError(
_('A project can not be a subproject of itself'))
return child

def get_subproject_queryset(self):
"""
Return scrubbed subproject choice queryset.