From 246539088950e256d5fa498cdfd251a826e5dcb6 Mon Sep 17 00:00:00 2001 From: FreneticScribbler Date: Tue, 31 Dec 2019 19:17:58 +0000 Subject: [PATCH] FEAT: Add associated assets to supplier detail view --- assets/models.py | 8 +++ assets/templates/supplier_detail.html | 73 +++++++++++++++++++++++++-- 2 files changed, 78 insertions(+), 3 deletions(-) diff --git a/assets/models.py b/assets/models.py index 2398a563..fcf93207 100644 --- a/assets/models.py +++ b/assets/models.py @@ -51,6 +51,14 @@ class Supplier(models.Model, RevisionMixin): def __str__(self): return self.name + @property + def assets(self): + p = [] + for e in Asset.objects.filter(purchased_from=self): + p.append(e) + + return p + class Connector(models.Model): description = models.CharField(max_length=80) diff --git a/assets/templates/supplier_detail.html b/assets/templates/supplier_detail.html index 7639cf6b..ddbb7817 100644 --- a/assets/templates/supplier_detail.html +++ b/assets/templates/supplier_detail.html @@ -1,6 +1,73 @@ {% extends 'base_assets.html' %} -{% block title %}Detail{% endblock %} +{% block title %}Supplier | {{ object.name }}{% endblock %} {% block content %} -{{ object }} -{% endblock %} \ No newline at end of file +
+ {% if not request.is_ajax %} +
+

Supplier | {{ object.name }}

+
+ +
+
+ Edit +
+
+ {% endif %} +
+
+
Supplier Details
+
+
+
Name
+
{{ object.name }}
+
+
+
+
+
+ +
+
+
+
Associated Assets
+
+ + + + + + + + + + + + {% with object.assets as object_list %} + {% include 'partials/asset_list_table_body.html' %} + {% endwith %} + +
Asset IDDescriptionCategoryStatus
+
+
+
+
+ + + {% if not request.is_ajax %} +
+ +
+ {% endif %} +{% endblock %}