Skip to content

Commit

Permalink
articles: adds 'created' to legacy serializer
Browse files Browse the repository at this point in the history
Signed-off-by: pamfilos <[email protected]>
  • Loading branch information
pamfilos committed Sep 19, 2024
1 parent d6929c1 commit bae0bd6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion scoap3/articles/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ def to_representation(self, instance):
class LegacyArticleSerializer(serializers.ModelSerializer):
metadata = serializers.SerializerMethodField()
updated = serializers.SerializerMethodField()
created = serializers.SerializerMethodField()
id = serializers.SerializerMethodField()

class Meta:
model = Article
fields = ["id", "metadata", "updated"]
fields = ["id", "metadata", "updated", "created"]

def get_id(self, obj):
return obj.id
Expand Down Expand Up @@ -168,6 +169,9 @@ def get_metadata(self, obj):
def get_updated(self, obj):
return obj._updated_at

def get_created(self, obj):
return obj._created_at


class ArticleDocumentSerializer(DocumentSerializer):
class Meta:
Expand Down
1 change: 1 addition & 0 deletions scoap3/articles/tests/test_record_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def test_get_record_json_structure(self, client, license, user):
assert "id" in data["results"][0]
assert "metadata" in data["results"][0]
assert "updated" in data["results"][0]
assert "created" in data["results"][0]

metadata = data["results"][0]["metadata"]
assert "control_number" in metadata
Expand Down

0 comments on commit bae0bd6

Please sign in to comment.