Skip to content

Commit

Permalink
added excluded field to the serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
bishwaspraveen committed Feb 14, 2024
1 parent aca9a0a commit cbfbb0d
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions sde_collections/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@


class CollectionSerializer(serializers.ModelSerializer):
curation_status_display = serializers.CharField(
source="get_curation_status_display", read_only=True
)
workflow_status_display = serializers.CharField(
source="get_workflow_status_display", read_only=True
)
curation_status_display = serializers.CharField(source="get_curation_status_display", read_only=True)
workflow_status_display = serializers.CharField(source="get_workflow_status_display", read_only=True)

class Meta:
model = Collection
Expand All @@ -44,9 +40,7 @@ class Meta:

class CandidateURLSerializer(serializers.ModelSerializer):
excluded = serializers.BooleanField(required=False)
document_type_display = serializers.CharField(
source="get_document_type_display", read_only=True
)
document_type_display = serializers.CharField(source="get_document_type_display", read_only=True)
url = serializers.CharField(required=False)
generated_title_id = serializers.SerializerMethodField(read_only=True)
match_pattern_type = serializers.SerializerMethodField(read_only=True)
Expand Down Expand Up @@ -95,10 +89,9 @@ class Meta:


class CandidateURLAPISerializer(serializers.ModelSerializer):
document_type = serializers.CharField(
source="get_document_type_display", read_only=True
)
document_type = serializers.CharField(source="get_document_type_display", read_only=True)
title = serializers.CharField(source="scraped_title")
excluded = serializers.SerializerMethodField()

class Meta:
model = CandidateURL
Expand All @@ -107,13 +100,15 @@ class Meta:
"title",
"document_type",
"hash",
"excluded",
)

def get_excluded(self, obj):
return getattr(obj, "excluded", False)


class BasePatternSerializer(serializers.ModelSerializer):
match_pattern_type_display = serializers.CharField(
source="get_match_pattern_type_display", read_only=True
)
match_pattern_type_display = serializers.CharField(source="get_match_pattern_type_display", read_only=True)
candidate_urls_count = serializers.SerializerMethodField(read_only=True)

def get_candidate_urls_count(self, instance):
Expand Down Expand Up @@ -161,9 +156,7 @@ def validate_match_pattern(self, value):


class DocumentTypePatternSerializer(BasePatternSerializer, serializers.ModelSerializer):
document_type_display = serializers.CharField(
source="get_document_type_display", read_only=True
)
document_type_display = serializers.CharField(source="get_document_type_display", read_only=True)
document_type = serializers.ChoiceField(
choices=DocumentTypes.choices
+ [
Expand Down

0 comments on commit cbfbb0d

Please sign in to comment.