On Tue, 2016-11-22 at 12:10 -0600, Andy Doan wrote: > 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?
Oh, that's a side effect too. More importantly though, it's about actually enabling this to change. The tests to check this were wrong, and we weren't actually able to change state using the code as is. That's fixed now. > > > > Signed-off-by: Stephen Finucane <[email protected]> > > Cc: Andy Doan <[email protected]> > > --- > > 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()] I considered this, but 'replace' will replace multiple spaces with multiple '-'. It's unlikely to happen, but I'd rather avoid the change of getting 'hello--world' if possible. I'm happy to reassess that, however :) Stephen _______________________________________________ Patchwork mailing list [email protected] https://lists.ozlabs.org/listinfo/patchwork
