From 56b287b2c81e41b446866b525c72a478988c98f6 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Wed, 4 Nov 2020 08:29:09 +1100 Subject: [PATCH 1/4] Logic fix for editing stock item creation form --- InvenTree/stock/views.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/InvenTree/stock/views.py b/InvenTree/stock/views.py index 2e45ceb00e..1d58647d5a 100644 --- a/InvenTree/stock/views.py +++ b/InvenTree/stock/views.py @@ -1505,8 +1505,10 @@ class StockItemCreate(AjaxCreateView): # form.fields['part'].widget = HiddenInput() # Trackable parts get special consideration: - form.fields['delete_on_deplete'].disabled = not part.trackable - form.fields['serial_numbers'].disabled = not part.trackable + if part.trackable: + form.fields['delete_on_deplete'].disabled = True + else: + form.fields['serial_numbers'].disabled = True # If the part is NOT purchaseable, hide the supplier_part field if not part.purchaseable: From f8da15287c165f80a34d938ac6ae05201ca2caf7 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Wed, 4 Nov 2020 09:35:43 +1100 Subject: [PATCH 2/4] Updated to latest version of coverage and coveralls --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 6e634328ae..f68f354b47 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,8 +18,8 @@ django-import-export==2.0.0 # Data import / export for admin interface django-cleanup==4.0.0 # Manage deletion of old / unused uploaded files django-qr-code==1.2.0 # Generate QR codes flake8==3.8.3 # PEP checking -coverage==5.2.1 # Unit test coverage -python-coveralls==2.9.1 # Coveralls linking (for Travis) +coverage==5.3 # Unit test coverage +python-coveralls==2.9.3 # Coveralls linking (for Travis) rapidfuzz==0.7.6 # Fuzzy string matching django-stdimage==5.1.1 # Advanced ImageField management django-tex==1.1.7 # LaTeX PDF export From 5f6f722d6c21df8d49cd944f1ec41422329e3301 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Wed, 4 Nov 2020 13:30:17 +1100 Subject: [PATCH 3/4] Change from python-coveralls to coveralls --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index f68f354b47..5d2917b57d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -19,7 +19,7 @@ django-cleanup==4.0.0 # Manage deletion of old / unused uploaded files django-qr-code==1.2.0 # Generate QR codes flake8==3.8.3 # PEP checking coverage==5.3 # Unit test coverage -python-coveralls==2.9.3 # Coveralls linking (for Travis) +coveralls==2.1.2 # Coveralls linking (for Travis) rapidfuzz==0.7.6 # Fuzzy string matching django-stdimage==5.1.1 # Advanced ImageField management django-tex==1.1.7 # LaTeX PDF export From f560be1a9a068796f7b9e1991b6c5009f09029c8 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Wed, 4 Nov 2020 15:41:17 +1100 Subject: [PATCH 4/4] Bug fix: Part thumbnail API list was not working - Part images could not be selected from grid --- InvenTree/company/templates/company/index.html | 4 +++- InvenTree/part/api.py | 17 ++++++++++++++--- InvenTree/part/test_api.py | 11 +++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/InvenTree/company/templates/company/index.html b/InvenTree/company/templates/company/index.html index f110950c0b..ae3e191bc1 100644 --- a/InvenTree/company/templates/company/index.html +++ b/InvenTree/company/templates/company/index.html @@ -15,7 +15,9 @@ InvenTree | {% trans "Supplier List" %} {% if pagetype == 'manufacturers' and roles.purchase_order.add or pagetype == 'suppliers' and roles.purchase_order.add or pagetype == 'customers' and roles.sales_order.add %}
- +
{% endif %} diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index 496153a6d0..c96cff6da5 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -186,18 +186,29 @@ class PartTestTemplateList(generics.ListCreateAPIView): class PartThumbs(generics.ListAPIView): - """ API endpoint for retrieving information on available Part thumbnails """ + """ + API endpoint for retrieving information on available Part thumbnails + """ + queryset = Part.objects.all() serializer_class = part_serializers.PartThumbSerializer + def get_queryset(self): + + queryset = super().get_queryset() + + # Get all Parts which have an associated image + queryset = queryset.exclude(image='') + + return queryset + def list(self, request, *args, **kwargs): """ Serialize the available Part images. - Images may be used for multiple parts! """ - # Get all Parts which have an associated image - queryset = Part.objects.all().exclude(image='') + queryset = self.get_queryset() # TODO - We should return the thumbnails here, not the full image! diff --git a/InvenTree/part/test_api.py b/InvenTree/part/test_api.py index 328ad3ef9e..131936b8bd 100644 --- a/InvenTree/part/test_api.py +++ b/InvenTree/part/test_api.py @@ -241,6 +241,17 @@ class PartAPITest(APITestCase): self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) + def test_get_thumbs(self): + """ + Return list of part thumbnails + """ + + url = reverse('api-part-thumbs') + + response = self.client.get(url) + + self.assertEqual(response.status_code, status.HTTP_200_OK) + class PartAPIAggregationTest(APITestCase): """