fix
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user