from com atlassian jira import ComponentManager from com atlassian cro

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from com.atlassian.jira import ComponentManager
from com.atlassian.crowd.embedded.api import CrowdService
from com.atlassian.jira.security.roles import ProjectRoleManager
auth_context = ComponentManager.getInstance().getJiraAuthenticationContext()
CrowdService = ComponentManager.getInstance().getCrowdService()
projectManager = ComponentManager.getInstance().getProjectManager()
projectRoleManager = ComponentManager.getComponentInstanceOfType(ProjectRoleManager)
current_user = auth_context.getUser()
projectMail = projectManager.getProjectObjByKey(u'MAIL')
roleDevelopers = projectRoleManager.getProjectRole(u'Developers')
roleManagers = projectRoleManager.getProjectRole(u'Managers')
checkRoleDevelopers = projectRoleManager.isUserInProjectRole(current_user, roleDevelopers, projectMail)
checkRoleManagers = projectRoleManager.isUserInProjectRole(current_user, roleManagers, projectMail)
components = issue.getComponentObjects()
if components.size() == 1:
if components[0].getName() == u'Почта':
if CrowdService.isUserMemberOfGroup(current_user,CrowdService.getGroup(u'mnt-approve-mail')):
issue.setAssigneeId(components[0].getLead())
elif checkRoleManagers or checkRoleDevelopers:
issue.setAssigneeId(u'anikin')
else:
issue.setAssigneeId(components[0].getLead())
elif components[0].getName() == u'Стораджа':
issue.setAssigneeId(components[0].getLead())