Skip to content

Commit dd78a76

Browse files
committed
Refactor: Update comments for clarity and remove debug logs in image handling components
1 parent b732d4e commit dd78a76

File tree

4 files changed

+1
-69
lines changed

4 files changed

+1
-69
lines changed

src/backend/InvenTree/common/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ def generate_image(filename: str = 'test.png', fmt: str = 'PNG') -> ContentFile:
2020
return ContentFile(buffer.read(), name=filename)
2121

2222

23-
# Subdirectory for storing part images
23+
# Subdirectory for storing images
2424
UPLOADED_IMAGE_DIR = 'images'

src/backend/InvenTree/company/test_migrations.py

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
"""Tests for the company model database migrations."""
22

3-
import shutil
4-
import tempfile
5-
6-
from django.test import override_settings
7-
83
from django_test_migrations.contrib.unittest_case import MigratorTestCase
94

10-
from common.helpers import generate_image
115
from InvenTree import unit_test
126

137

@@ -367,63 +361,3 @@ def test_supplier_part_quantity(self):
367361
# And the 'pack_size' attribute has been removed
368362
with self.assertRaises(AttributeError):
369363
sp.pack_size
370-
371-
372-
class TestCompanyImageMigrationEdgeCases(MigratorTestCase):
373-
"""Test edge cases for Company image migration."""
374-
375-
migrate_from = [('common', '0039_emailthread_emailmessage')]
376-
migrate_to = [('common', '0041_migrate_company_images')]
377-
378-
@classmethod
379-
def setUpClass(cls):
380-
"""Set up the test class."""
381-
super().setUpClass()
382-
cls._temp_media = tempfile.mkdtemp(prefix='test_media_edge_')
383-
cls._override = override_settings(MEDIA_ROOT=cls._temp_media)
384-
cls._override.enable()
385-
386-
@classmethod
387-
def tearDownClass(cls):
388-
"""Clean up after the test class."""
389-
super().tearDownClass()
390-
cls._override.disable()
391-
shutil.rmtree(cls._temp_media, ignore_errors=True)
392-
393-
def prepare(self):
394-
"""Prepare edge case scenarios."""
395-
Company = self.old_state.apps.get_model('company', 'company')
396-
397-
# Company with empty string image
398-
self.empty_img_co = Company.objects.create(name='EmptyImgCo', image='')
399-
400-
# Multiple companies with same image
401-
img = generate_image(filename='shared.png')
402-
self.co1 = Company.objects.create(name='Co1', image=img)
403-
self.co2 = Company.objects.create(name='Co2', image=img)
404-
405-
def test_empty_string_image(self):
406-
"""Test that empty string images are handled correctly."""
407-
InvenTreeImage = self.new_state.apps.get_model('common', 'inventreeimage')
408-
ContentType = self.new_state.apps.get_model('contenttypes', 'contenttype')
409-
410-
ct = ContentType.objects.get(app_label='company', model='company')
411-
412-
# Should not create an image for empty string
413-
with self.assertRaises(InvenTreeImage.DoesNotExist):
414-
InvenTreeImage.objects.get(
415-
content_type_id=ct.pk, object_id=self.empty_img_co.pk
416-
)
417-
418-
def test_shared_image_deduplication(self):
419-
"""Test that multiple companies sharing an image are handled correctly."""
420-
InvenTreeImage = self.new_state.apps.get_model('common', 'inventreeimage')
421-
ContentType = self.new_state.apps.get_model('contenttypes', 'contenttype')
422-
423-
ct = ContentType.objects.get(app_label='company', model='company')
424-
425-
img1 = InvenTreeImage.objects.get(content_type_id=ct.pk, object_id=self.co1.pk)
426-
img2 = InvenTreeImage.objects.get(content_type_id=ct.pk, object_id=self.co2.pk)
427-
428-
self.assertTrue(img1.primary)
429-
self.assertTrue(img2.primary)

src/frontend/src/components/details/DetailsImage.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,6 @@ function ImageItem(props: Readonly<DetailImageProps>) {
467467
}
468468
});
469469

470-
console.log(props);
471470
// Modal used for removing/deleting the current image
472471
const deleteUploadImage = useDeleteApiFormModal({
473472
url: ApiEndpoints.upload_image_list,

src/frontend/src/pages/build/BuildDetail.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,6 @@ export default function BuildDetail() {
553553
onFormSuccess: refreshInstance
554554
});
555555

556-
console.log(build);
557556
const duplicateBuildOrderInitialData = useMemo(() => {
558557
const data = { ...build };
559558
// if we set the reference to null/undefined, it will be left blank in the form

0 commit comments

Comments
 (0)