From 377985be10cb959fa975e9cddc5161d346f3d2c6 Mon Sep 17 00:00:00 2001 From: Kyle McFarland Date: Sun, 21 Oct 2018 19:26:32 -0600 Subject: Add view suppliers view and suppliers API endpoint This adds a simple view (mostly cribbed from the component view but without the database stats) to view details for a given supplier, currently lists the components they supply and name/email address pairs for representatives however there's room to add fields for other representative contact and company information as well. On the API side this adds 3 endpoints: * api/suppliers: returns a list of all suppliers and their representatives * api/suppliers/: returns a supplier object containing the representatives for the given supplier * api/suppliers//components: returns a supplier object containing a list of components supplied by the given supplier This also contains minor documentation and base template changes, fixing the navigation menu to use class="active" on the currently selected page (previously didn't work due to page_name capitalization) --- procurement/serializers.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'procurement/serializers.py') diff --git a/procurement/serializers.py b/procurement/serializers.py index 0466402..b3e9280 100644 --- a/procurement/serializers.py +++ b/procurement/serializers.py @@ -13,6 +13,17 @@ class SupplierSerializer(serializers.ModelSerializer): 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) -- cgit v1.1