6b799f4d by 周伟奇

Merge branch 'fix/1119' into feature/1119

2 parents 59f58c93 657b81ef
...@@ -944,11 +944,17 @@ class CompareResultView(GenericView): ...@@ -944,11 +944,17 @@ class CompareResultView(GenericView):
944 else: 944 else:
945 whole_result = consts.RESULT_Y if result_obj.is_finish else consts.RESULT_N 945 whole_result = consts.RESULT_Y if result_obj.is_finish else consts.RESULT_N
946 946
947 if result_obj is None or result_obj.comments is None: 947 if result_obj is None or not isinstance(result_obj.comments, str):
948 comments = '' 948 comments = ''
949 else: 949 else:
950 comments = result_obj.comments 950 comments = result_obj.comments
951 951
952 if result_obj is None or not isinstance(result_obj.version, str):
953 source = ''
954 version = ''
955 else:
956 source, version = result_obj.version.split(consts.SPLIT_STR)
957
952 compare_result = { 958 compare_result = {
953 'id': 0 if result_obj is None else result_obj.id, 959 'id': 0 if result_obj is None else result_obj.id,
954 'application_id': case_id, 960 'application_id': case_id,
...@@ -956,8 +962,8 @@ class CompareResultView(GenericView): ...@@ -956,8 +962,8 @@ class CompareResultView(GenericView):
956 'scheme': consts.DOC_SCHEME_LIST[0] if scheme == consts.COMPARE_DOC_SCHEME_LIST[0] else consts.DOC_SCHEME_LIST[1], 962 'scheme': consts.DOC_SCHEME_LIST[0] if scheme == consts.COMPARE_DOC_SCHEME_LIST[0] else consts.DOC_SCHEME_LIST[1],
957 'whole_result': whole_result, 963 'whole_result': whole_result,
958 'latest_compared_time': '' if result_obj is None else result_obj.update_time.strftime('%Y-%m-%d %H:%M'), 964 'latest_compared_time': '' if result_obj is None else result_obj.update_time.strftime('%Y-%m-%d %H:%M'),
959 'source': '' if result_obj is None else result_obj.version.split(consts.SPLIT_STR)[0], 965 'source': source,
960 'version': '' if result_obj is None else result_obj.version.split(consts.SPLIT_STR)[1], 966 'version': version,
961 'comments': comments, 967 'comments': comments,
962 'result': [] if result_obj is None else json.loads(result_obj.result) 968 'result': [] if result_obj is None else json.loads(result_obj.result)
963 } 969 }
...@@ -1065,20 +1071,29 @@ class CompareResultView(GenericView): ...@@ -1065,20 +1071,29 @@ class CompareResultView(GenericView):
1065 else: 1071 else:
1066 whole_result = consts.RESULT_Y if result_obj.is_finish else consts.RESULT_N 1072 whole_result = consts.RESULT_Y if result_obj.is_finish else consts.RESULT_N
1067 1073
1068 comments = '' if result_obj.comments is None else result_obj.comments 1074 if isinstance(result_obj.comments, str):
1075 comments = result_obj.comments
1076 else:
1077 comments = ''
1078
1079 if isinstance(result_obj.version, str):
1080 source, version = result_obj.version.split(consts.SPLIT_STR)
1081 else:
1082 source = ''
1083 version = ''
1069 1084
1070 compare_result = { 1085 compare_result = {
1071 'id': 0 if result_obj is None else result_obj.id, 1086 'id': result_obj.id,
1072 'application_id': case_id, 1087 'application_id': case_id,
1073 'entity': entity, 1088 'entity': entity,
1074 'scheme': consts.DOC_SCHEME_LIST[0] if scheme == consts.COMPARE_DOC_SCHEME_LIST[0] else 1089 'scheme': consts.DOC_SCHEME_LIST[0] if scheme == consts.COMPARE_DOC_SCHEME_LIST[0] else
1075 consts.DOC_SCHEME_LIST[1], 1090 consts.DOC_SCHEME_LIST[1],
1076 'whole_result': whole_result, 1091 'whole_result': whole_result,
1077 'latest_compared_time': '' if result_obj is None else result_obj.update_time.strftime('%Y-%m-%d %H:%M'), 1092 'latest_compared_time': result_obj.update_time.strftime('%Y-%m-%d %H:%M'),
1078 'source': '' if result_obj is None else result_obj.version.split(consts.SPLIT_STR)[0], 1093 'source': source,
1079 'version': '' if result_obj is None else result_obj.version.split(consts.SPLIT_STR)[1], 1094 'version': version,
1080 'comments': comments, 1095 'comments': comments,
1081 'result': [] if result_obj is None else json.loads(result_obj.result) 1096 'result': json.loads(result_obj.result)
1082 } 1097 }
1083 1098
1084 return response.need_update(data=compare_result) 1099 return response.need_update(data=compare_result)
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!