Skip to content

Commit 2be1927

Browse files
authored
Merge pull request #7969 from guohelu/feat_return_notify
feat: 模板接口返回新增通知信息 --story=126257473
2 parents 953fc36 + 010d6be commit 2be1927

File tree

5 files changed

+36
-7
lines changed

5 files changed

+36
-7
lines changed

gcloud/apigw/views/get_common_template_info.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
def get_common_template_info(request, template_id):
3434
include_subprocess = request.GET.get("include_subprocess", None)
3535
include_constants = request.GET.get("include_constants", None)
36+
include_notify = request.GET.get("include_notify", None)
3637
try:
3738
tmpl = CommonTemplate.objects.select_related("pipeline_template").get(id=template_id, is_deleted=False)
3839
except CommonTemplate.DoesNotExist:
@@ -42,7 +43,7 @@ def get_common_template_info(request, template_id):
4243
"code": err_code.CONTENT_NOT_EXIST.code,
4344
}
4445
return result
45-
data = format_template_data(template=tmpl, include_subprocess=include_subprocess)
46+
data = format_template_data(template=tmpl, include_subprocess=include_subprocess, include_notify=include_notify)
4647
if include_constants:
4748
data["template_constants"] = process_pipeline_constants(data["pipeline_tree"])
4849

gcloud/apigw/views/get_common_template_list.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,16 @@
2929
@mark_request_whether_is_trust
3030
@timezone_inject
3131
def get_common_template_list(request):
32+
include_notify = request.GET.get("include_notify", None)
3233
templates = CommonTemplate.objects.select_related("pipeline_template").filter(is_deleted=False)
33-
templates_data, common_templates_id_list = format_template_list_data(templates, return_id_list=True, tz=request.tz)
34+
templates_data, common_templates_id_list = format_template_list_data(
35+
templates, return_id_list=True, tz=request.tz, include_notify=include_notify
36+
)
3437
# 注入用户有权限的actions
3538
common_templates_allowed_actions = get_common_flow_allowed_actions_for_user(
36-
request.user.username, COMMON_FLOW_ACTIONS, common_templates_id_list,
39+
request.user.username,
40+
COMMON_FLOW_ACTIONS,
41+
common_templates_id_list,
3742
)
3843
for template in templates_data:
3944
template_id = template["id"]

gcloud/apigw/views/get_template_info.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def get_template_info(request, template_id, project_id):
4141
include_subprocess = request.GET.get("include_subprocess", None)
4242
include_constants = request.GET.get("include_constants", None)
4343
include_executor_proxy = request.GET.get("include_executor_proxy", None)
44+
include_notify = request.GET.get("include_notify", None)
4445
if template_source in NON_COMMON_TEMPLATE_TYPES:
4546
try:
4647
tmpl = TaskTemplate.objects.select_related("pipeline_template").get(
@@ -69,7 +70,9 @@ def get_template_info(request, template_id, project_id):
6970
}
7071
return result
7172

72-
data = format_template_data(tmpl, project, include_subprocess, include_executor_proxy=include_executor_proxy)
73+
data = format_template_data(
74+
tmpl, project, include_subprocess, include_executor_proxy=include_executor_proxy, include_notify=include_notify
75+
)
7376
if include_constants:
7477
data["template_constants"] = process_pipeline_constants(data["pipeline_tree"])
7578

gcloud/apigw/views/get_template_list.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def get_template_list(request, project_id):
4343
name_keyword = request.GET.get("name_keyword", None)
4444
include_labels = request.GET.get("include_labels", None)
4545
include_executor_proxy = request.GET.get("include_executor_proxy", None)
46+
include_notify = request.GET.get("include_notify", None)
4647

4748
if id_in:
4849
try:
@@ -65,7 +66,12 @@ def get_template_list(request, project_id):
6566
templates = CommonTemplate.objects.select_related("pipeline_template").filter(**filter_kwargs)
6667

6768
template_list, template_id_list = format_template_list_data(
68-
templates, project, return_id_list=True, tz=request.tz, include_executor_proxy=include_executor_proxy
69+
templates,
70+
project,
71+
return_id_list=True,
72+
tz=request.tz,
73+
include_executor_proxy=include_executor_proxy,
74+
include_notify=include_notify,
6975
)
7076
template_labels = {}
7177
if include_labels:

gcloud/apigw/views/utils.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
specific language governing permissions and limitations under the License.
1212
"""
1313

14+
import json
1415
import logging
1516
import traceback
1617
from copy import deepcopy
@@ -53,7 +54,9 @@ def info_data_from_period_task(task, detail=True, tz=None, include_edit_info=Non
5354
return info
5455

5556

56-
def format_template_data(template, project=None, include_subprocess=None, tz=None, include_executor_proxy=None):
57+
def format_template_data(
58+
template, project=None, include_subprocess=None, tz=None, include_executor_proxy=None, include_notify=None
59+
):
5760
pipeline_tree = template.pipeline_tree
5861
pipeline_tree.pop("line")
5962
pipeline_tree.pop("location")
@@ -80,6 +83,10 @@ def format_template_data(template, project=None, include_subprocess=None, tz=Non
8083
)
8184
if include_executor_proxy and hasattr(template, "executor_proxy"):
8285
data.update({"executor_proxy": template.executor_proxy})
86+
if include_notify:
87+
data.update(
88+
{"notify_type": json.loads(template.notify_type), "notify_receivers": json.loads(template.notify_receivers)}
89+
)
8390

8491
if include_subprocess:
8592
data.update(
@@ -92,7 +99,9 @@ def format_template_data(template, project=None, include_subprocess=None, tz=Non
9299
return data
93100

94101

95-
def format_template_list_data(templates, project=None, return_id_list=False, tz=None, include_executor_proxy=None):
102+
def format_template_list_data(
103+
templates, project=None, return_id_list=False, tz=None, include_executor_proxy=None, include_notify=None
104+
):
96105
data = []
97106
ids = []
98107
for tmpl in templates:
@@ -119,6 +128,11 @@ def format_template_list_data(templates, project=None, return_id_list=False, tz=
119128
if return_id_list:
120129
ids.append(item["id"])
121130

131+
if include_notify:
132+
item.update(
133+
{"notify_type": json.loads(tmpl.notify_type), "notify_receivers": json.loads(tmpl.notify_receivers)}
134+
)
135+
122136
if include_executor_proxy and hasattr(tmpl, "executor_proxy"):
123137
item.update({"executor_proxy": tmpl.executor_proxy})
124138

0 commit comments

Comments
 (0)