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

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.

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

Choose a reason for hiding this comment

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

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

Copy link
Member

Choose a reason for hiding this comment

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

@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

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

@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

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

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

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 is needed for test the query set

@stsewd
Copy link
Member Author

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
@stsewd stsewd deleted the fix-subproject branch February 15, 2018 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants