Skip to content

Commit

Permalink
Merge branch 'coddingtonbear-allow_remotelinks_if_no_applicationlinks'
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Jul 15, 2015
2 parents e8817ce + ce50aad commit 02f7273
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
21 changes: 19 additions & 2 deletions jira/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,23 @@ def add_remote_link(self, issue, destination, globalId=None, application=None, r
"broken: see https://bitbucket.org/bspeakmon/jira-python/issue/46 and https://jira.atlassian.com/browse/JRA-38551",
Warning)

try:
applicationlinks = self.applicationlinks()
except JIRAError as e:
applicationlinks = []
# In many (if not most) configurations, non-admin users are
# not allowed to list applicationlinks; if we aren't allowed,
# let's let people try to add remote links anyway, we just
# won't be able to be quite as helpful.
warnings.warn(
"Unable to gather applicationlinks; you will not be able "
"to add links to remote issues: (%s) %s" % (
e.status_code,
e.text
),
Warning
)

data = {}
if type(destination) == Issue:

Expand All @@ -936,7 +953,7 @@ def add_remote_link(self, issue, destination, globalId=None, application=None, r
'url': destination.permalink()
}

for x in self.applicationlinks():
for x in applicationlinks:
if x['application']['displayUrl'] == destination._options['server']:
data['globalId'] = "appId=%s&issueId=%s" % (
x['application']['id'], destination.raw['id'])
Expand All @@ -958,7 +975,7 @@ def add_remote_link(self, issue, destination, globalId=None, application=None, r
data['relationship'] = relationship

# check if the link comes from one of the configured application links
for x in self.applicationlinks():
for x in applicationlinks:
if x['application']['displayUrl'] == self._options['server']:
data['globalId'] = "appId=%s&issueId=%s" % (
x['application']['id'], destination.raw['id'])
Expand Down
2 changes: 1 addition & 1 deletion jira/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# 1) we don't load dependencies by storing it in __init__.py
# 2) we can import it in setup.py for the same reason
# 3) we can import it into the jira module
__version__ = '0.48'
__version__ = '0.48.1'

0 comments on commit 02f7273

Please sign in to comment.