Forráskód Böngészése

APP设备删除图标

linhaohong 1 éve
szülő
commit
e01ee14d6f
1 módosított fájl, 16 hozzáadás és 3 törlés
  1. 16 3
      AdminController/DeviceManagementController.py

+ 16 - 3
AdminController/DeviceManagementController.py

@@ -737,9 +737,22 @@ class DeviceManagement(View):
         if not all([app_bundle_id, app_device_type_id]):
             return response.json(444)
         try:
+            # 删除语言表
+            DeviceNameLanguage.objects.filter(app_device_type_id=app_device_type_id).delete()
+            # 删除保存的图片
+            app_device_type = AppDeviceType.objects.filter(id=app_device_type_id).first()
+            if app_device_type:
+                path = app_device_type.icon.split('/')[-1]
+                pathV2 = app_device_type.iconV2.split('/')[-1]
+                s3 = AmazonS3Util(AWS_ACCESS_KEY_ID[1], AWS_SECRET_ACCESS_KEY[1], AWS_SES_ACCESS_REGION)
+                bucket_name = 'ansjerfilemanager'
+                s3.delete_obj(bucket_name, f"app/device_type_images/{path}")
+                s3.delete_obj(bucket_name, f"app/device_type_images/{pathV2}")
+            # 删除多对多关系
             app_bundle_qs = AppBundle.objects.get(id=app_bundle_id)
-            app_device_type_qs = AppDeviceType.objects.filter(id=app_device_type_id)
-            app_bundle_qs.app_device_type.remove(*app_device_type_qs)
+            app_bundle_qs.app_device_type.remove(app_device_type_id)
+            # 删除app类型表
+            AppDeviceType.objects.filter(id=app_device_type_id).delete()
             return response.json(0)
         except Exception as e:
             print(e)
@@ -855,7 +868,7 @@ class DeviceManagement(View):
                     s3 = AmazonS3Util(AWS_ACCESS_KEY_ID[1], AWS_SECRET_ACCESS_KEY[1], AWS_SES_ACCESS_REGION)
                     s3.upload_file_obj(bucket_name, file_key, file,
                                        {'ContentType': file.content_type, 'ACL': 'public-read'})
-                    s3.upload_file_obj(bucket_name, file_v2_key, file,
+                    s3.upload_file_obj(bucket_name, file_v2_key, file_v2,
                                        {'ContentType': file_v2.content_type, 'ACL': 'public-read'})
                     for app_id in app_bundle_id:
                         for k, v in data_name.items():