RateMyCourse/backend/postings/api/serializers.py

36 lines
603 B
Python
Raw Permalink Normal View History

2018-09-16 16:52:23 +00:00
from rest_framework import serializers
from postings.models import *
2018-09-16 16:52:23 +00:00
# Serializes the generic Review object.
class ReviewSerializer(serializers.ModelSerializer):
class Meta:
model = Review
fields = [
'pk',
'rating',
'title',
'content',
'rateable_entity',
'created_date',
'last_updated_date'
]
read_only_fields = [
'pk',
'created_date',
'rateable_entity'
]
2018-10-11 09:18:48 +00:00
class ReviewHelpfulVoteSerializer(serializers.ModelSerializer):
class Meta:
2018-10-11 09:18:48 +00:00
model = ReviewHelpfulVote
fields = [
'pk',
2018-10-11 09:18:48 +00:00
'review',
'helpful',
'user'
]
read_only_fields = [
'pk'
2018-10-11 09:18:48 +00:00
]