Эх сурвалжийг харах

优化定制推送,可多选国家和删除任务

locky 1 жил өмнө
parent
commit
bdf6fdd081

+ 17 - 1
AdminController/UserManageController.py

@@ -313,6 +313,8 @@ class UserManagement(View):
                 return self.getCustomizedPushList(request_dict, response)
             elif operation == 'addOrEditCustomizedPush':  # 新增/编辑推送内容
                 return self.addOrEditCustomizedPush(request, request_dict, response)
+            elif operation == 'delCustomizedPush':  # 删除定制推送
+                return self.delCustomizedPush(request_dict, response)
             else:
                 return response.json(414)
 
@@ -1001,7 +1003,7 @@ class UserManagement(View):
                     return response.json(444)
                 customized_push_data['push_satus'] = False
                 CustomizedPush.objects.filter(id=customized_push_id).update(**customized_push_data)
-                apscheduler_obj.del_job('customizedPushId_{}'.format(customized_push_id))  # 删除旧定时任务
+                apscheduler_obj.del_job('customized_push_id_{}'.format(customized_push_id))  # 删除旧定时任务
             else:           # 新增
                 customized_push = CustomizedPush.objects.create(**customized_push_data)
                 customized_push_id = customized_push.id
@@ -1025,6 +1027,20 @@ class UserManagement(View):
         url = DETECT_PUSH_DOMAINS + 'customized_push/start'
         req = requests.post(url=url, data=data, timeout=8)
 
+    @staticmethod
+    def delCustomizedPush(request_dict, response):
+        customized_push_id = request_dict.get('customizedPushId', None)
+        if not customized_push_id:
+            return response.json(444)
+        try:
+            CustomizedPush.objects.filter(id=customized_push_id).delete()
+            # 删除定时任务
+            apscheduler_obj = ApschedulerObject()
+            apscheduler_obj.del_job('customized_push_id_{}'.format(customized_push_id))
+            return response.json(0)
+        except Exception as e:
+            return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
+
     @staticmethod
     def getCountryList(response):
         try:

+ 2 - 2
Model/models.py

@@ -4070,8 +4070,8 @@ class CustomizedPush(models.Model):
     msg = models.TextField(default='', verbose_name='内容')
     link = models.TextField(default='', verbose_name='链接')
     icon_link = models.TextField(default='', verbose_name='预览图链接')
-    country = models.CharField(default='', max_length=32, verbose_name='国家')
-    # 多选型号用,分开
+    # 多选国家,设备型号,用逗号分开
+    country = models.CharField(default='', max_length=320, verbose_name='国家')
     device_type = models.TextField(default='', verbose_name='设备类型')
     register_period = models.CharField(default='', max_length=32, verbose_name='注册年限')
     time_zone = models.CharField(default='', max_length=8, verbose_name='时区')