Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion atlassian/bitbucket/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@ def repo_users_with_administrator_permissions(self, project_key, repo_key):
repo_administrators = []
for user in self.repo_users(project_key, repo_key):
if user["permission"] == "REPO_ADMIN":
repo_administrators.append(user['user'])
repo_administrators.append(user["user"])
for group in self.repo_groups_with_administrator_permissions(project_key, repo_key):
for user in self.group_members(group):
repo_administrators.append(user)
Expand Down
22 changes: 22 additions & 0 deletions atlassian/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -1971,6 +1971,28 @@ def issue_edit_comment(
params: dict = {"notifyUsers": "true" if notify_users else "false"}
return self.put(url, data=data, params=params)

def issue_pin_comment(self, issue_key: str, comment_id: T_id) -> T_resp_json:
"""
Pin a comment on a Jira issue
:param issue_key: str
:param comment_id: int or str
:return:
"""
base_url = self.resource_url("issue")
url = f"{base_url}/{issue_key}/comment/{comment_id}/pin"
return self.put(url, data=True)

def issue_unpin_comment(self, issue_key: str, comment_id: T_id) -> T_resp_json:
"""
Unpin a comment on a Jira issue
:param issue_key: str
:param comment_id: int or str
:return:
"""
base_url = self.resource_url("issue")
url = f"{base_url}/{issue_key}/comment/{comment_id}/pin"
return self.put(url, data=False)

def scrap_regex_from_issue(self, issue: str, regex: str):
"""
This function scrapes the output of the given regex matches from the issue's description and comments.
Expand Down
1 change: 0 additions & 1 deletion atlassian/models/jira/issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from atlassian.models.jira.fields import IssueFields, IssueType


_ISSUE_TYPE_REGISTRY: dict[str, type[JiraIssue]] = {}


Expand Down
2 changes: 1 addition & 1 deletion atlassian/rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ def request(
url += ("&" if params or params_already_in_url else "") + "&".join(flags or [])
json_dump = None
if files is None:
data = None if not data else dumps(data)
data = None if data is None else dumps(data)
json_dump = None if not json else dumps(json)

headers = headers or self.default_headers
Expand Down
18 changes: 6 additions & 12 deletions atlassian/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,12 @@ def block_code_macro_confluence(code, lang=None):
"""
if not lang:
lang = ""
return (
"""\
return ("""\
<ac:structured-macro ac:name="code" ac:schema-version="1">
<ac:parameter ac:name="language">{lang}</ac:parameter>
<ac:plain-text-body><![CDATA[{code}]]></ac:plain-text-body>
</ac:structured-macro>
"""
).format(lang=lang, code=code)
""").format(lang=lang, code=code)


def html_code__macro_confluence(text):
Expand All @@ -229,13 +227,11 @@ def html_code__macro_confluence(text):
:param text:
:return:
"""
return (
"""\
return ("""\
<ac:structured-macro ac:name="html" ac:schema-version="1">
<ac:plain-text-body><![CDATA[{text}]]></ac:plain-text-body>
</ac:structured-macro>
"""
).format(text=text)
""").format(text=text)


def noformat_code_macro_confluence(text, nopanel=None):
Expand All @@ -247,14 +243,12 @@ def noformat_code_macro_confluence(text, nopanel=None):
"""
if not nopanel:
nopanel = False
return (
"""\
return ("""\
<ac:structured-macro ac:name="noformat" ac:schema-version="1">
<ac:parameter ac:name="nopanel">{nopanel}</ac:parameter>
<ac:plain-text-body><![CDATA[{text}]]></ac:plain-text-body>
</ac:structured-macro>
"""
).format(nopanel=nopanel, text=text)
""").format(nopanel=nopanel, text=text)


def symbol_normalizer(text):
Expand Down
6 changes: 2 additions & 4 deletions examples/jira/jira_admins_confluence_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@

confluence = Confluence(url="http://localhost:8090", username="admin", password="admin")

html = [
"""<table>
html = ["""<table>
<tr>
<th>Project Key</th>
<th>Project Name</th>
<th>Leader</th>
<th>Email</th>
</tr>"""
]
</tr>"""]

for data in jira.project_leaders():
log.info("{project_key} leader is {lead_name} <{lead_email}>".format(**data))
Expand Down
4 changes: 1 addition & 3 deletions examples/jira/jira_project_administrators.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
<td>{project_name}</td>
<td>{lead_name}</td>
<td><a href="mailto:{lead_email}">{lead_email}</a></td>
</tr>""".format(
**data
)
</tr>""".format(**data)

html += "</table>"

Expand Down
6 changes: 2 additions & 4 deletions examples/jira/jira_project_leaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@
jira = Jira(url="http://localhost:8080", username="admin", password="admin")

EMAIL_SUBJECT = quote("Jira access to project {project_key}")
EMAIL_BODY = quote(
"""I am asking for access to the {project_key} project in Jira.
EMAIL_BODY = quote("""I am asking for access to the {project_key} project in Jira.

To give me the appropriate permissions, assign me to a role on the page:
http://localhost:8080/plugins/servlet/project-config/{project_key}/roles

Role:
Users - read-only access + commenting
Developers - work on tasks, editing, etc.
Admin - Change of configuration and the possibility of starting sprints"""
)
Admin - Change of configuration and the possibility of starting sprints""")

MAILTO = '<a href="mailto:{lead_email}?subject={email_subject}&body={email_body}">{lead_name}</a>'

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
responses['true'] = {}
responses['false'] = {}
8 changes: 8 additions & 0 deletions tests/test_jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ def test_get_issue_comment_not_found(self):
with self.assertRaises(HTTPError):
self.jira.epic_issues("BAR-11")

def test_pin_issue_comment(self):
"""Can pin a comment on an issue"""
self.jira.issue_pin_comment("FOO-123", 10000)

def test_unpin_issue_comment(self):
"""Can unpin a comment on an issue"""
self.jira.issue_unpin_comment("FOO-123", 10000)

def test_post_issue_with_invalid_request(self):
"""Post an issue but receive a 400 error response"""
with self.assertRaises(HTTPError):
Expand Down
Loading