Explorar o código

后台APP设备编辑修改

linhaohong hai 1 ano
pai
achega
fa9888def4
Modificáronse 1 ficheiros con 7 adicións e 6 borrados
  1. 7 6
      AdminController/DeviceManagementController.py

+ 7 - 6
AdminController/DeviceManagementController.py

@@ -607,10 +607,11 @@ class DeviceManagement(View):
         try:
             with transaction.atomic():
                 if icon or iconV2:
+                    app_device_type = AppDeviceType.objects.filter(id=app_device_type_id).first()
                     bucket_name = 'ansjerfilemanager'
                     s3 = AmazonS3Util(AWS_ACCESS_KEY_ID[1], AWS_SECRET_ACCESS_KEY[1], AWS_SES_ACCESS_REGION)
-                    icon_path = ""
-                    icon_v2_path = ""
+                    icon_path = app_device_type.icon
+                    icon_v2_path = app_device_type.iconV2
                     if icon:
                         icon_path = f'https://ansjerfilemanager.s3.amazonaws.com/app/device_type_images/{now_time}_{icon.name}'
                         file_key = f'app/device_type_images/{now_time}_{icon.name}'
@@ -678,11 +679,12 @@ class DeviceManagement(View):
             return response.json(444)
         try:
             with transaction.atomic():
+                app_device_type = AppDeviceType.objects.filter(id=app_device_type_id).first()
                 if icon or iconV2:
                     bucket_name = 'ansjerfilemanager'
                     s3 = AmazonS3Util(AWS_ACCESS_KEY_ID[1], AWS_SECRET_ACCESS_KEY[1], AWS_SES_ACCESS_REGION)
-                    icon_path = ""
-                    icon_v2_path = ""
+                    icon_path = app_device_type.icon
+                    icon_v2_path = app_device_type.iconV2
                     if icon:
                         icon_path = f'https://ansjerfilemanager.s3.amazonaws.com/app/device_type_images/{now_time}_{icon.name}'
                         file_key = f'app/device_type_images/{now_time}_{icon.name}'
@@ -706,8 +708,7 @@ class DeviceManagement(View):
                             return response.json(444, 'config必须是一个json数据')
                         AppDeviceType.objects.filter(id=app_device_type_id) \
                             .update(model=model, type=type, icon=icon_path, iconV2=icon_v2_path,
-                                    app_version_number_id=version_number,
-                                    config=config)
+                                    app_version_number_id=version_number, config=config)
                     else:
                         AppDeviceType.objects.filter(id=app_device_type_id) \
                             .update(model=model, type=type, icon=icon_path, iconV2=icon_v2_path,