8000 Handle settings.domain_whitelist, partly · uglide/python-gitlab@41ca449 · GitHub
[go: up one dir, main page]

Skip to content

Commit 41ca449

Browse files
author
Gauvain Pocentek
committed
Handle settings.domain_whitelist, partly
The API doesn't like receiving lists, although documentation says it's what's expected. To be investigated. This fixes the tests.
1 parent 1e0ae59 commit 41ca449

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

gitlab/objects.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,10 @@ def _data_for_gitlab(self, extra_parameters={}, update=False,
222222
for attribute in attributes:
223223
if hasattr(self, attribute):
224224
value = getattr(self, attribute)
225-
if isinstance(value, list):
226-
if value and isinstance(value[0], six.string_types):
227-
value = ",".join(value)
228-
if attribute == 'sudo':
225+
# labels need to be sent as a comma-separated list
226+
if attribute == 'labels' and isinstance(value, list):
227+
value = ", ".join(value)
228+
elif attribute == 'sudo':
229229
value = str(value)
230230
data[attribute] = value
231231

@@ -764,6 +764,15 @@ class ApplicationSettings(GitlabObject):
764764
canCreate = False
765765
canDelete = False
766766

767+
def _data_for_gitlab(self, extra_parameters={}, update=False,
768+
as_json=True):
769+
data = (super(ApplicationSettings, self)
770+
._data_for_gitlab(extra_parameters, update=update,
771+
as_json=False))
772+
if not self.domain_whitelist:
773+
data.pop('domain_whitelist', None)
774+
return json.dumps(data)
775+
767776

768777
class ApplicationSettingsManager(BaseManager):
769778
obj_cls = ApplicationSettings
@@ -1458,19 +1467,6 @@ class ProjectIssue(GitlabObject):
14581467
[('project_id', 'project_id'), ('issue_id', 'id')]),
14591468
)
14601469

1461-
def _data_for_gitlab(self, extra_parameters={}, update=False,
1462-
as_json=True):
1463-
# Gitlab-api returns labels in a json list and takes them in a
1464-
# comma separated list.
1465-
if hasattr(self, "labels"):
1466-
if (self.labels is not None and
1467-
not isinstance(self.labels, six.string_types)):
1468-
labels = ", ".join(self.labels)
1469-
extra_parameters['labels'] = labels
1470-
1471-
return super(ProjectIssue, self)._data_for_gitlab(extra_parameters,
1472-
update)
1473-
14741470
def subscribe(self, **kwargs):
14751471
"""Subscribe to an issue.
14761472

0 commit comments

Comments
 (0)
0