summaryrefslogtreecommitdiff
path: root/procurement/serializers.py
blob: 046640249b94f1081379cb438c5aa837d74788f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from rest_framework import serializers
from procurement.models import Component, Supplier, Representative

class RepresentativeSerializer(serializers.ModelSerializer):
    class Meta:
        model = Representative
        exclude = ('created', 'updated', 'supplier', 'id')

class SupplierSerializer(serializers.ModelSerializer):
    representatives = RepresentativeSerializer(many=True, read_only=True)

    class Meta:
        model = Supplier
        exclude = ('created', 'updated')


class ComponentSerializer(serializers.ModelSerializer):
    text = serializers.CharField(source='__str__', read_only=True)
    suppliers = SupplierSerializer(many=True, read_only=True)

    class Meta:
        model = Component
        exclude = ('created', 'updated')