Skip to content

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

Merged
merged 9 commits into from
Oct 3, 2020
Merged

feat: Allow users to comment #193

merged 9 commits into from
Oct 3, 2020

Conversation

orronai
Copy link
Collaborator

@orronai 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
- 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)
Copy link
Member

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

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,
Copy link
Member

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)
Copy link
Member

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?

Copy link
Collaborator Author

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.

@yammesicka yammesicka merged commit 19e1c67 into master Oct 3, 2020
@yammesicka yammesicka deleted the allow-users-comments branch October 3, 2020 08:00
@yammesicka yammesicka linked an issue Oct 5, 2020 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow students to comment/reply
2 participants