diff --git a/app/api/serializers.py b/app/api/serializers.py index e95cae33..fa2e0d26 100644 --- a/app/api/serializers.py +++ b/app/api/serializers.py @@ -113,8 +113,7 @@ class TextClassificationProjectSerializer(ProjectSerializer): class Meta: model = TextClassificationProject - fields = ('id', 'name', 'description', 'guideline', 'users', 'current_users_role', 'project_type', 'image', - 'updated_at', 'randomize_document_order') + fields = ProjectSerializer.Meta.fields read_only_fields = ProjectSerializer.Meta.read_only_fields @@ -122,8 +121,7 @@ class SequenceLabelingProjectSerializer(ProjectSerializer): class Meta: model = SequenceLabelingProject - fields = ('id', 'name', 'description', 'guideline', 'users', 'current_users_role', 'project_type', 'image', - 'updated_at', 'randomize_document_order') + fields = ProjectSerializer.Meta.fields read_only_fields = ProjectSerializer.Meta.read_only_fields @@ -131,8 +129,7 @@ class Seq2seqProjectSerializer(ProjectSerializer): class Meta: model = Seq2seqProject - fields = ('id', 'name', 'description', 'guideline', 'users', 'current_users_role', 'project_type', 'image', - 'updated_at', 'randomize_document_order') + fields = ProjectSerializer.Meta.fields read_only_fields = ProjectSerializer.Meta.read_only_fields diff --git a/app/api/tests/test_api.py b/app/api/tests/test_api.py index 0a77bb7c..5369fa1e 100644 --- a/app/api/tests/test_api.py +++ b/app/api/tests/test_api.py @@ -111,6 +111,20 @@ class TestProjectListAPI(APITestCase): password=self.super_user_pass) response = self.client.post(self.url, format='json', data=self.data) self.assertEqual(response.status_code, status.HTTP_201_CREATED) + self.assertFalse(response.json().get('collaborative_annotation')) + self.assertFalse(response.json().get('randomize_document_order')) + + def test_allows_superuser_to_create_project_with_flags(self): + self.client.login(username=self.super_user_name, + password=self.super_user_pass) + response = self.client.post(self.url, format='json', data=dict( + collaborative_annotation=True, + randomize_document_order=True, + **self.data, + )) + self.assertEqual(response.status_code, status.HTTP_201_CREATED) + self.assertTrue(response.json().get('collaborative_annotation')) + self.assertTrue(response.json().get('randomize_document_order')) def test_disallows_project_member_to_create_project(self): self.client.login(username=self.main_project_member_name,