Skip to content

Commit

Permalink
Merge branch 'fastcat-issue-65'
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Jul 15, 2015
2 parents ac501e8 + 10e199d commit 3dd925a
Showing 1 changed file with 32 additions and 7 deletions.
39 changes: 32 additions & 7 deletions jira/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def __init__(self, options, session, raw=None):
if raw:
self._parse_raw(raw)

def update(self, fields=None, async=None, jira=None, **fieldargs):
def update(self, fields=None, update=None, async=None, jira=None, **fieldargs):
"""
Update this issue on the server.
Expand All @@ -344,17 +344,42 @@ def update(self, fields=None, async=None, jira=None, **fieldargs):
fields in an issue. This information is available through the :py:meth:`.JIRA.editmeta` method. Further examples
are available here: https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+Example+-+Edit+issues
:param fields: a dict containing field names and the values to use; if present, all other keyword arguments\
will be ignored
:param fields: a dict containing field names and the values to use
:param update: a dict containing update operations to apply
keyword arguments will generally be merged into fields, except lists, which will be merged into updates
"""
data = {}
if fields is not None:
data['fields'] = fields
fields_dict = fields
else:
fields_dict = {}
for field in fieldargs:
fields_dict[field] = fieldargs[field]
data['fields'] = fields_dict
data['fields'] = fields_dict
if update is not None:
update_dict = update
else:
update_dict = {}
data['update'] = update_dict
for field, value in fieldargs.iteritems():
# apply some heuristics to make certain changes easier
if isinstance(value, string_types):
if field == 'assignee' or field == 'reporter':
fields_dict['assignee'] = {'name': value}
elif field == 'comment':
if not 'comment' in update_dict:
update_dict['comment'] = []
update_dict['comment'].append({
'add': { 'body': value }
})
else:
fields_dict[field] = value
elif isinstance(value, list):
if not field in update_dict:
update_dict[field] = []
update_dict[field].extend(value)
else:
fields_dict[field] = value

super(Issue, self).update(async=async, jira=jira, fields=data)

Expand Down

0 comments on commit 3dd925a

Please sign in to comment.