File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ class PatchListSerializer(BaseHyperlinkedModelSerializer):
82
82
project = ProjectSerializer (read_only = True )
83
83
state = StateField ()
84
84
submitter = PersonSerializer (read_only = True )
85
- delegate = UserSerializer ()
85
+ delegate = UserSerializer (allow_null = True )
86
86
mbox = SerializerMethodField ()
87
87
series = SeriesSerializer (many = True , read_only = True )
88
88
comments = SerializerMethodField ()
@@ -116,6 +116,9 @@ def get_tags(self, instance):
116
116
117
117
def validate_delegate (self , value ):
118
118
"""Check that the delgate is a maintainer of the patch's project."""
119
+ if not value :
120
+ return value
121
+
119
122
if not self .instance .project .maintainer_project .filter (
120
123
id = value .id ).exists ():
121
124
raise ValidationError ("User '%s' is not a maintainer for project "
Original file line number Diff line number Diff line change @@ -224,6 +224,13 @@ def test_update(self):
224
224
self .assertEqual (Patch .objects .get (id = patch .id ).state , state )
225
225
self .assertEqual (Patch .objects .get (id = patch .id ).delegate , user )
226
226
227
+ # (who can unset fields too)
228
+ # we need to send as JSON due to https://stackoverflow.com/q/30677216/
229
+ resp = self .client .patch (self .api_url (patch .id ), {'delegate' : None },
230
+ format = 'json' )
231
+ self .assertEqual (status .HTTP_200_OK , resp .status_code , resp )
232
+ self .assertIsNone (Patch .objects .get (id = patch .id ).delegate )
233
+
227
234
def test_update_invalid (self ):
228
235
"""Ensure we handle invalid Patch updates."""
229
236
project = create_project ()
You can’t perform that action at this time.
0 commit comments