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):
8282 project = ProjectSerializer (read_only = True )
8383 state = StateField ()
8484 submitter = PersonSerializer (read_only = True )
85- delegate = UserSerializer ()
85+ delegate = UserSerializer (allow_null = True )
8686 mbox = SerializerMethodField ()
8787 series = SeriesSerializer (many = True , read_only = True )
8888 comments = SerializerMethodField ()
@@ -116,6 +116,9 @@ def get_tags(self, instance):
116116
117117 def validate_delegate (self , value ):
118118 """Check that the delgate is a maintainer of the patch's project."""
119+ if not value :
120+ return value
121+
119122 if not self .instance .project .maintainer_project .filter (
120123 id = value .id ).exists ():
121124 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):
224224 self .assertEqual (Patch .objects .get (id = patch .id ).state , state )
225225 self .assertEqual (Patch .objects .get (id = patch .id ).delegate , user )
226226
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+
227234 def test_update_invalid (self ):
228235 """Ensure we handle invalid Patch updates."""
229236 project = create_project ()
You can’t perform that action at this time.
0 commit comments