Skip to content

Commit 1ecb739

Browse files
author
Gauvain Pocentek
committed
fix ProjectLabel get and delete
1 parent 9709d79 commit 1ecb739

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

gitlab/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ def delete(self, obj, id=None, **kwargs):
454454
raise GitlabDeleteError('Missing attribute(s): %s' %
455455
", ".join(missing))
456456

457-
obj_id = params[obj.idAttr]
457+
obj_id = params[obj.idAttr] if obj._id_in_delete_url else None
458458
url = self._construct_url(id_=obj_id, obj=obj, parameters=params)
459459
headers = self._create_headers()
460460

gitlab/objects.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,12 @@ class GitlabObject(object):
177177
# Some objects (e.g. merge requests) have different urls for singular and
178178
# plural
179179
_urlPlural = None
180+
_id_in_delete_url = True
180181
_returnClass = None
181182
_constructorTypes = None
183+
182184
#: Whether _get_list_or_object should return list or object when id is None
183185
getListWhenNoId = True
184-
185186
#: Tells if GitLab-api allows retrieving single objects.
186187
canGet = True
187188
#: Tells if GitLab-api allows listing of objects.
@@ -897,6 +898,8 @@ class ProjectMilestoneManager(BaseManager):
897898

898899
class ProjectLabel(GitlabObject):
899900
_url = '/projects/%(project_id)s/labels'
901+
_id_in_delete_url = False
902+
canGet = 'from_list'
900903
requiredUrlAttrs = ['project_id']
901904
idAttr = 'name'
902905
requiredDeleteAttrs = ['name']

tools/python_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@
115115

116116
# labels
117117
label1 = admin_project.labels.create({'name': 'label1', 'color': '#778899'})
118+
label1 = admin_project.labels.get('label1')
118119
assert(len(admin_project.labels.list()) == 1)
119120
label1.new_name = 'label1updated'
120121
label1.save()
121122
assert(label1.name == 'label1updated')
122-
# FIXME(gpocentek): broken
123-
# label1.delete()
123+
label1.delete()
124124

125125
# milestones
126126
m1 = admin_project.milestones.create({'title': 'milestone1'})

0 commit comments

Comments
 (0)