-
Notifications
You must be signed in to change notification settings - Fork 134
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
Add check if user has permission to add a project to a profile. #1385
Conversation
is there an issue this is tied to? |
@pld I believe this is tied to https://github.com/onaio/core/issues/1357 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only thing to change is the typo.
But also, I don't see any explicit tested for project creation in another users account that replicates the production error.
@@ -0,0 +1,55 @@ | |||
# -*- coding: utf-8 -*- | |||
""" | |||
Command apply_can_add_preject_perms - applys can_add_project permission to all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo, preject
-> project
|
||
class Command(BaseCommand): | ||
""" | ||
Command apply_can_add_preject_perms - applys can_add_project permission to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
PROJ_BASE_FORMS_CACHE, PROJ_FORMS_CACHE, PROJ_NUM_DATASET_CACHE, | ||
PROJ_PERM_CACHE, PROJ_SUB_DATE_CACHE, PROJ_TEAM_USERS_CACHE, | ||
PROJECT_LINKED_DATAVIEWS, safe_delete) | ||
from onadata.libs.utils.decorators import check_obj | ||
|
||
|
||
def get_obj_xforms(obj): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember if there's a historical reason why we have obj
throughout this namespace, but it looks like a future refactor would be to change that to project
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Migration from being in the serializer which expects obj
to being a function outside of the serializer, this are the remnants.
).first() | ||
if md and hasattr(md, 'data_value') and md.data_value: | ||
return True | ||
fields = ('name', 'formid', 'id_string', 'num_of_submissions', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👎
@ukanga would we need the same kind of fix for XForms? |
Does the same kind of error exist for XForm? |
@pld are you talking about this test?
|
No, since that's tests for moving a project. Replicating the error would be on creating a project in another users account. |
Command apply_can_add_project_perms - applies can_add_project permission to all users who have can_add_xform permission to a user/organization profile. This was necessary because we previously, before April 2018, did not have can_add_project permission on the UserProfile and OrganizationProfile classes. An attempt on doing this in migrations seems not to be a recommended approach.
387212f
to
caa1b54
Compare
@moshthepitt no, when using the projects endpoint the user needs to be a manager of the project. On the forms endpoint there is an explicit check if a user has 'can_add_xform'. On the xforms front this is not an issue. |
nearly green, let's merge, get it in next release |
No description provided.