Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions jira/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,51 @@ def project_role(self, project, id):

# Resolutions

def add_user_to_role(self, project, role, username):
"""
Add the user ``username`` to the ``role`` in ``project``

:param project: ID or key of the project to get the role from
:param role: ID of the role where the user will be added
:param username: The user to add to the role.
"""
data = {}
data['user'] = [username]
if isinstance(role, Number):
role = "%s" % role
url = self._get_url('project/' + project + '/role/' + role)

r = self._session.post(
url, data=json.dumps(data))
if r.status_code == 200:
return True
else:
logging.warning(
'Failed to add user %s to role. Got code: %s' % (username, r.status_code))
return r.status_code
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function returns bool or int as a result. I think that function result must be consistent - either all time returns bool or int.


def add_group_to_role(self, project, role, group):
"""
Add the ``group`` to the ``role`` in ``project``

:param project: ID or key of the project to get the role from
:param role: ID of the role where the user will be added
:param group: The group to add to the role.
"""
data = {}
data['group'] = [group]
if isinstance(role, Number):
role = "%s" % role
url = self._get_url('project/' + project + '/role/' + role)

r = self._session.post(url, data=json.dumps(data))
if r.status_code == 200:
return True
else:
logging.warning(
'Failed to add group %s to role. Got code: %s' % (group, r.status_code))
return r.status_code

def resolutions(self):
"""Get a list of resolution Resources from the server."""
r_json = self._get_json('resolution')
Expand Down