diff --git a/app/api/admin.py b/app/api/admin.py index 64023af1..5a3cf4ce 100644 --- a/app/api/admin.py +++ b/app/api/admin.py @@ -19,7 +19,7 @@ class DocumentAdmin(admin.ModelAdmin): class ProjectAdmin(admin.ModelAdmin): - list_display = ('name', 'description', 'project_type', 'randomize_document_order') + list_display = ('name', 'description', 'project_type', 'randomize_document_order', 'collaborative_annotation') ordering = ('project_type',) search_fields = ('name',) diff --git a/app/api/serializers.py b/app/api/serializers.py index eaa2af2c..fa2e0d26 100644 --- a/app/api/serializers.py +++ b/app/api/serializers.py @@ -106,35 +106,31 @@ class ProjectSerializer(serializers.ModelSerializer): model = Project fields = ('id', 'name', 'description', 'guideline', 'users', 'current_users_role', 'project_type', 'image', 'updated_at', 'randomize_document_order', 'collaborative_annotation') - read_only_fields = ('image', 'updated_at', 'current_users_role') + read_only_fields = ('image', 'updated_at', 'users', 'current_users_role') class TextClassificationProjectSerializer(ProjectSerializer): class Meta: model = TextClassificationProject - fields = ('id', 'name', 'description', 'guideline', 'users', 'current_users_role', 'project_type', 'image', - 'updated_at', 'randomize_document_order') - read_only_fields = ('image', 'updated_at', 'users', 'current_users_role') + fields = ProjectSerializer.Meta.fields + read_only_fields = ProjectSerializer.Meta.read_only_fields class SequenceLabelingProjectSerializer(ProjectSerializer): - class Meta: model = SequenceLabelingProject - fields = ('id', 'name', 'description', 'guideline', 'users', 'current_users_role', 'project_type', 'image', - 'updated_at', 'randomize_document_order') - read_only_fields = ('image', 'updated_at', 'users', 'current_users_role') + fields = ProjectSerializer.Meta.fields + read_only_fields = ProjectSerializer.Meta.read_only_fields class Seq2seqProjectSerializer(ProjectSerializer): class Meta: model = Seq2seqProject - fields = ('id', 'name', 'description', 'guideline', 'users', 'current_users_role', 'project_type', 'image', - 'updated_at', 'randomize_document_order') - read_only_fields = ('image', 'updated_at', 'users', 'current_users_role') + fields = ProjectSerializer.Meta.fields + read_only_fields = ProjectSerializer.Meta.read_only_fields class ProjectPolymorphicSerializer(PolymorphicSerializer): diff --git a/app/api/tests/test_api.py b/app/api/tests/test_api.py index 0a77bb7c..46c95466 100644 --- a/app/api/tests/test_api.py +++ b/app/api/tests/test_api.py @@ -111,6 +111,19 @@ 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) + data = dict(self.data) + data['collaborative_annotation'] = True + data['randomize_document_order'] = True + response = self.client.post(self.url, format='json', data=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,