|
@@ -573,16 +573,19 @@ class DeviceManagement(View):
|
|
|
|
|
|
try:
|
|
|
with transaction.atomic():
|
|
|
- if config:
|
|
|
- try:
|
|
|
- config = json.loads(config)
|
|
|
- except:
|
|
|
- return response.json(444, 'config必须是一个json数据')
|
|
|
if icon:
|
|
|
icon_path = 'https://ansjerfilemanager.s3.amazonaws.com/app/device_type_images/{}'.format(icon)
|
|
|
- AppDeviceType.objects.filter(id__in=list_app_device_type_id) \
|
|
|
- .update(model=model, type=type, icon=icon_path, app_version_number_id=version_number,
|
|
|
- config=config)
|
|
|
+ if config:
|
|
|
+ try:
|
|
|
+ config = json.loads(config)
|
|
|
+ except:
|
|
|
+ return response.json(444, 'config必须是一个json数据')
|
|
|
+ AppDeviceType.objects.filter(id__in=list_app_device_type_id) \
|
|
|
+ .update(model=model, type=type, icon=icon_path, app_version_number_id=version_number,
|
|
|
+ config=config)
|
|
|
+ else:
|
|
|
+ AppDeviceType.objects.filter(id__in=list_app_device_type_id) \
|
|
|
+ .update(model=model, type=type, icon=icon_path, app_version_number_id=version_number)
|
|
|
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)
|
|
@@ -593,8 +596,17 @@ class DeviceManagement(View):
|
|
|
icon,
|
|
|
{'ContentType': icon.content_type, 'ACL': 'public-read'})
|
|
|
else:
|
|
|
- AppDeviceType.objects.filter(id__in=list_app_device_type_id) \
|
|
|
- .update(model=model, type=type, app_version_number_id=version_number, config=config)
|
|
|
+ if config:
|
|
|
+ try:
|
|
|
+ config = json.loads(config)
|
|
|
+ except:
|
|
|
+ return response.json(444, 'config必须是一个json数据')
|
|
|
+ AppDeviceType.objects.filter(id__in=list_app_device_type_id) \
|
|
|
+ .update(model=model, type=type, app_version_number_id=version_number,
|
|
|
+ config=config)
|
|
|
+ else:
|
|
|
+ AppDeviceType.objects.filter(id__in=list_app_device_type_id) \
|
|
|
+ .update(model=model, type=type, app_version_number_id=version_number)
|
|
|
DeviceNameLanguage.objects.filter(id__in=list_device_name_language_id).update(sort=sort)
|
|
|
return response.json(0)
|
|
|
except Exception as e:
|
|
@@ -619,17 +631,20 @@ class DeviceManagement(View):
|
|
|
if not all([app_device_type_id, model, type, device_name_language_id, lang, name, sort]):
|
|
|
return response.json(444)
|
|
|
try:
|
|
|
- if config:
|
|
|
- try:
|
|
|
- config = json.loads(config)
|
|
|
- except:
|
|
|
- return response.json(444, 'config必须是一个json数据')
|
|
|
with transaction.atomic():
|
|
|
if icon:
|
|
|
icon_path = 'https://ansjerfilemanager.s3.amazonaws.com/app/device_type_images/{}'.format(icon)
|
|
|
- AppDeviceType.objects.filter(id=app_device_type_id) \
|
|
|
- .update(model=model, type=type, icon=icon_path, app_version_number_id=version_number,
|
|
|
- config=config)
|
|
|
+ if config:
|
|
|
+ try:
|
|
|
+ config = json.loads(config)
|
|
|
+ except:
|
|
|
+ return response.json(444, 'config必须是一个json数据')
|
|
|
+ AppDeviceType.objects.filter(id=app_device_type_id) \
|
|
|
+ .update(model=model, type=type, icon=icon_path, 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, app_version_number_id=version_number)
|
|
|
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)
|
|
@@ -640,8 +655,17 @@ class DeviceManagement(View):
|
|
|
icon,
|
|
|
{'ContentType': icon.content_type, 'ACL': 'public-read'})
|
|
|
else:
|
|
|
- AppDeviceType.objects.filter(id=app_device_type_id) \
|
|
|
- .update(model=model, type=type, app_version_number_id=version_number)
|
|
|
+ if config:
|
|
|
+ try:
|
|
|
+ config = json.loads(config)
|
|
|
+ except:
|
|
|
+ return response.json(444, 'config必须是一个json数据')
|
|
|
+ AppDeviceType.objects.filter(id=app_device_type_id) \
|
|
|
+ .update(model=model, type=type, app_version_number_id=version_number,
|
|
|
+ config=config)
|
|
|
+ else:
|
|
|
+ AppDeviceType.objects.filter(id=app_device_type_id) \
|
|
|
+ .update(model=model, type=type, app_version_number_id=version_number)
|
|
|
DeviceNameLanguage.objects.filter(id=device_name_language_id).update(lang=lang, name=name, sort=sort)
|
|
|
return response.json(0)
|
|
|
except Exception as e:
|