Skip to content

Commit

Permalink
fix: 修复继承问题 --story=120737215
Browse files Browse the repository at this point in the history
  • Loading branch information
guohelu committed Nov 27, 2024
1 parent 61a60d7 commit bc34603
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions gcloud/core/apis/drf/serilaziers/periodic_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def check_cron_params(cron, project):


class CronFieldSerializer(serializers.Serializer):
cron = serializers.DictField(write_only=True, help_text="周期", required=False)
cron = serializers.DictField(write_only=True)

def inspect_cron(self, cron):
minute = cron.get("minute", "*")
Expand Down Expand Up @@ -214,7 +214,7 @@ def validate_project(self, value):
def validate(self, attrs):
check_cron_params(attrs.get("cron"), attrs.get("project"))
if settings.PERIODIC_TASK_SHORTEST_TIME and not self.context["request"].user.is_superuser:
super().inspect_cron(attrs.get("cron"))
self.inspect_cron(attrs.get("cron"))
return attrs

class Meta:
Expand All @@ -223,12 +223,13 @@ class Meta:


class PatchUpdatePeriodicTaskSerializer(CronFieldSerializer, serializers.Serializer):
cron = serializers.DictField(help_text="周期", required=False)
project = serializers.IntegerField(help_text="项目ID", required=False)
constants = serializers.DictField(help_text="执行参数", required=False)
name = serializers.CharField(help_text="任务名", required=False)

def validate(self, attrs):
check_cron_params(attrs.get("cron"), attrs.get("project"))
if settings.PERIODIC_TASK_SHORTEST_TIME and not self.context["request"].user.is_superuser:
super().inspect_cron(attrs.get("cron"))
self.inspect_cron(attrs.get("cron"))
return attrs

0 comments on commit bc34603

Please sign in to comment.