Skip to content

Commit

Permalink
Add support for Project badges
Browse files Browse the repository at this point in the history
  • Loading branch information
Miouge1 committed May 27, 2018
1 parent 97c8619 commit e00cad4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions gitlab/v4/objects.py
Expand Up @@ -1250,6 +1250,18 @@ def enable(self, key_id, **kwargs):
self.gitlab.http_post(path, **kwargs)


class ProjectBadge(SaveMixin, ObjectDeleteMixin, RESTObject):
pass


class ProjectBadgeManager(CRUDMixin, RESTManager):
_path = '/projects/%(project_id)s/badges'
_obj_cls = ProjectBadge
_from_parent_attrs = {'project_id': 'id'}
_create_attrs = (('link_url', 'image_url'), tuple())
_update_attrs = (('link_url', 'image_url'), tuple())


class ProjectEvent(Event):
pass

Expand Down Expand Up @@ -2472,6 +2484,7 @@ class Project(SaveMixin, ObjectDeleteMixin, RESTObject):
_short_print_attr = 'path'
_managers = (
('accessrequests', 'ProjectAccessRequestManager'),
('badges', 'ProjectBadgeManager'),
('boards', 'ProjectBoardManager'),
('branches', 'ProjectBranchManager'),
('jobs', 'ProjectJobManager'),
Expand Down
6 changes: 6 additions & 0 deletions tools/python_test_v4.py
Expand Up @@ -583,6 +583,12 @@
#lists = board.lists.list()
#assert(len(lists) == begin_size - 1)

# project badges
badge_image = 'http://example.com'
badge_link = 'http://example/img.svg'
bp = admin_project.badges.create({'link_url': badge_link, 'image_url': badge_image})
assert(len(admin_project.badges.list()) == 1)

# project wiki
wiki_content = 'Wiki page content'
wp = admin_project.wikis.create({'title': 'wikipage', 'content': wiki_content})
Expand Down

0 comments on commit e00cad4

Please sign in to comment.