diff --git a/hypha/apply/api/v1/serializers.py b/hypha/apply/api/v1/serializers.py index d80715f24634bbb2488ec8853292f5c568240d86..b366e8486aa2ecae0ba4d3d1f5cdc79f0f2bd8af 100644 --- a/hypha/apply/api/v1/serializers.py +++ b/hypha/apply/api/v1/serializers.py @@ -450,6 +450,7 @@ class CommentEditSerializer(CommentCreateSerializer): class Meta(CommentCreateSerializer.Meta): read_only_fields = ( "timestamp", + "visibility", "edited", ) diff --git a/hypha/apply/api/v1/tests/test_views.py b/hypha/apply/api/v1/tests/test_views.py index e5f8a2f24284daf1203ac50da0a226d22e4ebab3..53c2e0b2b0baa76b615b2d3f0687b630b5bb05cb 100644 --- a/hypha/apply/api/v1/tests/test_views.py +++ b/hypha/apply/api/v1/tests/test_views.py @@ -78,7 +78,7 @@ class TestCommentEdit(TestCase): self.assertEqual(Activity.objects.count(), 1) - def test_staff_can_change_visibility(self): + def test_staff_can_not_change_visibility(self): user = StaffFactory() comment = CommentFactory(user=user, visibility=APPLICANT) self.client.force_login(user) @@ -93,7 +93,7 @@ class TestCommentEdit(TestCase): ) self.assertEqual(response.status_code, 200, response.json()) - self.assertEqual(response.json()["visibility"], ALL) + self.assertEqual(response.json()["visibility"], APPLICANT) def test_out_of_order_does_nothing(self): user = ApplicantFactory() # any role assigned user diff --git a/hypha/apply/api/v1/views.py b/hypha/apply/api/v1/views.py index 84b090670443b72d97e5b770bc742a1eafc63ce4..af2929f35921c5a5d8dcd3fc6cb83a737f2207ac 100644 --- a/hypha/apply/api/v1/views.py +++ b/hypha/apply/api/v1/views.py @@ -384,9 +384,7 @@ class CommentViewSet(viewsets.GenericViewSet): serializer = self.get_serializer(comment_to_edit, data=request.data) serializer.is_valid(raise_exception=True) - if (serializer.validated_data["message"] != comment_to_update.message) or ( - serializer.validated_data["visibility"] != comment_to_update.visibility - ): + if serializer.validated_data["message"] != comment_to_update.message: self.perform_create(serializer) comment_to_update.current = False comment_to_update.save()