Skip to content

Commit b0f6308

Browse files
committed
Ensure fields are consistent
1 parent af8ca8d commit b0f6308

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

app/api/serializers.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,26 +113,23 @@ class TextClassificationProjectSerializer(ProjectSerializer):
113113

114114
class Meta:
115115
model = TextClassificationProject
116-
fields = ('id', 'name', 'description', 'guideline', 'users', 'current_users_role', 'project_type', 'image',
117-
'updated_at', 'randomize_document_order')
116+
fields = ProjectSerializer.Meta.fields
118117
read_only_fields = ProjectSerializer.Meta.read_only_fields
119118

120119

121120
class SequenceLabelingProjectSerializer(ProjectSerializer):
122121

123122
class Meta:
124123
model = SequenceLabelingProject
125-
fields = ('id', 'name', 'description', 'guideline', 'users', 'current_users_role', 'project_type', 'image',
126-
'updated_at', 'randomize_document_order')
124+
fields = ProjectSerializer.Meta.fields
127125
read_only_fields = ProjectSerializer.Meta.read_only_fields
128126

129127

130128
class Seq2seqProjectSerializer(ProjectSerializer):
131129

132130
class Meta:
133131
model = Seq2seqProject
134-
fields = ('id', 'name', 'description', 'guideline', 'users', 'current_users_role', 'project_type', 'image',
135-
'updated_at', 'randomize_document_order')
132+
fields = ProjectSerializer.Meta.fields
136133
read_only_fields = ProjectSerializer.Meta.read_only_fields
137134

138135

app/api/tests/test_api.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,20 @@ def test_allows_superuser_to_create_project(self):
111111
password=self.super_user_pass)
112112
response = self.client.post(self.url, format='json', data=self.data)
113113
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
114+
self.assertFalse(response.json().get('collaborative_annotation'))
115+
self.assertFalse(response.json().get('randomize_document_order'))
116+
117+
def test_allows_superuser_to_create_project_with_flags(self):
118+
self.client.login(username=self.super_user_name,
119+
password=self.super_user_pass)
120+
response = self.client.post(self.url, format='json', data=dict(
121+
collaborative_annotation=True,
122+
randomize_document_order=True,
123+
**self.data,
124+
))
125+
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
126+
self.assertTrue(response.json().get('collaborative_annotation'))
127+
self.assertTrue(response.json().get('randomize_document_order'))
114128

115129
def test_disallows_project_member_to_create_project(self):
116130
self.client.login(username=self.main_project_member_name,

0 commit comments

Comments
 (0)