-
Notifications
You must be signed in to change notification settings - Fork 10
fix(arhcived-project-tasks): only superuser can edit tasks of archived projects #668
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
base: main
Are you sure you want to change the base?
fix(arhcived-project-tasks): only superuser can edit tasks of archived projects #668
Conversation
…n the project is not archived
d8ec624
to
44db493
Compare
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.
LGTM!
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.
Please add a test for that!
backend/timed/permissions.py
Outdated
@@ -65,6 +65,13 @@ def has_object_permission(self, request, view, _obj): | |||
return self.has_permission(request, view) | |||
|
|||
|
|||
class IsProjectActive(BasePermission): | |||
"""Allow Only the project that is not archived.""" |
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.
"""Allow Only the project that is not archived.""" | |
"""Allows access to object only if a project is not archived.""" |
backend/timed/projects/views.py
Outdated
# only superuser can update tasks of archived projects | ||
| (IsUpdateOnly & IsProjectActive) | ||
# managers may edit all tasks | ||
| IsManager |
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.
The order is wrong!
This means that anyone who isn't a superuser can update a task if the project is active.
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.
Right - and wrong. It's not the order, but the full expression for the permission
# only superuser can update tasks of archived projects | |
| (IsUpdateOnly & IsProjectActive) | |
# managers may edit all tasks | |
| IsManager | |
# only superuser can update tasks of archived projects | |
| (IsUpdateOnly & IsProjectActive & IsManager) |
442b694
to
e50fd22
Compare
the backend tests is failing not because of this PR, and the fix will be #669 |
fix #513