|
@@ -149,25 +149,34 @@ class EquipmentInfo(View):
|
|
|
|
|
|
|
|
|
|
def update_info(self, request_dict, userID, response):
|
|
def update_info(self, request_dict, userID, response):
|
|
- id_list = request_dict.getlist('id[]', None)
|
|
|
|
- if id_list is None or len(id_list) < 1:
|
|
|
|
- id_list = request_dict.getlist('id', None)
|
|
|
|
- param_flag = CommonService.get_param_flag(data=[id_list])
|
|
|
|
- if param_flag is True:
|
|
|
|
- count = 0
|
|
|
|
- for id in id_list:
|
|
|
|
- try:
|
|
|
|
- eq = Equipment_Info.objects.filter(id=int(id))
|
|
|
|
- if eq.exists():
|
|
|
|
- own_dev = ModelService.check_own_device(userID, eq[0].devUid)
|
|
|
|
- if own_dev is True:
|
|
|
|
- count += 1
|
|
|
|
- eq.update(status=1)
|
|
|
|
- except Exception as e:
|
|
|
|
- print(repr(e))
|
|
|
|
- return response.json(0, {'update_success': count})
|
|
|
|
|
|
+ id_all = request_dict.getlist('all', None)
|
|
|
|
+ if id_all == 1:
|
|
|
|
+ try:
|
|
|
|
+ eq = Equipment_Info.objects.filter(userID=userID)
|
|
|
|
+ eq.update(status=1)
|
|
|
|
+ except Exception as e:
|
|
|
|
+ print(repr(e))
|
|
|
|
+ return response.json(0, {'update_success': 'all'})
|
|
else:
|
|
else:
|
|
- return response.json(444)
|
|
|
|
|
|
+ id_list = request_dict.getlist('id[]', None)
|
|
|
|
+ if id_list is None or len(id_list) < 1:
|
|
|
|
+ id_list = request_dict.getlist('id', None)
|
|
|
|
+ param_flag = CommonService.get_param_flag(data=[id_list])
|
|
|
|
+ if param_flag is True:
|
|
|
|
+ count = 0
|
|
|
|
+ for id in id_list:
|
|
|
|
+ try:
|
|
|
|
+ eq = Equipment_Info.objects.filter(id=int(id))
|
|
|
|
+ if eq.exists():
|
|
|
|
+ own_dev = ModelService.check_own_device(userID, eq[0].devUid)
|
|
|
|
+ if own_dev is True:
|
|
|
|
+ count += 1
|
|
|
|
+ eq.update(status=1)
|
|
|
|
+ except Exception as e:
|
|
|
|
+ print(repr(e))
|
|
|
|
+ return response.json(0, {'update_success': count})
|
|
|
|
+ else:
|
|
|
|
+ return response.json(444)
|
|
|
|
|
|
def delete_info(self, request_dict, userID, response):
|
|
def delete_info(self, request_dict, userID, response):
|
|
id_list = request_dict.getlist('id[]', None)
|
|
id_list = request_dict.getlist('id[]', None)
|