reimbursinator/back/backend/serializers.py

67 lines
1.4 KiB
Python
Raw Normal View History

# Rupika Dikkala
# January 23, 2019
# File contains serializers needed
# to set up API end points
2019-01-23 07:11:41 +00:00
from rest_framework import serializers
from . import models
# serializer for reports
class ReportSerializer(serializers.ModelSerializer):
2019-01-24 02:18:19 +00:00
# user id is foreign key
user_id = serializers.PrimaryKeyRelatedField(many=False, read_only=True)
class Meta:
2019-01-24 02:18:19 +00:00
fields = (
'user_id',
'title',
'date_created',
# 'data_submitted',
'submitted',
)
2019-01-25 20:45:34 +00:00
model = models.Report
2019-01-23 07:11:41 +00:00
# section serializer
class SectionSerializer(serializers.ModelSerializer):
# report id foriegn key
report_id = serializers.PrimaryKeyRelatedField(many=True, read_only=True)
2019-01-23 07:11:41 +00:00
class Meta:
fields = (
'report_id',
'completed',
2019-01-23 07:11:41 +00:00
'title',
'html_description',
'number',
)
model = models.Section
class FieldSerializer(serializers.ModelSerializer):
# section_id is foriegn key
section_id = serializers.PrimaryKeyRelatedField(many=True, read_only=True)
class Meta:
fields = (
'section_id',
'label',
'number',
'type',
'completed',
2019-01-23 07:11:41 +00:00
)
model = models.Field
class DataSerializer(serializers.ModelSerializer):
field_id = serializers.PrimaryKeyRelatedField(many=False, read_only=True)
2019-01-23 07:11:41 +00:00