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) --- .../templates/procurement/documentation.html | 7 ++- .../procurement/includes/supplier_details.html | 51 ++++++++++++++++++++++ .../templates/procurement/view_suppliers.html | 35 +++++++++++++++ 3 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 procurement/templates/procurement/includes/supplier_details.html create mode 100644 procurement/templates/procurement/view_suppliers.html (limited to 'procurement/templates') diff --git a/procurement/templates/procurement/documentation.html b/procurement/templates/procurement/documentation.html index 4775890..f482a1d 100644 --- a/procurement/templates/procurement/documentation.html +++ b/procurement/templates/procurement/documentation.html @@ -55,7 +55,9 @@

Components and their approved Suppliers can be located under source components. From this page you may search for a - component, and then click the Find Suppliers button to display its Suppliers + component, and then click the Find Suppliers button to display its Suppliers. + You can also view details for any authorized Supplier in the system directly under + view suppliers.

API

@@ -63,6 +65,7 @@ A simple REST api is integrated into the system, using the Django Rest Framework. It provides a means of querying all components or, by providing an id in the url, a specific component. + You may also use the API to query all authorized suppliers, a specific supplier by providing an id, or the components a specific supplier provides.

@@ -73,4 +76,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/procurement/templates/procurement/includes/supplier_details.html b/procurement/templates/procurement/includes/supplier_details.html new file mode 100644 index 0000000..0e46c67 --- /dev/null +++ b/procurement/templates/procurement/includes/supplier_details.html @@ -0,0 +1,51 @@ + +
+
+ Supplier information for {{ supplier.name }} +
+ +
+
+ + + + + + + + + {% for representative in supplier.representatives.all %} + + + + + {% empty %} + + + + {% endfor %} + +
RepresentativeEmail
{{ representative.name }}{{ representative.email }}
{{ supplier_name }} has no representatives
+
+ +
+ +
+ + +
+
+ Components Supplied by {{ supplier.name }} +
+
+
+
+ {% csrf_token %} + {{ component_form }} +
+
+ +
+
+
+
diff --git a/procurement/templates/procurement/view_suppliers.html b/procurement/templates/procurement/view_suppliers.html new file mode 100644 index 0000000..918ce62 --- /dev/null +++ b/procurement/templates/procurement/view_suppliers.html @@ -0,0 +1,35 @@ +{% extends "base.html" %} +{% load static %} + +{% block additional_css %} + + +{% endblock %} + +{% block main_content_area %} +
+
+
+
+
+ {% csrf_token %} + {{ form }} +
+
+ +
+
+
+ +
+ + {% if supplier != None %} + {% include 'procurement/includes/supplier_details.html' %} + {% endif %} +
+{% endblock %} + +{% block additional_js %} + + +{% endblock %} -- cgit v1.1