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

Conversation

@stsewd
Copy link
Member

@stsewd stsewd commented Feb 2, 2018

Closes #3449

@@ -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

@stsewd stsewd Feb 2, 2018

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

{'child': subproject.pk},
project=project,
user=user
)
Copy link
Member

@safwanrahman safwanrahman Feb 15, 2018

I think is_valid should be called and tested that it return False

Copy link
Member

@humitos humitos Feb 15, 2018

@stsewd take a look at this comment.

If you don't calle is_valid all your validations (clean_ methods) are not called.

Copy link
Member

@humitos humitos left a comment

This looks good!

Please, take a look at the comments and I think we will be ready to merge after that.

{'child': subproject.pk},
project=project,
user=user
)
Copy link
Member

@humitos humitos Feb 15, 2018

@stsewd take a look at this comment.

If you don't calle is_valid all your validations (clean_ methods) are not called.

def test_exclude_self_project_as_subproject(self):
user = fixture.get(User)
project = fixture.get(Project, users=[user])
subproject = project
Copy link
Member

@humitos humitos Feb 15, 2018

Do not assign this variable. So, in the form initialization it's clear that we are using the same project for both fields.

project=project,
user=user
)
self.assertNotIn(
Copy link
Member

@humitos humitos Feb 15, 2018

I think this won't be needed once you use is_valid method.

Copy link
Member Author

@stsewd stsewd Feb 15, 2018

This is needed for test the query set

@stsewd
Copy link
Member Author

@stsewd stsewd commented Feb 15, 2018

@safwanrahman @humitos thanks for the feedback, I update the PR and responded to @humitos comment.

@safwanrahman safwanrahman merged commit dca2b8c into readthedocs:master Feb 15, 2018
1 check passed
@stsewd stsewd deleted the fix-subproject branch Feb 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants