[PATCH v2 07/13] REST: Make 'Patch.state' editable

Andy Doan andy.doan at linaro.org
Wed Nov 23 05:10:04 AEDT 2016


On 11/19/2016 10:51 AM, Stephen Finucane wrote:
> This is one of the most useful fields to allow editing of via the API.
> Make it so.

So this is really about changing states to be managed by name rather 
than id, right?

> Signed-off-by: Stephen Finucane <stephen at that.guru>
> Cc: Andy Doan <andy.doan at linaro.org>
> ---
>  patchwork/api/__init__.py        |  5 +++++
>  patchwork/api/patch.py           | 30 +++++++++++++++++++++++++-----
>  patchwork/tests/test_rest_api.py |  6 ++++--
>  3 files changed, 34 insertions(+), 7 deletions(-)
>
> diff --git a/patchwork/api/__init__.py b/patchwork/api/__init__.py
> index dbd8148..73a1dc7 100644
> --- a/patchwork/api/__init__.py
> +++ b/patchwork/api/__init__.py
> @@ -23,6 +23,11 @@ from rest_framework import permissions
>  from rest_framework.pagination import PageNumberPagination
>  from rest_framework.response import Response
>
> +from patchwork.models import State
> +
> +STATE_CHOICES = ['-'.join(state.name.lower().split())
> +                 for state in State.objects.all()]

This confused me for a moment. I think a more clear way to do this would be:

  [x.name.lower().replace(' ', '-') for x in State.objects.all()]



More information about the Patchwork mailing list