From dbbe38381a051113564001c1d134059f8ab0b5bf Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Sun, 12 Oct 2025 12:12:52 +0800 Subject: [PATCH] fix --- problem/serializers.py | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/problem/serializers.py b/problem/serializers.py index a63520d..964c3b7 100644 --- a/problem/serializers.py +++ b/problem/serializers.py @@ -156,15 +156,6 @@ class ProblemSerializer(BaseProblemSerializer): "answers", ) - def to_representation(self, instance): - data = super().to_representation(instance) - # 如果 allow_flowchart=False,则不返回 flowchart 相关字段 - if not instance.allow_flowchart: - flowchart_fields = ['mermaid_code', 'flowchart_data', 'flowchart_hint', 'show_flowchart'] - for field in flowchart_fields: - data.pop(field, None) - return data - class ProblemListSerializer(BaseProblemSerializer): class Meta: @@ -182,15 +173,6 @@ class ProblemListSerializer(BaseProblemSerializer): "rule_type", ] - def to_representation(self, instance): - data = super().to_representation(instance) - # 如果 allow_flowchart=False,则不返回 flowchart 相关字段 - if not instance.allow_flowchart: - flowchart_fields = ['mermaid_code', 'flowchart_data', 'flowchart_hint', 'show_flowchart'] - for field in flowchart_fields: - data.pop(field, None) - return data - class ProblemSafeSerializer(BaseProblemSerializer): template = serializers.SerializerMethodField("get_public_template") @@ -209,16 +191,6 @@ class ProblemSafeSerializer(BaseProblemSerializer): "answers", ) - def to_representation(self, instance): - data = super().to_representation(instance) - # 如果 allow_flowchart=False,则不返回 flowchart 相关字段 - if not instance.allow_flowchart: - flowchart_fields = ['mermaid_code', 'flowchart_data', 'flowchart_hint', 'show_flowchart'] - for field in flowchart_fields: - data.pop(field, None) - return data - - class ContestProblemMakePublicSerializer(serializers.Serializer): id = serializers.IntegerField() display_id = serializers.CharField(max_length=32)