Skip to content

Commit 2a1a581

Browse files
author
Gonchik Tsymzhitov
committed
Confluence: polish bugfix and new example for normalizing permissions
1 parent 32b6879 commit 2a1a581

File tree

3 files changed

+60
-2
lines changed

3 files changed

+60
-2
lines changed

atlassian/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.7.0
1+
3.7.1

atlassian/confluence.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ def get_blueprint_templates(self, space=None, start=0, limit=None, expand=None):
838838

839839
return response.get("results") or []
840840

841-
@deprecated(since="3.7.0", reason="Use get_content_templates()")
841+
@deprecated(version="3.7.0", reason="Use get_content_templates()")
842842
def get_all_templates_from_space(self, space, start=0, limit=None, expand=None):
843843
"""
844844
Get all users templates from space. Experimental API
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# coding: utf8
2+
from atlassian import Jira
3+
4+
"""
5+
That example use for normalizing the permission schemes between
6+
BROWSE_PROJECTS and WORK_ON_ISSUES parameters
7+
"""
8+
9+
""" Login part"""
10+
11+
jira = Jira(url="JIRA_URL", username="ATLASSIAN_LOGIN", password="ATLASSIAN_PASSWORD")
12+
13+
"""Get all permission schemes ID's"""
14+
15+
permission_schemes = jira.get_all_permissionschemes()
16+
scheme_id_list = []
17+
for item in permission_schemes:
18+
# Get id's (except default)
19+
if item.get("id") != 0:
20+
scheme_id_list.append(item.get("id"))
21+
22+
"""Make a func for checking permissions matching"""
23+
24+
25+
def check_if_permissions_match(permission_id):
26+
browse_projects = []
27+
work_on_issues = []
28+
29+
scheme = jira.get_permissionscheme(permission_id, expand="permissions")
30+
31+
for permission in scheme["permissions"]:
32+
permission["holder"].pop("expand", None)
33+
if permission["permission"] == "WORK_ON_ISSUES":
34+
work_on_issues.append(permission["holder"])
35+
elif permission["permission"] == "BROWSE_PROJECTS":
36+
browse_projects.append(permission["holder"])
37+
if browse_projects == work_on_issues:
38+
missing_permissions = False
39+
elif not work_on_issues:
40+
missing_permissions = browse_projects
41+
else:
42+
missing_permissions = []
43+
for parameter in browse_projects:
44+
if parameter in work_on_issues:
45+
pass
46+
else:
47+
missing_permissions.append(parameter)
48+
return missing_permissions
49+
50+
51+
evaluate_flag = True
52+
for id in scheme_id_list:
53+
result = check_if_permissions_match(id)
54+
print(result)
55+
if result and evaluate_flag:
56+
for item in result:
57+
grant = dict(holder=item, permission="WORK_ON_ISSUES")
58+
jira.set_permissionscheme_grant(id, grant)

0 commit comments

Comments
 (0)