summaryrefslogtreecommitdiff
path: root/procurement/serializers.py
blob: b3e928081cf08939f73996ff1a0649a365d1e5b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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 SupplierComponentSerializer(serializers.ModelSerializer):
    text = serializers.CharField(source="__str__", read_only=True)
    class Meta:
        model = Component
        exclude = ('created', 'updated')

class SupplierComponentsSerializer(serializers.ModelSerializer):
    components = SupplierComponentSerializer(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')