功能变化:

修改系统配置后,进行WS通知
pull/93/head
猿小天 2023-04-08 22:21:34 +08:00
parent 2cccc87ee4
commit d13533a203
2 changed files with 11 additions and 0 deletions

View File

@ -397,12 +397,20 @@ class SystemConfig(CoreModel):
return f"{self.title}"
def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
# from application.websocketConfig import websocket_push
# websocket_push("dvadmin", message={"sender": 'system', "contentType": 'SYSTEM',
# "content": '系统配置有变化~', "systemConfig": True})
super().save(force_insert, force_update, using, update_fields)
dispatch.refresh_system_config() # 有更新则刷新系统配置
def delete(self, using=None, keep_parents=False):
res = super().delete(using, keep_parents)
dispatch.refresh_system_config()
from application.websocketConfig import websocket_push
websocket_push("dvadmin", message={"sender": 'system', "contentType": 'SYSTEM',
"content": '系统配置有变化~', "systemConfig": True})
return res

View File

@ -13,6 +13,7 @@ from rest_framework import serializers
from rest_framework.views import APIView
from application import dispatch
from application.websocketConfig import websocket_push
from dvadmin.system.models import SystemConfig
from dvadmin.utils.json_response import DetailResponse, SuccessResponse, ErrorResponse
from dvadmin.utils.models import get_all_models_objects
@ -179,6 +180,8 @@ class SystemConfigViewSet(CustomModelViewSet):
serializer = SystemConfigCreateSerializer(instance_obj, data=data)
if serializer.is_valid(raise_exception=True):
serializer.save()
websocket_push("dvadmin", message={"sender": 'system', "contentType": 'SYSTEM',
"content": '系统配置有变化~', "systemConfig": True})
return DetailResponse(msg="保存成功")
def get_association_table(self, request):