From 2eb825b0e6697cd8bb50eb9a77e09a8dfbdd7a9b Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 4 May 2019 00:02:53 +1000 Subject: [PATCH 1/2] Improved table rendering --- .../company/templates/company/detail_part.html | 1 + InvenTree/company/templates/company/index.html | 1 + InvenTree/part/templates/part/supplier.html | 1 + InvenTree/part/templates/part/used_in.html | 13 +------------ InvenTree/static/script/inventree/bom.js | 1 + InvenTree/templates/InvenTree/search.html | 1 + 6 files changed, 6 insertions(+), 12 deletions(-) diff --git a/InvenTree/company/templates/company/detail_part.html b/InvenTree/company/templates/company/detail_part.html index 1db55c12d5..797446472f 100644 --- a/InvenTree/company/templates/company/detail_part.html +++ b/InvenTree/company/templates/company/detail_part.html @@ -39,6 +39,7 @@ $("#part-table").bootstrapTable({ sortable: true, search: true, + formatNoMatches: function() { return "No supplier parts found for {{ company.name }}"; }, queryParams: function(p) { return { supplier: {{ company.id }} diff --git a/InvenTree/company/templates/company/index.html b/InvenTree/company/templates/company/index.html index a9cb7e2700..7cfd7d18de 100644 --- a/InvenTree/company/templates/company/index.html +++ b/InvenTree/company/templates/company/index.html @@ -31,6 +31,7 @@ sortable: true, search: true, pagination: true, + formatNoMatches: function() { return "No company information found"; }, columns: [ { field: 'pk', diff --git a/InvenTree/part/templates/part/supplier.html b/InvenTree/part/templates/part/supplier.html index fba1ec38db..0f417eb650 100644 --- a/InvenTree/part/templates/part/supplier.html +++ b/InvenTree/part/templates/part/supplier.html @@ -40,6 +40,7 @@ $("#supplier-table").bootstrapTable({ sortable: true, search: true, + formatNoMatches: function() { return "No supplier parts available for {{ part.name }}"; }, queryParams: function(p) { return { part: {{ part.id }} diff --git a/InvenTree/part/templates/part/used_in.html b/InvenTree/part/templates/part/used_in.html index bce5dfcffa..118f335468 100644 --- a/InvenTree/part/templates/part/used_in.html +++ b/InvenTree/part/templates/part/used_in.html @@ -6,21 +6,9 @@

Used In

-{% if part.used_in_count > 0 %} - -

- {{ part.name }} is used to make {{ part.used_in_count }} other parts. -

-
-{% else %} -

- {{ part.name }} is not used to make any other parts. -

-{% endif %} - {% endblock %} {% block js_ready %} @@ -29,6 +17,7 @@ $("#used-table").bootstrapTable({ sortable: true, search: true, + formatNoMatches: function() { return "{{ part.name }} is not used to make any other parts"; }, queryParams: function(p) { return { sub_part: {{ part.id }} diff --git a/InvenTree/static/script/inventree/bom.js b/InvenTree/static/script/inventree/bom.js index 1b58b81a93..777acbd4ef 100644 --- a/InvenTree/static/script/inventree/bom.js +++ b/InvenTree/static/script/inventree/bom.js @@ -164,6 +164,7 @@ function loadBomTable(table, options) { table.bootstrapTable({ sortable: true, search: true, + formatNoMatches: function() { return "No BOM items found"; }, clickToSelect: true, queryParams: function(p) { return { diff --git a/InvenTree/templates/InvenTree/search.html b/InvenTree/templates/InvenTree/search.html index ceb79cc5a3..a3e709870f 100644 --- a/InvenTree/templates/InvenTree/search.html +++ b/InvenTree/templates/InvenTree/search.html @@ -27,6 +27,7 @@ sortable: true, search: true, pagination: true, + formatNoMatches: function() { return "No parts found matching search query"; }, queryParams: function(p) { return { search: "{{ query }}", From 4af59f0ca98bbdcf39fa6600d4f218eaf170a25d Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 4 May 2019 00:37:08 +1000 Subject: [PATCH 2/2] Fixed part image upload - Image was being saved twice - Don't call super().post in AjaxUpdateView - Instead, handle properly --- InvenTree/InvenTree/views.py | 9 ++++----- InvenTree/part/models.py | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/InvenTree/InvenTree/views.py b/InvenTree/InvenTree/views.py index 9a388c5b2c..711a4f685c 100644 --- a/InvenTree/InvenTree/views.py +++ b/InvenTree/InvenTree/views.py @@ -201,10 +201,8 @@ class AjaxUpdateView(AjaxMixin, UpdateView): """ super(UpdateView, self).get(request, *args, **kwargs) - - form = self.get_form() - return self.renderJsonResponse(request, form, context=self.get_context_data()) + return self.renderJsonResponse(request, self.get_form(), context=self.get_context_data()) def post(self, request, *args, **kwargs): """ Respond to POST request. @@ -215,7 +213,8 @@ class AjaxUpdateView(AjaxMixin, UpdateView): - Otherwise, return sucess status """ - super(UpdateView, self).post(request, *args, **kwargs) + # Make sure we have an object to point to + self.object = self.get_object() form = self.get_form() @@ -225,7 +224,7 @@ class AjaxUpdateView(AjaxMixin, UpdateView): if form.is_valid(): obj = form.save() - + # Include context data about the updated object data['pk'] = obj.id diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 7bce91c26c..9f5d9f0e29 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -115,10 +115,10 @@ class Part(models.Model): return reverse('part-detail', kwargs={'pk': self.id}) # Short name of the part - name = models.CharField(max_length=100, unique=True, help_text='Part name (must be unique)') + name = models.CharField(max_length=100, unique=True, blank=False, help_text='Part name (must be unique)') # Longer description of the part (optional) - description = models.CharField(max_length=250, help_text='Part description') + description = models.CharField(max_length=250, blank=False, help_text='Part description') # Internal Part Number (optional) # Potentially multiple parts map to the same internal IPN (variants?)