From 02ede72ce9ddeb4d7d7241503585bb07fe3e2c50 Mon Sep 17 00:00:00 2001 From: Kyle McFarland Date: Sat, 20 Oct 2018 21:51:14 -0600 Subject: Allow suppliers to have multiple representatives This adds a basic Representative model and allows for editing them in the admin interface both in the Suppliers admin panel for each supplier and in a new Representatives admin panel which allows bulk editing of all representatives. Currently multiple representatives are just listed in the component view as extra rows below the company row but it would probably make sense to add a view for viewing suppliers directly. The REST API has also been slightly modified to return a list of representatives for each supplier in the components endpoint, adding a suppliers endpoint would probably also be a good idea. Requires running: $ python manage.py migrate procurement 0002_add_representative To update the database for the new model, both forward and lossy reverse data migration is implemented in the migration. --- .../templates/procurement/includes/supplier_list.html | 12 +++++++++--- procurement/templates/procurement/source_components.html | 6 +++++- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'procurement/templates') diff --git a/procurement/templates/procurement/includes/supplier_list.html b/procurement/templates/procurement/includes/supplier_list.html index 028e62c..ffd7435 100644 --- a/procurement/templates/procurement/includes/supplier_list.html +++ b/procurement/templates/procurement/includes/supplier_list.html @@ -17,11 +17,17 @@ {% for supplier in supplier_results %} + {% for representative in supplier.representatives.all %} + {% if forloop.first %} {{ supplier.name }} - {{ supplier.representative_name }} - {{ supplier.representative_email }} + {% else %} + + {% endif %} + {{ representative.name }} + {{ representative.email }} + {% endfor %} {% empty %} No authorized suppliers found. @@ -34,4 +40,4 @@ - \ No newline at end of file + diff --git a/procurement/templates/procurement/source_components.html b/procurement/templates/procurement/source_components.html index 3eebf84..db412a2 100644 --- a/procurement/templates/procurement/source_components.html +++ b/procurement/templates/procurement/source_components.html @@ -42,6 +42,10 @@ {{ suppliers_last_updated }} + {{ representative_count }} Representatives + {{ representatives_last_updated }} + + {{ component_count }} Components {{ components_last_updated }} @@ -58,4 +62,4 @@ {% block additional_js %} -{% endblock %} \ No newline at end of file +{% endblock %} -- cgit v1.1