backend/api/serializers.py
2022-10-31 09:20:43 +01:00

71 lines
2.0 KiB
Python
Executable File

from django.contrib.auth import get_user_model
from rest_framework import serializers
from photo_log.models import (
PhotoGroup,
Photo,
PhotoLog,
PhotoTag,
PhotoLogTemplate,
)
class PhotoTagSerializer(serializers.ModelSerializer):
class Meta:
model = PhotoTag
fields = ('id', 'name', 'color')
class PhotoLogTemplateSerializer(serializers.ModelSerializer):
class Meta:
model = PhotoLogTemplate
fields = ('id', 'title', 'date', 'render_date', 'start_slide_image', 'slides',)
class PhotoGroupSerializer(serializers.ModelSerializer):
class Meta:
model = PhotoGroup
fields = ('id', 'name', 'date', 'parent')
class PhotosSerializer(serializers.ModelSerializer):
class Meta:
model = Photo
fields = ('id', 'legacy_id', 'group')
class PhotoSerializer(serializers.ModelSerializer):
tag = PhotoTagSerializer()
class Meta:
model = Photo
fields = ('id', 'owner', 'legacy_id', 'group', 'bbox_coords', 'rotate', 'intersections', 'original_image', 'cropped_image', 'ocr_text', 'tag')
class AddPhotoSerializer(serializers.ModelSerializer):
class Meta:
model = Photo
fields = ('id', 'legacy_id', 'group', 'bbox_coords', 'rotate', 'intersections', 'original_image', 'cropped_image', 'ocr_text', 'tag')
class PhotoUpdateSerializer(serializers.ModelSerializer):
class Meta:
model = Photo
fields = ('id', 'legacy_id', 'group', 'bbox_coords', 'rotate', 'ocr_text', 'tag')
class PhotoLogSerializer(serializers.ModelSerializer):
class Meta:
model = PhotoLog
fields = ('id', 'title', 'date', 'render_date', 'start_slide_image', 'slides', 'pdf')
class PhotoLogsSerializer(serializers.ModelSerializer):
class Meta:
model = PhotoLog
fields = ('id', 'title', 'date', 'pdf')
class UserSerializer(serializers.ModelSerializer):
class Meta:
model = get_user_model()
fields = ('id', 'email')