Files
product-slip/slips/management/commands/seed_products.py
Diaco Soltanpour d7f1929674 Label print calibration and Lithium Label UI polish (#3)
## Summary
- Calibrate label print/calibrate CSS to the reference PDF (positions, ~7pt/6pt sizes, bottom-row pitch)
- Print layout: partial last-box weight, pad short pages to 4 slips, whole-number weights
- Rename to Lithium Label Manager; Vazirmatn for FA / Inter for EN; inverted lithium icon; seed weights=5; number step=1; hide empty toast

## Test plan
- [ ] Print calibration sheet and overlay on a physical label — top and bottom rows align
- [ ] Order 50/5/4 — box labels show 20, 20, 10 (padded page); weights without `.0`
- [ ] Language toggle switches Inter ↔ Vazirmatn
- [ ] Seed products use canister weight 5; form spinners step by 1

Reviewed-on: #3
Co-authored-by: Diaco Soltanpour <dyaco8464@yahoo.com>
Co-committed-by: Diaco Soltanpour <dyaco8464@yahoo.com>
2026-10-01 18:10:44 +00:00

50 lines
1.9 KiB
Python

from django.core.management.base import BaseCommand
from slips.models import Product
SEED_PRODUCTS = [
{'code': 'ICJ/408', 'description': 'DIGITAL INK RED BROWN', 'default_net_weight': 5},
{'code': 'ICJ/407', 'description': 'DIGITAL INK RED BROWN', 'default_net_weight': 5},
{'code': 'ICJ/309', 'description': 'DIGITAL INK CYAN', 'default_net_weight': 5},
{'code': 'ICJ/EH630', 'description': 'DIGITAL INK BLACK', 'default_net_weight': 5},
{'code': 'ICJ/308', 'description': 'DIGITAL INK BLUE', 'default_net_weight': 5},
]
class Command(BaseCommand):
help = 'Seed the database with initial product data from Excel'
def add_arguments(self, parser):
parser.add_argument(
'--skip-existing',
action='store_true',
help='Skip products that already exist',
)
def handle(self, *args, **options):
created_count = 0
for product_data in SEED_PRODUCTS:
if options['skip_existing']:
product, created = Product.objects.get_or_create(
code=product_data['code'],
defaults=product_data,
)
if not created:
# Sync seed canister weight without wiping other edits
w = product_data['default_net_weight']
if product.default_net_weight != w:
product.default_net_weight = w
product.save(update_fields=['default_net_weight'])
else:
Product.objects.update_or_create(
code=product_data['code'],
defaults=product_data,
)
created = True
if created:
created_count += 1
self.stdout.write(
self.style.SUCCESS(f'Seeded {created_count} products ({len(SEED_PRODUCTS)} total)')
)