From eb378e5e5d08c48f0fa0f97b53d6ddc1dde6f549 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 6 Sep 2019 12:38:09 +1000 Subject: [PATCH 1/3] Specify PNG image for QR code generation --- InvenTree/InvenTree/static/css/inventree.css | 11 +++++++++++ InvenTree/InvenTree/tests.py | 2 +- InvenTree/templates/qr_code.html | 4 +++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/InvenTree/InvenTree/static/css/inventree.css b/InvenTree/InvenTree/static/css/inventree.css index d9515dbff9..321d9e1cf4 100644 --- a/InvenTree/InvenTree/static/css/inventree.css +++ b/InvenTree/InvenTree/static/css/inventree.css @@ -1,3 +1,14 @@ +.qr-code { + max-width: 400px; + max-height: 400px; + align-content: center; +} + +.qr-container { + width: 100%; + align-content: center; +} + .navbar-brand { float: left; } diff --git a/InvenTree/InvenTree/tests.py b/InvenTree/InvenTree/tests.py index 2d1b345687..4e238a6c80 100644 --- a/InvenTree/InvenTree/tests.py +++ b/InvenTree/InvenTree/tests.py @@ -78,7 +78,7 @@ class TestQuoteWrap(TestCase): self.assertEqual(helpers.WrapWithQuotes('hello"'), '"hello"') -class TestMakeBarcoede(TestCase): +class TestMakeBarcode(TestCase): """ Tests for barcode string creation """ def test_barcode(self): diff --git a/InvenTree/templates/qr_code.html b/InvenTree/templates/qr_code.html index 9c0c698368..bdc58a45eb 100644 --- a/InvenTree/templates/qr_code.html +++ b/InvenTree/templates/qr_code.html @@ -2,7 +2,9 @@
{% if qr_data %} - QR Code +
+ QR Code +
{% else %} Error:
{{ error_msg }} From 9bde8bde66a238e5977631dc73afe961942336a0 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 6 Sep 2019 12:40:04 +1000 Subject: [PATCH 2/3] Tree items dispaly description in __str__ representation --- InvenTree/InvenTree/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InvenTree/InvenTree/models.py b/InvenTree/InvenTree/models.py index 646515ce70..0c05a2a44b 100644 --- a/InvenTree/InvenTree/models.py +++ b/InvenTree/InvenTree/models.py @@ -189,7 +189,7 @@ class InvenTreeTree(models.Model): def __str__(self): """ String representation of a category is the full path to that category """ - return self.pathstring + return "{path} - {desc}".format(path=self.pathstring, desc=self.description) @receiver(pre_delete, sender=InvenTreeTree, dispatch_uid='tree_pre_delete_log') From dac1264878b7e521f4d9c7c9a9da36f968a7c826 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 6 Sep 2019 12:48:31 +1000 Subject: [PATCH 3/3] Fixed unit tests --- InvenTree/part/test_category.py | 8 ++++---- InvenTree/part/test_part.py | 2 +- InvenTree/part/test_views.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/InvenTree/part/test_category.py b/InvenTree/part/test_category.py index 3b3fe36b08..d9bb42d546 100644 --- a/InvenTree/part/test_category.py +++ b/InvenTree/part/test_category.py @@ -67,8 +67,8 @@ class CategoryTest(TestCase): def test_path_string(self): """ Test that the category path string works correctly """ - self.assertEqual(str(self.resistors), 'Electronics/Resistors') - self.assertEqual(str(self.transceivers), 'Electronics/IC/Transceivers') + self.assertEqual(str(self.resistors), 'Electronics/Resistors - Resistors') + self.assertEqual(str(self.transceivers.pathstring), 'Electronics/IC/Transceivers') def test_url(self): """ Test that the PartCategory URL works """ @@ -111,11 +111,11 @@ class CategoryTest(TestCase): def test_default_locations(self): """ Test traversal for default locations """ - self.assertEqual(str(self.fasteners.default_location), 'Office/Drawer_1') + self.assertEqual(str(self.fasteners.default_location), 'Office/Drawer_1 - In my desk') # Test that parts in this location return the same default location, too for p in self.fasteners.children.all(): - self.assert_equal(p.get_default_location(), 'Office/Drawer_1') + self.assert_equal(p.get_default_location().pathstring, 'Office/Drawer_1') # Any part under electronics should default to 'Home' R1 = Part.objects.get(name='R_2K2_0805') diff --git a/InvenTree/part/test_part.py b/InvenTree/part/test_part.py index 8e69c8681d..c9028cd406 100644 --- a/InvenTree/part/test_part.py +++ b/InvenTree/part/test_part.py @@ -44,7 +44,7 @@ class PartTest(TestCase): self.assertEqual(self.R1.get_absolute_url(), '/part/3/') def test_category(self): - self.assertEqual(str(self.C1.category), 'Electronics/Capacitors') + self.assertEqual(str(self.C1.category), 'Electronics/Capacitors - Capacitors') orphan = Part.objects.get(name='Orphan') self.assertIsNone(orphan.category) diff --git a/InvenTree/part/test_views.py b/InvenTree/part/test_views.py index b2d0b50fb9..ecf4c936d1 100644 --- a/InvenTree/part/test_views.py +++ b/InvenTree/part/test_views.py @@ -167,7 +167,7 @@ class PartQRTest(PartViewTestCase): data = str(response.content) self.assertIn('Part QR Code', data) - self.assertIn('