[PATCH 01/11] REST: Check.user is not read-only

Daniel Axtens dja at axtens.net
Sun Aug 26 17:10:44 AEST 2018


Hi Stephen,

Super keen to have Django 2.0 support! I dropped patch 8 because I
couldn't get it to work, and applied the small changes I suggested.

I have applied and pushed the remainder.

Regards,
Daniel

> 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 <stephen at that.guru>
> ---
>  patchwork/api/check.py            | 2 +-
>  patchwork/tests/api/test_check.py | 1 +
>  2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/patchwork/api/check.py b/patchwork/api/check.py
> index 8753c7de..5e461de6 100644
> --- a/patchwork/api/check.py
> +++ b/patchwork/api/check.py
> @@ -44,7 +44,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 43181af3..0e7e0cfc 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."""
> -- 
> 2.17.1
>
> _______________________________________________
> Patchwork mailing list
> Patchwork at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/patchwork


More information about the Patchwork mailing list