diff options
author | Gauvain Pocentek <gauvain@pocentek.net> | 2017-02-18 16:39:45 +0100 |
---|---|---|
committer | Gauvain Pocentek <gauvain@pocentek.net> | 2017-02-18 16:39:45 +0100 |
commit | 41ca4497c3e30100991db0e8c673b722e45a6f44 (patch) | |
tree | 0b69a65c01612eba9b8bb2386e15b52308824068 /gitlab/objects.py | |
parent | 1e0ae591616b297739bb5f35db6697eee88909a3 (diff) | |
download | gitlab-41ca4497c3e30100991db0e8c673b722e45a6f44.tar.gz |
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.
Diffstat (limited to 'gitlab/objects.py')
-rw-r--r-- | gitlab/objects.py | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/gitlab/objects.py b/gitlab/objects.py index 41931ab..4f5a394 100644 --- a/gitlab/objects.py +++ b/gitlab/objects.py @@ -222,10 +222,10 @@ class GitlabObject(object): for attribute in attributes: if hasattr(self, attribute): value = getattr(self, attribute) - if isinstance(value, list): - if value and isinstance(value[0], six.string_types): - value = ",".join(value) - if attribute == 'sudo': + # labels need to be sent as a comma-separated list + if attribute == 'labels' and isinstance(value, list): + value = ", ".join(value) + elif attribute == 'sudo': value = str(value) data[attribute] = value @@ -764,6 +764,15 @@ class ApplicationSettings(GitlabObject): canCreate = False canDelete = False + def _data_for_gitlab(self, extra_parameters={}, update=False, + as_json=True): + data = (super(ApplicationSettings, self) + ._data_for_gitlab(extra_parameters, update=update, + as_json=False)) + if not self.domain_whitelist: + data.pop('domain_whitelist', None) + return json.dumps(data) + class ApplicationSettingsManager(BaseManager): obj_cls = ApplicationSettings @@ -1458,19 +1467,6 @@ class ProjectIssue(GitlabObject): [('project_id', 'project_id'), ('issue_id', 'id')]), ) - def _data_for_gitlab(self, extra_parameters={}, update=False, - as_json=True): - # Gitlab-api returns labels in a json list and takes them in a - # comma separated list. - if hasattr(self, "labels"): - if (self.labels is not None and - not isinstance(self.labels, six.string_types)): - labels = ", ".join(self.labels) - extra_parameters['labels'] = labels - - return super(ProjectIssue, self)._data_for_gitlab(extra_parameters, - update) - def subscribe(self, **kwargs): """Subscribe to an issue. |