-
Notifications
You must be signed in to change notification settings - Fork 34
feat: Allow users to comment #193
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
Conversation
orronai
commented
Sep 29, 2020
- Users can now comment to their own solutions
- Users can now delete their own comments
- Users can now comment to their own solutions - Users can now delete their own comments
- Changed the style of users comments to different color
- Fixed common comments to be only staff comments
- Added in the configurations a variable that the admin can turn on and off this feature - Changed the common comments according to peewee documentation
- Added checks in the backend to distinguish whether a user has permissions to comment - Added a check in the grader.js javascript file to check if the user can see the trash icon to delete a comment - Added unittest for checking users comments
and not current_user.role.is_manager | ||
): | ||
return fail(403, "You aren't allowed to access this page.") | ||
|
||
if act == 'delete': | ||
comment_id = int(request.args.get('commentId')) | ||
comment_ = Comment.get_or_none(Comment.id == comment_id) |
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.
A user should be able to delete a comment only if its his comment , or he's an administrator
lms/lmsweb/views.py
Outdated
CommentText.select(CommentText.id, CommentText.text).join(Comment) | ||
.join(User).join(Role).where( | ||
CommentText.flake8_key.is_null(True), | ||
Comment.commenter.role > Role.get_student_role().id, |
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.
role
doesn't have total ordering, and we don't wanna take the comments of banned users.
Check if role == administrator or role == staff
- Fixed a test of users trying to delete a staff user's comment - Fixed that users can't remove staff comments
- Fixed a test of users trying to delete a staff user's comment - Fixed that users can't remove staff comments # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # On branch allow-users-comments # Changes to be committed: # modified: lms/lmsdb/models.py # modified: lms/lmsweb/views.py # modified: lms/tests/conftest.py # modified: lms/tests/test_solutions.py #
CommentText.flake8_key.name: None, | ||
}).select(CommentText.id, CommentText.text).join(Comment) | ||
is_moderator_comments = ( | ||
(Comment.commenter.role == Role.get_staff_role().id) |
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.
Comment.commenter.role.is_staff
?
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.
It's not possible - it throws an error that says is_staff, is_manager etc. are not attributes of Role.