fixed legacy flavor crash

This commit is contained in:
nvrl committed 2026-03-19 15:53:54 +01:00
1 parent ea5d85f31f
commit 33a41a959d
1 file changed
+8 -2
@@ -121,11 +121,13 @@ class Command(BaseCommand):
if not flavor: if not flavor:
# 2. Try exact name match in category # 2. Try exact name match in category
flavor = Flavor.objects.filter(name=title, category=category, is_legacy=False).first() # REMOVED: is_legacy=False
flavor = Flavor.objects.filter(name=title, category=category).first()
if not flavor: if not flavor:
# 3. Try case-insensitive name match in category (safety for whitespace/case) # 3. Try case-insensitive name match in category (safety for whitespace/case)
flavor = Flavor.objects.filter(name__iexact=title, category=category, is_legacy=False).first() # REMOVED: is_legacy=False
flavor = Flavor.objects.filter(name__iexact=title, category=category).first()
if not flavor: if not flavor:
flavor = Flavor(external_id=p['id'], name=title, category=category, is_legacy=False) flavor = Flavor(external_id=p['id'], name=title, category=category, is_legacy=False)
@@ -136,6 +138,10 @@ class Command(BaseCommand):
if not flavor.external_id: if not flavor.external_id:
flavor.external_id = p['id'] flavor.external_id = p['id']
# Reactivate the flavor if it was previously marked as legacy
if flavor.is_legacy:
flavor.is_legacy = False
if image_url: if image_url:
# Check if local file exists # Check if local file exists
file_exists = False file_exists = False