@@ -209,7 +209,8 @@ class GitlabObject(object):
209
209
#: Attribute to use as ID when displaying the object.
210
210
shortPrintAttr = None
211
211
212
- def _data_for_gitlab (self , extra_parameters = {}, update = False ):
212
+ def _data_for_gitlab (self , extra_parameters = {}, update = False ,
213
+ as_json = True ):
213
214
data = {}
214
215
if update and (self .requiredUpdateAttrs or self .optionalUpdateAttrs ):
215
216
attributes = itertools .chain (self .requiredUpdateAttrs ,
@@ -227,7 +228,7 @@ def _data_for_gitlab(self, extra_parameters={}, update=False):
227
228
228
229
data .update (extra_parameters )
229
230
230
- return json .dumps (data )
231
+ return json .dumps (data ) if as_json else data
231
232
232
233
@classmethod
233
234
def list (cls , gl , ** kwargs ):
@@ -573,7 +574,8 @@ class User(GitlabObject):
573
574
('keys' , UserKeyManager , [('user_id' , 'id' )])
574
575
]
575
576
576
- def _data_for_gitlab (self , extra_parameters = {}, update = False ):
577
+ def _data_for_gitlab (self , extra_parameters = {}, update = False ,
578
+ as_json = True ):
577
579
if hasattr (self , 'confirm' ):
578
580
self .confirm = str (self .confirm ).lower ()
579
581
return super (User , self )._data_for_gitlab (extra_parameters )
@@ -1191,7 +1193,8 @@ class ProjectIssue(GitlabObject):
1191
1193
managers = [('notes' , ProjectIssueNoteManager ,
1192
1194
[('project_id' , 'project_id' ), ('issue_id' , 'id' )])]
1193
1195
1194
- def _data_for_gitlab (self , extra_parameters = {}, update = False ):
1196
+ def _data_for_gitlab (self , extra_parameters = {}, update = False ,
1197
+ as_json = True ):
1195
1198
# Gitlab-api returns labels in a json list and takes them in a
1196
1199
# comma separated list.
1197
1200
if hasattr (self , "labels" ):
@@ -1369,18 +1372,16 @@ class ProjectMergeRequest(GitlabObject):
1369
1372
managers = [('notes' , ProjectMergeRequestNoteManager ,
1370
1373
[('project_id' , 'project_id' ), ('merge_request_id' , 'id' )])]
1371
1374
1372
- def _data_for_gitlab (self , extra_parameters = {}, update = False ):
1375
+ def _data_for_gitlab (self , extra_parameters = {}, update = False ,
1376
+ as_json = True ):
1373
1377
data = (super (ProjectMergeRequest , self )
1374
- ._data_for_gitlab (extra_parameters , update = update ))
1378
+ ._data_for_gitlab (extra_parameters , update = update ,
1379
+ as_json = False ))
1375
1380
if update :
1376
1381
# Drop source_branch attribute as it is not accepted by the gitlab
1377
1382
# server (Issue #76)
1378
- # We need to unserialize and reserialize the
1379
- # data, this is far from optimal
1380
- d = json .loads (data )
1381
- d .pop ('source_branch' , None )
1382
- data = json .dumps (d )
1383
- return data
1383
+ data .pop ('source_branch' , None )
1384
+ return json .dumps (data )
1384
1385
1385
1386
def subscribe (self , ** kwargs ):
1386
1387
"""Subscribe to a MR.
0 commit comments