|
@@ -77,7 +77,7 @@ class DeviceManagement(View):
|
|
|
elif operation == 'getAppBundleIdList': # 获取app包id数据
|
|
|
return self.get_app_bundle_id_list(response)
|
|
|
elif operation == 'editAppDeviceType': # 编辑app设备类型数据
|
|
|
- return self.edit_app_device_type(request_dict, response)
|
|
|
+ return self.edit_app_device_type(request_dict, request, response)
|
|
|
elif operation == 'deleteAppDeviceType': # 删除app设备类型数据
|
|
|
return self.delete_app_device_type(request_dict, response)
|
|
|
elif operation == 'getAppBundle': # 获取app版本包
|
|
@@ -528,12 +528,12 @@ class DeviceManagement(View):
|
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
|
|
@staticmethod
|
|
|
- def edit_app_device_type(request_dict, response):
|
|
|
+ def edit_app_device_type(request_dict, request, response):
|
|
|
# app_device_type表数据
|
|
|
app_device_type_id = request_dict.get('app_device_type__id', None)
|
|
|
model = request_dict.get('model', None)
|
|
|
type = request_dict.get('type', None)
|
|
|
- icon = request_dict.get('icon', None)
|
|
|
+ icon = request.FILES.get('icon', None)
|
|
|
# device_name_language表数据
|
|
|
device_name_language_id = request_dict.get('app_device_type__devicenamelanguage__id', None)
|
|
|
lang = request_dict.get('lang', None)
|
|
@@ -542,11 +542,20 @@ class DeviceManagement(View):
|
|
|
|
|
|
if not all([app_device_type_id, model, type, icon, device_name_language_id, lang, name, sort]):
|
|
|
return response.json(444)
|
|
|
-
|
|
|
+ icon_path = 'https://ansjerfilemanager.s3.amazonaws.com/app/device_type_images/{}'.format(icon)
|
|
|
try:
|
|
|
with transaction.atomic():
|
|
|
- AppDeviceType.objects.filter(id=app_device_type_id).update(model=model, type=type, icon=icon)
|
|
|
+ AppDeviceType.objects.filter(id=app_device_type_id).update(model=model, type=type, icon=icon_path)
|
|
|
DeviceNameLanguage.objects.filter(id=device_name_language_id).update(lang=lang, name=name, sort=sort)
|
|
|
+ bucket_name = 'ansjerfilemanager'
|
|
|
+ file_key = 'app/device_type_images/{}'.format(icon)
|
|
|
+ s3 = AmazonS3Util(AWS_ACCESS_KEY_ID[1], AWS_SECRET_ACCESS_KEY[1], AWS_SES_ACCESS_REGION)
|
|
|
+ # 地址:https://ansjerfilemanager.s3.amazonaws.com/app/device_type_images/camera_c190.png
|
|
|
+ s3.upload_file_obj(
|
|
|
+ bucket_name,
|
|
|
+ file_key,
|
|
|
+ icon,
|
|
|
+ {'ContentType': icon.content_type, 'ACL': 'public-read'})
|
|
|
return response.json(0)
|
|
|
except Exception as e:
|
|
|
print(e)
|