操作JIRA的API来实现的。
但感觉比单纯操作API要简单一些。
from jira import JIRA from django.conf import settings JIRA_URL = settings.JIRA['URL'] USER = settings.JIRA['USER'] PASSWORD = settings.JIRA['PASSWORD'] jira_client = JIRA(server=JIRA_URL, basic_auth=(USER, PASSWORD)) def search_jira_version(request): # site_id = request.GET.get('site_id') project = jira_client.project('ECO') versions = jira_client.project_versions(project) version_list = [] for v in reversed(versions): tmp_dict = dict() tmp_dict[v.id] = v.name version_list.append(tmp_dict) if len(version_list) > 5: break return JsonResponse({"versions": version_list}) def search_jira_issue(request): # site_id = request.GET.get('site_id') version_name = request.GET.get('version_name') project = jira_client.project('ECO') issue_list = [] jql = "project = {} AND fixVersion = {}".format(project.name, version_name) max_results = 30 try: issues = jira_client.search_issues(jql, maxResults=max_results) for issue in issues: tmp_dict = dict() tmp_dict[issue.id] = str(issue) issue_list.append(tmp_dict) except Exception as e: print(e) return JsonResponse({"issues": issue_list})
前端稍作ajax操作,就可以出来关联菜单选择了。