From: Stephen Finucane Date: Tue, 30 Apr 2019 06:02:59 +0000 (+1000) Subject: REST: Check.user is not read-only X-Git-Tag: v2.1.2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=641b1232169023b74c3bf900c1a6f2347743ad72;p=thirdparty%2Fpatchwork.git REST: Check.user is not read-only We only support 'Check' creation - not check updating. As a result, there's no real reason that the 'Check.user' field should be read-only and this is causing an issue with Django REST Framework 3.7. Simply remove the attribute and extend the tests to validate things are working as expected. Signed-off-by: Stephen Finucane Reviewed-by: Daniel Axtens Signed-off-by: Daniel Axtens (cherry picked from commit c9cc59dac70d76971a5342ca53e2b13eb93592de) --- diff --git a/patchwork/api/check.py b/patchwork/api/check.py index 594ecd4b..d76573a5 100644 --- a/patchwork/api/check.py +++ b/patchwork/api/check.py @@ -46,7 +46,7 @@ class CheckSerializer(HyperlinkedModelSerializer): url = CheckHyperlinkedIdentityField('api-check-detail') patch = HiddenField(default=CurrentPatchDefault()) - user = UserSerializer(read_only=True, default=CurrentUserDefault()) + user = UserSerializer(default=CurrentUserDefault()) def run_validation(self, data): for val, label in Check.STATE_CHOICES: diff --git a/patchwork/tests/api/test_check.py b/patchwork/tests/api/test_check.py index bc06e86e..f5a8eca1 100644 --- a/patchwork/tests/api/test_check.py +++ b/patchwork/tests/api/test_check.py @@ -67,6 +67,7 @@ class TestCheckAPI(APITestCase): self.assertEqual(check_obj.target_url, check_json['target_url']) self.assertEqual(check_obj.context, check_json['context']) self.assertEqual(check_obj.description, check_json['description']) + self.assertEqual(check_obj.user.id, check_json['user']['id']) def test_list(self): """Validate we can list checks on a patch."""