aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--patchwork/api/check.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/patchwork/api/check.py b/patchwork/api/check.py
index 5b38150..b37d6e0 100644
--- a/patchwork/api/check.py
+++ b/patchwork/api/check.py
@@ -49,7 +49,16 @@ class CheckSerializer(HyperlinkedModelSerializer):
def run_validation(self, data):
for val, label in Check.STATE_CHOICES:
if label == data['state']:
+ # NOTE(stephenfin): 'data' is essentially 'request.POST', which
+ # is immutable by default. However, there's no good reason for
+ # this to be this way [1], so temporarily unset that mutability
+ # to fix what we need to here.
+ #
+ # [1] http://stackoverflow.com/a/12619745/613428
+ mutable = data._mutable # noqa
+ data._mutable = True # noqa
data['state'] = val
+ data._mutable = mutable # noqa
break
return super(CheckSerializer, self).run_validation(data)