|
35 | 35 | from common.constants.authentication_type import AuthenticationType |
36 | 36 | from common.db.search import get_dynamics_model, native_search, native_page_search |
37 | 37 | from common.db.sql_execute import select_list |
38 | | -from common.exception.app_exception import AppApiException, NotFound404, AppUnauthorizedFailed |
| 38 | +from common.exception.app_exception import AppApiException, NotFound404, AppUnauthorizedFailed, ChatException |
39 | 39 | from common.field.common import UploadedImageField, UploadedFileField |
40 | 40 | from common.models.db_model_manage import DBModelManage |
41 | 41 | from common.response import result |
@@ -268,7 +268,8 @@ def get_embed(self, with_valid=True, params=None): |
268 | 268 | float_location = application_setting.float_location |
269 | 269 | if application_setting.custom_theme is not None and len( |
270 | 270 | application_setting.custom_theme.get('header_font_color', 'rgb(100, 106, 115)')) > 0: |
271 | | - header_font_color = application_setting.custom_theme.get('header_font_color', 'rgb(100, 106, 115)') |
| 271 | + header_font_color = application_setting.custom_theme.get('header_font_color', |
| 272 | + 'rgb(100, 106, 115)') |
272 | 273 |
|
273 | 274 | is_auth = 'true' if application_access_token is not None and application_access_token.is_active else 'false' |
274 | 275 | t = Template(content) |
@@ -916,6 +917,12 @@ def profile(self, with_valid=True): |
916 | 917 | if application_access_token is None: |
917 | 918 | raise AppUnauthorizedFailed(500, "非法用户") |
918 | 919 | application_setting_model = DBModelManage.get_model('application_setting') |
| 920 | + if application.type == ApplicationTypeChoices.WORK_FLOW: |
| 921 | + work_flow_version = QuerySet(WorkFlowVersion).filter(application_id=application.id).order_by( |
| 922 | + '-create_time')[0:1].first() |
| 923 | + if work_flow_version is not None: |
| 924 | + application.work_flow = work_flow_version.work_flow |
| 925 | + |
919 | 926 | xpack_cache = DBModelManage.get_model('xpack_cache') |
920 | 927 | X_PACK_LICENSE_IS_VALID = False if xpack_cache is None else xpack_cache.get('XPACK_LICENSE_IS_VALID', False) |
921 | 928 | application_setting_dict = {} |
@@ -1150,9 +1157,23 @@ def application_list(self, with_valid=True): |
1150 | 1157 | def get_application(self, app_id, with_valid=True): |
1151 | 1158 | if with_valid: |
1152 | 1159 | self.is_valid(raise_exception=True) |
1153 | | - application = QuerySet(Application).filter(id=self.data.get("application_id")).first() |
1154 | | - return ApplicationSerializer.Operate(data={'user_id': application.user_id, 'application_id': app_id}).one( |
1155 | | - with_valid=True) |
| 1160 | + if with_valid: |
| 1161 | + self.is_valid() |
| 1162 | + embed_application = QuerySet(Application).get(id=app_id) |
| 1163 | + if embed_application.type == ApplicationTypeChoices.WORK_FLOW: |
| 1164 | + work_flow_version = QuerySet(WorkFlowVersion).filter(application_id=embed_application.id).order_by( |
| 1165 | + '-create_time')[0:1].first() |
| 1166 | + if work_flow_version is not None: |
| 1167 | + embed_application.work_flow = work_flow_version.work_flow |
| 1168 | + dataset_list = self.list_dataset(with_valid=False) |
| 1169 | + mapping_dataset_id_list = [adm.dataset_id for adm in |
| 1170 | + QuerySet(ApplicationDatasetMapping).filter(application_id=app_id)] |
| 1171 | + dataset_id_list = [d.get('id') for d in |
| 1172 | + list(filter(lambda row: mapping_dataset_id_list.__contains__(row.get('id')), |
| 1173 | + dataset_list))] |
| 1174 | + self.update_search_node(embed_application.work_flow, [str(dataset.get('id')) for dataset in dataset_list]) |
| 1175 | + return {**ApplicationSerializer.Query.reset_application(ApplicationSerializerModel(embed_application).data), |
| 1176 | + 'dataset_id_list': dataset_id_list} |
1156 | 1177 |
|
1157 | 1178 | class ApplicationKeySerializerModel(serializers.ModelSerializer): |
1158 | 1179 | class Meta: |
|
0 commit comments