|
@@ -519,7 +519,8 @@ class DeviceManagement(View):
|
|
|
'type', 'icon', 'app_bundle_id',
|
|
|
'app_device_type__devicenamelanguage__id',
|
|
|
'lang', 'name', 'sort',
|
|
|
- 'app_device_type__app_version_number_id').order_by(
|
|
|
+ 'app_device_type__app_version_number_id',
|
|
|
+ 'app_device_type__config').order_by(
|
|
|
'app_device_type__devicenamelanguage__sort')
|
|
|
if not app_bundle_qs.exists():
|
|
|
return response.json(0)
|
|
@@ -561,6 +562,8 @@ class DeviceManagement(View):
|
|
|
device_name_language_id = request_dict.get('app_device_type__devicenamelanguage__id', None)
|
|
|
sort = request_dict.get('sort', None)
|
|
|
version_number = request_dict.get('version_number', None)
|
|
|
+ config = request_dict.get('config', None)
|
|
|
+
|
|
|
if not all([app_device_type_id, device_name_language_id, model, type, sort, version_number]):
|
|
|
return response.json(444)
|
|
|
|
|
@@ -570,10 +573,16 @@ 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)
|
|
|
+ .update(model=model, type=type, icon=icon_path, app_version_number_id=version_number,
|
|
|
+ config=config)
|
|
|
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)
|
|
@@ -585,7 +594,7 @@ class DeviceManagement(View):
|
|
|
{'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)
|
|
|
+ .update(model=model, type=type, app_version_number_id=version_number, config=config)
|
|
|
DeviceNameLanguage.objects.filter(id__in=list_device_name_language_id).update(sort=sort)
|
|
|
return response.json(0)
|
|
|
except Exception as e:
|
|
@@ -605,15 +614,22 @@ class DeviceManagement(View):
|
|
|
name = request_dict.get('name', None)
|
|
|
sort = request_dict.get('sort', None)
|
|
|
version_number = request_dict.get('version_number', None)
|
|
|
+ config = request_dict.get('config', None)
|
|
|
|
|
|
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)
|
|
|
+ .update(model=model, type=type, icon=icon_path, app_version_number_id=version_number,
|
|
|
+ config=config)
|
|
|
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)
|
|
@@ -710,9 +726,11 @@ class DeviceManagement(View):
|
|
|
# device_name_language表数据
|
|
|
name = request_dict.get('name', None)
|
|
|
sort = request_dict.get('sort', None)
|
|
|
+ config = request_dict.get('config', None)
|
|
|
# 上传图标
|
|
|
file = request.FILES.get('iconFile', None)
|
|
|
-
|
|
|
+ if config:
|
|
|
+ config = json.loads(config)
|
|
|
try:
|
|
|
type = int(type)
|
|
|
data_name = eval(name)
|
|
@@ -760,11 +778,16 @@ class DeviceManagement(View):
|
|
|
app_bundle = AppBundle.objects.filter(id=app_id).values('id', 'app_bundle_id').first()
|
|
|
app_device_type_qs = AppDeviceType.objects.create(model=model, type=type,
|
|
|
icon=response_url,
|
|
|
- app_version_number_id=version_number)
|
|
|
+ app_version_number_id=version_number,
|
|
|
+ config=config)
|
|
|
DeviceNameLanguage.objects.create(lang=k, name=v, sort=sort,
|
|
|
app_device_type_id=app_device_type_qs.id)
|
|
|
app_device_type_qs.appbundle_set.add(app_bundle["id"])
|
|
|
- success_records.append(record_key)
|
|
|
+ success_records.append(
|
|
|
+ {"app_bundle_id": app_bundle["app_bundle_id"], "type": type,
|
|
|
+ "version_number": version_number,
|
|
|
+ "lang": k, "model": model}
|
|
|
+ )
|
|
|
|
|
|
response_data = {
|
|
|
'success_records': success_records,
|
|
@@ -932,6 +955,7 @@ class DeviceManagement(View):
|
|
|
# device_name_language表数据
|
|
|
name = request_dict.get('name', None)
|
|
|
sort = request_dict.get('sort', None)
|
|
|
+ config = request_dict.get('config', None)
|
|
|
# 上传图标
|
|
|
files = request.FILES.get('iconFile', None)
|
|
|
# 需要添加到哪一个服
|
|
@@ -962,8 +986,14 @@ class DeviceManagement(View):
|
|
|
'sort': sort,
|
|
|
'model': model,
|
|
|
'versionNumber': version_number,
|
|
|
- 'appBundleName': app_bundle_name
|
|
|
+ 'appBundleName': app_bundle_name,
|
|
|
}
|
|
|
+ if config:
|
|
|
+ try:
|
|
|
+ config = json.loads(config)
|
|
|
+ except:
|
|
|
+ return response.json(444, 'config必须是一个json数据')
|
|
|
+ form_data["config"] = json.dumps(config)
|
|
|
# 发送 POST 请求调用 add_app_device_type 方法
|
|
|
response_value = requests.post(url + "/deviceManagement/addAppDeviceType",
|
|
|
data=form_data,
|