fix: post anonymous to peers not visible for ta (#29915)
* fix: post anonymous to peers not visible for ta * test: fix tests
This commit is contained in:
@@ -164,9 +164,11 @@ class _ContentSerializer(serializers.Serializer):
|
||||
Returns a boolean indicating whether the content should be anonymous to
|
||||
the requester.
|
||||
"""
|
||||
user_id = self.context["request"].user.id
|
||||
is_user_staff = user_id in self.context["staff_user_ids"]
|
||||
return (
|
||||
obj["anonymous"] or
|
||||
obj["anonymous_to_peers"] and not self.context["is_requester_privileged"]
|
||||
obj["anonymous_to_peers"] and not is_user_staff
|
||||
)
|
||||
|
||||
def get_author(self, obj):
|
||||
|
||||
@@ -73,7 +73,7 @@ class SerializerTestMixin(ForumsEnableMixin, CommentsServiceMockMixin, UrlResetM
|
||||
(FORUM_ROLE_MODERATOR, True, False, True),
|
||||
(FORUM_ROLE_MODERATOR, False, True, False),
|
||||
(FORUM_ROLE_COMMUNITY_TA, True, False, True),
|
||||
(FORUM_ROLE_COMMUNITY_TA, False, True, False),
|
||||
(FORUM_ROLE_COMMUNITY_TA, False, True, True),
|
||||
(FORUM_ROLE_STUDENT, True, False, True),
|
||||
(FORUM_ROLE_STUDENT, False, True, True),
|
||||
)
|
||||
@@ -82,7 +82,7 @@ class SerializerTestMixin(ForumsEnableMixin, CommentsServiceMockMixin, UrlResetM
|
||||
"""
|
||||
Test that content is properly made anonymous.
|
||||
|
||||
Content should be anonymous iff the anonymous field is true or the
|
||||
Content should be anonymous if the anonymous field is true or the
|
||||
anonymous_to_peers field is true and the requester does not have a
|
||||
privileged role.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user