mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-27 16:07:02 -05:00
feat: Add blog, media, and support apps, implement ride credits and image API, and remove toplist feature.
This commit is contained in:
29
backend/apps/reviews/serializers.py
Normal file
29
backend/apps/reviews/serializers.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from rest_framework import serializers
|
||||
from .models import Review
|
||||
from apps.accounts.serializers import UserSerializer
|
||||
|
||||
class ReviewSerializer(serializers.ModelSerializer):
|
||||
user = UserSerializer(read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = Review
|
||||
fields = [
|
||||
"id",
|
||||
"user",
|
||||
"content_type",
|
||||
"object_id",
|
||||
"rating",
|
||||
"text",
|
||||
"is_public",
|
||||
"helpful_votes",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
]
|
||||
read_only_fields = ["id", "user", "helpful_votes", "created_at", "updated_at"]
|
||||
|
||||
def validate(self, data):
|
||||
"""
|
||||
Check that rating is between 1 and 5.
|
||||
"""
|
||||
# Rating is already validated by model field validation but explicit check is good
|
||||
return data
|
||||
Reference in New Issue
Block a user