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

Projects
None yet
4 participants
@stsewd
Member

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:

This comment has been minimized.

@stsewd

stsewd Feb 2, 2018

Member

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

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

This comment has been minimized.

@safwanrahman

safwanrahman Feb 15, 2018

Member

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

This comment has been minimized.

@humitos

humitos Feb 15, 2018

Member

@stsewd take a look at this comment.

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

@humitos

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
)

This comment has been minimized.

@humitos

humitos Feb 15, 2018

Member

@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

This comment has been minimized.

@humitos

humitos Feb 15, 2018

Member

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(

This comment has been minimized.

@humitos

humitos Feb 15, 2018

Member

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

This comment has been minimized.

@stsewd

stsewd Feb 15, 2018

Member

This is needed for test the query set

@stsewd

This comment has been minimized.

Member

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 rtfd:master Feb 15, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@stsewd stsewd deleted the stsewd:fix-subproject branch Feb 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment