Show More
@@ -60,64 +60,72 b' class JiraClient(object):' | |||||
60 | projects = self.client.projects() |
|
60 | projects = self.client.projects() | |
61 | return projects |
|
61 | return projects | |
62 |
|
62 | |||
63 | def get_assignees(self): |
|
63 | def get_assignees(self, request): | |
64 | """Gets list of possible assignees""" |
|
64 | """Gets list of possible assignees""" | |
65 | users = self.client.search_assignable_users_for_issues( |
|
65 | cache_region = request.registry.cache_regions.redis_sec_30 | |
66 | None, project=self.project) |
|
66 | @cache_region.cache_on_arguments('JiraClient.get_assignees') | |
67 | results = [] |
|
|||
68 | for user in users: |
|
|||
69 | results.append({"id": user.name, "name": user.displayName}) |
|
|||
70 | return results |
|
|||
71 |
|
||||
72 | def get_metadata(self): |
|
|||
73 | def cached(project_name): |
|
67 | def cached(project_name): | |
74 | metadata = self.client.createmeta( |
|
68 | users = self.client.search_assignable_users_for_issues( | |
75 |
project |
|
69 | None, project=project_name) | |
76 | assignees = self.get_assignees() |
|
70 | results = [] | |
77 | parsed_metadata = [] |
|
71 | for user in users: | |
78 | for entry in metadata['projects'][0]['issuetypes']: |
|
72 | results.append({"id": user.name, "name": user.displayName}) | |
79 | issue = {"name": entry['name'], |
|
73 | return results | |
80 | "id": entry['id'], |
|
74 | return cached(self.project) | |
81 | "fields": []} |
|
|||
82 | for i_id, field_i in entry['fields'].items(): |
|
|||
83 | field = { |
|
|||
84 | "name": field_i['name'], |
|
|||
85 | "id": i_id, |
|
|||
86 | "required": field_i['required'], |
|
|||
87 | "values": [], |
|
|||
88 | "type": field_i['schema'].get('type') |
|
|||
89 | } |
|
|||
90 | if field_i.get('allowedValues'): |
|
|||
91 | field['values'] = [] |
|
|||
92 | for i in field_i['allowedValues']: |
|
|||
93 | field['values'].append( |
|
|||
94 | {'id': i['id'], |
|
|||
95 | 'name': i.get('name', i.get('value', '')) |
|
|||
96 | }) |
|
|||
97 | if field['id'] == 'assignee': |
|
|||
98 | field['values'] = assignees |
|
|||
99 |
|
75 | |||
100 | issue['fields'].append(field) |
|
76 | def get_issue_types(self, request): | |
101 | parsed_metadata.append(issue) |
|
77 | metadata = self.get_metadata(request) | |
102 | return parsed_metadata |
|
78 | assignees = self.get_assignees(request) | |
|
79 | parsed_metadata = [] | |||
|
80 | for entry in metadata['projects'][0]['issuetypes']: | |||
|
81 | issue = {"name": entry['name'], | |||
|
82 | "id": entry['id'], | |||
|
83 | "fields": []} | |||
|
84 | for i_id, field_i in entry['fields'].items(): | |||
|
85 | field = { | |||
|
86 | "name": field_i['name'], | |||
|
87 | "id": i_id, | |||
|
88 | "required": field_i['required'], | |||
|
89 | "values": [], | |||
|
90 | "type": field_i['schema'].get('type') | |||
|
91 | } | |||
|
92 | if field_i.get('allowedValues'): | |||
|
93 | field['values'] = [] | |||
|
94 | for i in field_i['allowedValues']: | |||
|
95 | field['values'].append( | |||
|
96 | {'id': i['id'], | |||
|
97 | 'name': i.get('name', i.get('value', '')) | |||
|
98 | }) | |||
|
99 | if field['id'] == 'assignee': | |||
|
100 | field['values'] = assignees | |||
|
101 | issue['fields'].append(field) | |||
|
102 | parsed_metadata.append(issue) | |||
|
103 | return parsed_metadata | |||
103 |
|
104 | |||
|
105 | def get_metadata(self, request): | |||
|
106 | # cache_region = request.registry.cache_regions.redis_sec_30 | |||
|
107 | # @cache_region.cache_on_arguments('JiraClient.get_metadata') | |||
|
108 | def cached(project_name): | |||
|
109 | return self.client.createmeta( | |||
|
110 | projectKeys=project_name, expand='projects.issuetypes.fields') | |||
104 | return cached(self.project) |
|
111 | return cached(self.project) | |
105 |
|
112 | |||
106 | def create_issue(self, form_data): |
|
113 | def create_issue(self, form_data, request): | |
107 | metadata = self.get_metadata() |
|
114 | issue_types = self.get_issue_types(request) | |
108 | payload = { |
|
115 | payload = { | |
109 | 'project': {'key': form_data['project']}, |
|
116 | 'project': {'key': form_data['project']}, | |
110 | 'summary': form_data['title'], |
|
117 | 'summary': form_data['title'], | |
111 | 'description': form_data['content'], |
|
118 | 'description': form_data['content'], | |
112 |
'issuetype': {'id': ' |
|
119 | 'issuetype': {'id': form_data['issue_type']}, | |
113 | "priority": {'id': form_data['priority']}, |
|
120 | "priority": {'id': form_data['priority']}, | |
114 | "assignee": {'name': form_data['responsible']}, |
|
121 | "assignee": {'name': form_data['responsible']}, | |
115 | } |
|
122 | } | |
116 |
for issue_type in |
|
123 | for issue_type in issue_types: | |
117 |
if issue_type['id'] == ' |
|
124 | if issue_type['id'] == form_data['issue_type']: | |
118 | for field in issue_type['fields']: |
|
125 | for field in issue_type['fields']: | |
|
126 | # set some defaults for other required fields | |||
119 | if field == 'reporter': |
|
127 | if field == 'reporter': | |
120 |
payload["reporter"] = {'id': self.user_name} |
|
128 | payload["reporter"] = {'id': self.user_name} | |
121 | if field['required'] and field['id'] not in payload: |
|
129 | if field['required'] and field['id'] not in payload: | |
122 | if field['type'] == 'array': |
|
130 | if field['type'] == 'array': | |
123 | payload[field['id']] = [field['values'][0], ] |
|
131 | payload[field['id']] = [field['values'][0], ] |
@@ -4613,6 +4613,11 b' function kickstartAE() {' | |||||
4613 | " <div class=\"col-sm-8 col-lg-9\">\n" + |
|
4613 | " <div class=\"col-sm-8 col-lg-9\">\n" + | |
4614 | " <data-form-errors errors=\"integration.integrationForm.ae_validation.host_name\"></data-form-errors>\n" + |
|
4614 | " <data-form-errors errors=\"integration.integrationForm.ae_validation.host_name\"></data-form-errors>\n" + | |
4615 | " <input class=\"form-control\" id=\"host_name\" name=\"host_name\" type=\"text\" ng-model=\"integration.config.host_name\">\n" + |
|
4615 | " <input class=\"form-control\" id=\"host_name\" name=\"host_name\" type=\"text\" ng-model=\"integration.config.host_name\">\n" + | |
|
4616 | "\n" + | |||
|
4617 | " <p>\n" + | |||
|
4618 | " <small>https://servername.atlassian.net</small>\n" + | |||
|
4619 | " </p>\n" + | |||
|
4620 | "\n" + | |||
4616 | " </div>\n" + |
|
4621 | " </div>\n" + | |
4617 | " </div>\n" + |
|
4622 | " </div>\n" + | |
4618 | " <div class=\"form-group\" id=\"row-user_name\">\n" + |
|
4623 | " <div class=\"form-group\" id=\"row-user_name\">\n" + | |
@@ -4624,6 +4629,11 b' function kickstartAE() {' | |||||
4624 | "\n" + |
|
4629 | "\n" + | |
4625 | " <data-form-errors errors=\"integration.integrationForm.ae_validation.user_name\"></data-form-errors>\n" + |
|
4630 | " <data-form-errors errors=\"integration.integrationForm.ae_validation.user_name\"></data-form-errors>\n" + | |
4626 | " <input class=\"form-control\" id=\"user_name\" name=\"user_name\" type=\"text\" ng-model=\"integration.config.user_name\">\n" + |
|
4631 | " <input class=\"form-control\" id=\"user_name\" name=\"user_name\" type=\"text\" ng-model=\"integration.config.user_name\">\n" + | |
|
4632 | "\n" + | |||
|
4633 | " <p>\n" + | |||
|
4634 | " <small>user@email.com</small>\n" + | |||
|
4635 | " </p>\n" + | |||
|
4636 | "\n" + | |||
4627 | " </div>\n" + |
|
4637 | " </div>\n" + | |
4628 | " </div>\n" + |
|
4638 | " </div>\n" + | |
4629 | " <div class=\"form-group\" id=\"row-password\">\n" + |
|
4639 | " <div class=\"form-group\" id=\"row-password\">\n" + | |
@@ -5609,6 +5619,11 b' function kickstartAE() {' | |||||
5609 | " <label for=\"issue_title\">Issue Title</label>\n" + |
|
5619 | " <label for=\"issue_title\">Issue Title</label>\n" + | |
5610 | " <input type=\"text\" class=\"form-control\" id=\"issue_title\" placeholder=\"Issue title\" ng-model=\"ctrl.form.title\">\n" + |
|
5620 | " <input type=\"text\" class=\"form-control\" id=\"issue_title\" placeholder=\"Issue title\" ng-model=\"ctrl.form.title\">\n" + | |
5611 | " </div>\n" + |
|
5621 | " </div>\n" + | |
|
5622 | "\n" + | |||
|
5623 | " <div class=\"form-group\">\n" + | |||
|
5624 | " <label for=\"issue_type\">Issue Type</label>\n" + | |||
|
5625 | " <select class=\"form-control\" id=\"issue_type\" ng-options=\"i.name for i in ctrl.issue_types\" ng-model=\"ctrl.form.issue_type\"></select>\n" + | |||
|
5626 | " </div>\n" + | |||
5612 | " <div class=\"form-group row\">\n" + |
|
5627 | " <div class=\"form-group row\">\n" + | |
5613 | " <div class=\"col-sm-6\">\n" + |
|
5628 | " <div class=\"col-sm-6\">\n" + | |
5614 | " <label for=\"issue_priority\">Priority</label>\n" + |
|
5629 | " <label for=\"issue_priority\">Priority</label>\n" + | |
@@ -9091,6 +9106,7 b' function JiraIntegrationCtrl($uibModalInstance, $state, report, integrationName,' | |||||
9091 | vm.integrationName = integrationName; |
|
9106 | vm.integrationName = integrationName; | |
9092 | vm.statuses = []; |
|
9107 | vm.statuses = []; | |
9093 | vm.priorities = []; |
|
9108 | vm.priorities = []; | |
|
9109 | vm.issue_types = []; | |||
9094 | vm.error_messages = []; |
|
9110 | vm.error_messages = []; | |
9095 | vm.form = { |
|
9111 | vm.form = { | |
9096 | content: '\n' + |
|
9112 | content: '\n' + | |
@@ -9111,6 +9127,8 b' function JiraIntegrationCtrl($uibModalInstance, $state, report, integrationName,' | |||||
9111 | } |
|
9127 | } | |
9112 | vm.assignees = data.assignees; |
|
9128 | vm.assignees = data.assignees; | |
9113 | vm.priorities = data.priorities; |
|
9129 | vm.priorities = data.priorities; | |
|
9130 | vm.issue_types = data.issue_types; | |||
|
9131 | vm.form.issue_type = vm.issue_types[0]; | |||
9114 | vm.form.responsible = vm.assignees[0]; |
|
9132 | vm.form.responsible = vm.assignees[0]; | |
9115 | vm.form.priority = vm.priorities[0]; |
|
9133 | vm.form.priority = vm.priorities[0]; | |
9116 | }, function (error_data) { |
|
9134 | }, function (error_data) { |
@@ -86,7 +86,7 b' class BitbucketView(IntegrationView):' | |||||
86 | return {'error_messages': [str(e)]} |
|
86 | return {'error_messages': [str(e)]} | |
87 |
|
87 | |||
88 | comment_body = 'Bitbucket issue created: %s ' % issue['web_url'] |
|
88 | comment_body = 'Bitbucket issue created: %s ' % issue['web_url'] | |
89 |
comment = ReportComment( |
|
89 | comment = ReportComment(owner_id=self.request.user.id, | |
90 | report_time=report.first_timestamp, |
|
90 | report_time=report.first_timestamp, | |
91 | body=comment_body) |
|
91 | body=comment_body) | |
92 | report.comments.append(comment) |
|
92 | report.comments.append(comment) |
@@ -88,7 +88,7 b' class GithubView(IntegrationView):' | |||||
88 | return {'error_messages': [str(e)]} |
|
88 | return {'error_messages': [str(e)]} | |
89 |
|
89 | |||
90 | comment_body = 'Github issue created: %s ' % issue['web_url'] |
|
90 | comment_body = 'Github issue created: %s ' % issue['web_url'] | |
91 |
comment = ReportComment( |
|
91 | comment = ReportComment(owner_id=self.request.user.id, | |
92 | report_time=report.first_timestamp, |
|
92 | report_time=report.first_timestamp, | |
93 | body=comment_body) |
|
93 | body=comment_body) | |
94 | report.comments.append(comment) |
|
94 | report.comments.append(comment) |
@@ -68,15 +68,19 b' class JiraView(IntegrationView):' | |||||
68 | return {'error_messages': [str(e)]} |
|
68 | return {'error_messages': [str(e)]} | |
69 | assignees = [] |
|
69 | assignees = [] | |
70 | priorities = [] |
|
70 | priorities = [] | |
71 | metadata = client.get_metadata() |
|
71 | issue_types = [] | |
72 | for issue_type in metadata: |
|
72 | possible_issue_types = client.get_issue_types(self.request) | |
|
73 | for issue_type in possible_issue_types: | |||
73 | for field in issue_type['fields']: |
|
74 | for field in issue_type['fields']: | |
74 | if field['id'] == 'assignee': |
|
75 | if field['id'] == 'assignee': | |
75 | assignees = field['values'] |
|
76 | assignees = field['values'] | |
76 | if field['id'] == 'priority': |
|
77 | if field['id'] == 'priority': | |
77 | priorities = field['values'] |
|
78 | priorities = field['values'] | |
|
79 | issue_types.append({'name':issue_type['name'], | |||
|
80 | 'id':issue_type['id']}) | |||
78 | return {'assignees': assignees, |
|
81 | return {'assignees': assignees, | |
79 |
'priorities': priorities |
|
82 | 'priorities': priorities, | |
|
83 | 'issue_types': issue_types} | |||
80 |
|
84 | |||
81 | @view_config(route_name='integrations_id', |
|
85 | @view_config(route_name='integrations_id', | |
82 | match_param=['action=create-issue', |
|
86 | match_param=['action=create-issue', | |
@@ -92,20 +96,20 b' class JiraView(IntegrationView):' | |||||
92 | 'title': self.request.unsafe_json_body.get('title', |
|
96 | 'title': self.request.unsafe_json_body.get('title', | |
93 | 'Unknown Title'), |
|
97 | 'Unknown Title'), | |
94 | 'content': self.request.unsafe_json_body.get('content', ''), |
|
98 | 'content': self.request.unsafe_json_body.get('content', ''), | |
95 | 'kind': 'bug', |
|
99 | 'issue_type': self.request.unsafe_json_body['issue_type']['id'], | |
96 | 'priority': self.request.unsafe_json_body['priority']['id'], |
|
100 | 'priority': self.request.unsafe_json_body['priority']['id'], | |
97 | 'responsible': self.request.unsafe_json_body['responsible']['id'], |
|
101 | 'responsible': self.request.unsafe_json_body['responsible']['id'], | |
98 | 'project': self.integration.config['project'] |
|
102 | 'project': self.integration.config['project'] | |
99 | } |
|
103 | } | |
100 | try: |
|
104 | try: | |
101 | client = self.create_client() |
|
105 | client = self.create_client() | |
102 | issue = client.create_issue(form_data) |
|
106 | issue = client.create_issue(form_data, request=self.request) | |
103 | except IntegrationException as e: |
|
107 | except IntegrationException as e: | |
104 | self.request.response.status_code = 503 |
|
108 | self.request.response.status_code = 503 | |
105 | return {'error_messages': [str(e)]} |
|
109 | return {'error_messages': [str(e)]} | |
106 |
|
110 | |||
107 | comment_body = 'Jira issue created: %s ' % issue['web_url'] |
|
111 | comment_body = 'Jira issue created: %s ' % issue['web_url'] | |
108 |
comment = ReportComment( |
|
112 | comment = ReportComment(owner_id=self.request.user.id, | |
109 | report_time=report.first_timestamp, |
|
113 | report_time=report.first_timestamp, | |
110 | body=comment_body) |
|
114 | body=comment_body) | |
111 | report.comments.append(comment) |
|
115 | report.comments.append(comment) |
@@ -30,6 +30,7 b' function JiraIntegrationCtrl($uibModalInstance, $state, report, integrationName,' | |||||
30 | vm.integrationName = integrationName; |
|
30 | vm.integrationName = integrationName; | |
31 | vm.statuses = []; |
|
31 | vm.statuses = []; | |
32 | vm.priorities = []; |
|
32 | vm.priorities = []; | |
|
33 | vm.issue_types = []; | |||
33 | vm.error_messages = []; |
|
34 | vm.error_messages = []; | |
34 | vm.form = { |
|
35 | vm.form = { | |
35 | content: '\n' + |
|
36 | content: '\n' + | |
@@ -50,6 +51,8 b' function JiraIntegrationCtrl($uibModalInstance, $state, report, integrationName,' | |||||
50 | } |
|
51 | } | |
51 | vm.assignees = data.assignees; |
|
52 | vm.assignees = data.assignees; | |
52 | vm.priorities = data.priorities; |
|
53 | vm.priorities = data.priorities; | |
|
54 | vm.issue_types = data.issue_types; | |||
|
55 | vm.form.issue_type = vm.issue_types[0]; | |||
53 | vm.form.responsible = vm.assignees[0]; |
|
56 | vm.form.responsible = vm.assignees[0]; | |
54 | vm.form.priority = vm.priorities[0]; |
|
57 | vm.form.priority = vm.priorities[0]; | |
55 | }, function (error_data) { |
|
58 | }, function (error_data) { |
@@ -16,6 +16,11 b'' | |||||
16 | <div class="col-sm-8 col-lg-9"> |
|
16 | <div class="col-sm-8 col-lg-9"> | |
17 | <data-form-errors errors="integration.integrationForm.ae_validation.host_name"></data-form-errors> |
|
17 | <data-form-errors errors="integration.integrationForm.ae_validation.host_name"></data-form-errors> | |
18 | <input class="form-control" id="host_name" name="host_name" type="text" ng-model="integration.config.host_name"> |
|
18 | <input class="form-control" id="host_name" name="host_name" type="text" ng-model="integration.config.host_name"> | |
|
19 | ||||
|
20 | <p> | |||
|
21 | <small>https://servername.atlassian.net</small> | |||
|
22 | </p> | |||
|
23 | ||||
19 | </div> |
|
24 | </div> | |
20 | </div> |
|
25 | </div> | |
21 | <div class="form-group" id="row-user_name"> |
|
26 | <div class="form-group" id="row-user_name"> | |
@@ -27,6 +32,11 b'' | |||||
27 |
|
32 | |||
28 | <data-form-errors errors="integration.integrationForm.ae_validation.user_name"></data-form-errors> |
|
33 | <data-form-errors errors="integration.integrationForm.ae_validation.user_name"></data-form-errors> | |
29 | <input class="form-control" id="user_name" name="user_name" type="text" ng-model="integration.config.user_name"> |
|
34 | <input class="form-control" id="user_name" name="user_name" type="text" ng-model="integration.config.user_name"> | |
|
35 | ||||
|
36 | <p> | |||
|
37 | <small>user@email.com</small> | |||
|
38 | </p> | |||
|
39 | ||||
30 | </div> |
|
40 | </div> | |
31 | </div> |
|
41 | </div> | |
32 | <div class="form-group" id="row-password"> |
|
42 | <div class="form-group" id="row-password"> |
@@ -12,6 +12,11 b'' | |||||
12 | <label for="issue_title">Issue Title</label> |
|
12 | <label for="issue_title">Issue Title</label> | |
13 | <input type="text" class="form-control" id="issue_title" placeholder="Issue title" ng-model="ctrl.form.title"> |
|
13 | <input type="text" class="form-control" id="issue_title" placeholder="Issue title" ng-model="ctrl.form.title"> | |
14 | </div> |
|
14 | </div> | |
|
15 | ||||
|
16 | <div class="form-group"> | |||
|
17 | <label for="issue_type">Issue Type</label> | |||
|
18 | <select class="form-control" id="issue_type" ng-options="i.name for i in ctrl.issue_types" ng-model="ctrl.form.issue_type"></select> | |||
|
19 | </div> | |||
15 | <div class="form-group row"> |
|
20 | <div class="form-group row"> | |
16 | <div class="col-sm-6"> |
|
21 | <div class="col-sm-6"> | |
17 | <label for="issue_priority">Priority</label> |
|
22 | <label for="issue_priority">Priority</label> |
General Comments 0
You need to be logged in to leave comments.
Login now