feat: 增加change_data字段
This commit is contained in:
parent
4ac5d1f1f7
commit
da3b0f62e5
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.2.12 on 2024-08-28 08:51
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('enm', '0043_xscript'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='xscript',
|
||||
name='change_data',
|
||||
field=models.JSONField(blank=True, default=dict, null=True, verbose_name='变更数据'),
|
||||
),
|
||||
]
|
|
@ -8,6 +8,7 @@ class Xscript(BaseModel):
|
|||
name = models.CharField("脚本名称", max_length=50)
|
||||
code = models.TextField("脚本内容", null=True, blank=True)
|
||||
base_data = models.JSONField("基础数据", default=dict, null=True, blank=True)
|
||||
change_data = models.JSONField("变更数据", default=dict, null=True, blank=True)
|
||||
myschedule = models.ForeignKey('system.myschedule', verbose_name='周期', on_delete=models.SET_NULL, null=True, blank=True)
|
||||
periodictask = models.ForeignKey(PeriodicTask, verbose_name='关联定时任务', on_delete=models.CASCADE, related_name='xscript_periodictask', null=True, blank=True)
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ class XscriptSerializer(CustomModelSerializer):
|
|||
class Meta:
|
||||
model = Xscript
|
||||
fields = "__all__"
|
||||
read_only_fields = EXCLUDE_FIELDS_BASE + ['periodictask']
|
||||
read_only_fields = EXCLUDE_FIELDS_BASE + ['periodictask', 'change_data']
|
||||
|
||||
def validate(self, attrs):
|
||||
code = attrs['code']
|
||||
|
|
|
@ -92,6 +92,16 @@ class XscriptViewSet(CustomModelViewSet):
|
|||
periodictask.save()
|
||||
return Response()
|
||||
|
||||
@action(methods=['put'], detail=True, perms_map={'put': 'xscript.update'})
|
||||
def change_data(self, request, pk=None):
|
||||
"""修改变动数据
|
||||
|
||||
修改变动数据
|
||||
"""
|
||||
obj: Xscript = self.get_object()
|
||||
obj.change_data = request.data.get('change_data', {})
|
||||
return Response()
|
||||
|
||||
@transaction.atomic
|
||||
def perform_destroy(self, instance):
|
||||
periodictask = instance.periodictask
|
||||
|
|
Loading…
Reference in New Issue