mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 05:05:42 +00:00 
			
		
		
		
	Part page loading improvements (#3185)
* Lazy load the pricing bom table when the "pricing" tab is selected * Update django-debug-toolbar configuration * Major refactoring for the 'can_build' function - Use a single annotated query to the db, rather than a for loop (which is what a caveman would use) - Query performance is greatly improved - Also refactors existing variant-part-stock subquery code, to make it re-usable * Use minified JS and CSS where possible * Render a 'preview' version of each part image - Saves load time when the image is quite large - Adds a data migration to render out the new variation * Adds 'preview' version of company images * Defer loading of javascript files Note: some cannot be deferred - jquery in particular * Crucial bugfix for user roles context - Previously was *not* being calculated correctly - A non-superuser role would most likely display pages incorrectly * Prevent loading of "about" on every page - Load dynamically when requested - Takes ~400ms! - Cuts out a lot of fat * Match displayed image size to preview image size * Utilize caching framework for accessing user "role" information - Reduces number of DB queries required by rendering framework * Remove redundant query elements * Remove 'stock' field from PartBrief serializer - A calculated field on a serializer is a *bad idea* when that calculation requires a DB hit * Query improvements for StockItem serializer - Remove calculated fields - Fix annotations * Bug fixes * Remove JS load test - Loading of JS files is now deferred, so the unit test does not work as it used to * Fix broken template for "maintenance" page * Remove thumbnail generation migrations - Already performed manually as part of ''invoke migrate" - Running as a migration causes unit test problems - Not sensible to run this as a data-migration anyway * tweak for build table
This commit is contained in:
		| @@ -127,7 +127,10 @@ class Company(models.Model): | ||||
|         upload_to=rename_company_image, | ||||
|         null=True, | ||||
|         blank=True, | ||||
|         variations={'thumbnail': (128, 128)}, | ||||
|         variations={ | ||||
|             'thumbnail': (128, 128), | ||||
|             'preview': (256, 256), | ||||
|         }, | ||||
|         delete_orphans=True, | ||||
|         verbose_name=_('Image'), | ||||
|     ) | ||||
|   | ||||
| @@ -47,7 +47,7 @@ | ||||
| <div class='dropzone part-thumb-container' id='company-thumb'> | ||||
|     <img class="part-thumb" id='company-image' | ||||
|     {% if company.image %} | ||||
|     src="{{ company.image.url }}" | ||||
|     src="{{ company.image.preview.url }}" | ||||
|     {% else %} | ||||
|     src="{% static 'img/blank_image.png' %}" | ||||
|     {% endif %}/> | ||||
|   | ||||
| @@ -50,7 +50,7 @@ | ||||
| {% block thumbnail %} | ||||
| <img class='part-thumb' | ||||
| {% if part.part.image %} | ||||
| src='{{ part.part.image.url }}' | ||||
| src='{{ part.part.image.preview.url }}' | ||||
| {% else %} | ||||
| src="{% static 'img/blank_image.png' %}" | ||||
| {% endif %}/> | ||||
|   | ||||
| @@ -62,7 +62,7 @@ | ||||
| {% block thumbnail %} | ||||
| <img class='part-thumb' | ||||
| {% if part.part.image %} | ||||
| src='{{ part.part.image.url }}' | ||||
| src='{{ part.part.image.preview.url }}' | ||||
| {% else %} | ||||
| src="{% static 'img/blank_image.png' %}" | ||||
| {% endif %}/> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user