diff options
author | Stephen Finucane <stephen@that.guru> | 2018-01-06 22:43:56 +0000 |
---|---|---|
committer | Stephen Finucane <stephen@that.guru> | 2018-01-10 00:09:08 +0000 |
commit | ba7b56842d2443c57c8648532611a9e2bbccb4fb (patch) | |
tree | d8a3d8774be50aed7836d03ef9094afa53fe3a3e | |
parent | 856b1fef1bc18af02f8a82a0a4098b91e44c448a (diff) | |
download | patchwork-ba7b56842d2443c57c8648532611a9e2bbccb4fb.tar patchwork-ba7b56842d2443c57c8648532611a9e2bbccb4fb.tar.gz |
REST: Make single-use function a staticmethod
Signed-off-by: Stephen Finucane <stephen@that.guru>
-rw-r--r-- | patchwork/api/patch.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/patchwork/api/patch.py b/patchwork/api/patch.py index 1922cf5..115feff 100644 --- a/patchwork/api/patch.py +++ b/patchwork/api/patch.py @@ -38,10 +38,6 @@ from patchwork.models import State from patchwork.parser import clean_subject -def format_state_name(state): - return ' '.join(state.split('-')) - - class StateField(RelatedField): """Avoid the need for a state endpoint. @@ -58,13 +54,17 @@ class StateField(RelatedField): '{data_type}.'), } + @staticmethod + def format_state_name(state): + return ' '.join(state.split('-')) + def to_internal_value(self, data): try: - data = format_state_name(data) + data = self.format_state_name(data) return self.get_queryset().get(name__iexact=data) except State.DoesNotExist: self.fail('invalid_choice', name=data, choices=', '.join([ - format_state_name(x.name) for x in self.get_queryset()])) + self.format_state_name(x.name) for x in self.get_queryset()])) except (TypeError, ValueError): self.fail('incorrect_type', data_type=type(data).__name__) |