-
Notifications
You must be signed in to change notification settings - Fork 11
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
files: fix files permissions #754
Conversation
7c94764
to
85e3eb3
Compare
54b1ee9
to
c56134b
Compare
c56134b
to
0ce3750
Compare
"""Update permission check. | ||
|
||
:param user: Current user record. | ||
:param recor: Record to check. |
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.
:param record: Record to check.
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 will fix it with a find and replace.
"""Delete permission check. | ||
|
||
:param user: Current user record. | ||
:param recor: Record to check. |
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.
:param record: Record to check.
sonar/modules/documents/utils.py
Outdated
:param for_permission: True if it is used to compute permissions. | ||
:param file: File dict. | ||
:param organisations: List of organisations. |
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.
:param file: File dict.
:param organisations: List of organisations.
:param for_permission: True if it is used to compute permissions.
Mainly the same behavior than the corresponding organisation record. | ||
|
||
:param user: Current user record. | ||
:param recor: Record to check. |
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.
:param record: Record to check.
"""Delete permission check. | ||
|
||
:param user: Current user record. | ||
:param recor: Record to check. |
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.
:param record: Record to check.
if deposit: | ||
can = DepositPermission.read(user, deposit) | ||
if can: | ||
return True | ||
return False |
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.
same here
if deposit: | ||
can = DepositPermission.update(user, deposit) | ||
if can: | ||
return True |
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.
same here
if deposit: | ||
can = DepositPermission.delete(user, deposit) | ||
if can: | ||
return True | ||
return False |
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.
same here
if document: | ||
can_read_document = DocumentPermission.read(user, document) | ||
if not can_read_document: |
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.
could be merged
if organisation: | ||
can = OrganisationPermission.update(user, organisation) | ||
if can: | ||
return True |
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.
same again
sonar/modules/permissions.py
Outdated
(pid, rec) = request.view_args.get('pid_value').data | ||
if pid.pid_type == 'doc': | ||
from .documents.permissions import DocumentFilesPermission | ||
return DocumentFilesPermission.create_permission(obj, action) | ||
if pid.pid_type == 'coll': | ||
from .collections.permissions import FilesPermission as CollectionFilesPermission | ||
return CollectionFilesPermission.create_permission(obj, action) | ||
if pid.pid_type == 'org': | ||
from .organisations.permissions import OrganisationFilesPermission | ||
return OrganisationFilesPermission.create_permission(obj, action) | ||
if pid.pid_type == 'depo': | ||
from .deposits.permissions import DepositFilesPermission | ||
return DepositFilesPermission.create_permission(obj, action) | ||
return FilesPermission.create_permission(obj, action) |
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.
Maybe a good idea to create an utils function returning the FilesPermissions
subclass based on pid_type.
The code should be simplifer
permission_class = utils_get_permissions_class(pid_type) // should return FilePermission as default value
return permission_class.create_permission(obj, action)
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 have create a config instead.
0ce3750
to
68ff0fd
Compare
sonar/modules/permissions.py
Outdated
if request.view_args.get('pid_value'): | ||
(pid, rec) = request.view_args.get('pid_value').data | ||
pid_type = pid.pid_type | ||
print('===============>', |
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.
remove this beautiful print ;-)
339a8f2
to
a0e5c5c
Compare
|
7647014
to
bbae1bd
Compare
* Adds files restriction for documents. * Adds files restriction for deposits. * Adds files restriction for organisations. * Adds files restriction for collections. * Fixes document restrictions. * Closes rero#746. Co-Authored-by: Johnny Mariéthoz <[email protected]>
bbae1bd
to
0d0046c
Compare
Signed-off-by: Johnny Mariéthoz [email protected]
Why are you opening this PR?
How to test?
Code review check list