it_manager: показывать текст на этикетке даже если в шаблоне только QR/EAN.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -473,6 +473,40 @@ class ItManagerEquipmentTests(TestCase):
|
||||
eq = Equipment.objects.get(serial_number='SN-AUTO-INV-1')
|
||||
self.assertEqual(eq.inventory_number, suggested_inventory_number(eq.pk))
|
||||
|
||||
def test_labels_inject_text_when_template_codes_only(self):
|
||||
from apps.it_manager.equipment_labels import label_payload_for_unit
|
||||
from apps.it_manager.models import EquipmentLabelTemplate
|
||||
|
||||
tmpl = EquipmentLabelTemplate.get_default()
|
||||
tmpl.layout = [
|
||||
{
|
||||
'id': 'qr', 'type': 'qr',
|
||||
'x_mm': 2, 'y_mm': 2, 'w_mm': 20, 'h_mm': 20,
|
||||
'font_pt': 9, 'bold': False, 'align': 'left', 'text': '',
|
||||
},
|
||||
{
|
||||
'id': 'ean', 'type': 'ean13',
|
||||
'x_mm': 2, 'y_mm': 24, 'w_mm': 60, 'h_mm': 14,
|
||||
'font_pt': 8, 'bold': False, 'align': 'center', 'text': '',
|
||||
},
|
||||
]
|
||||
tmpl.save(update_fields=['layout'])
|
||||
|
||||
eq = make_equipment(serial_number='TXT-SN-1', inventory_number='INV-TXT-1')
|
||||
payload = label_payload_for_unit(eq, template=tmpl)
|
||||
types = {b['type'] for b in payload['blocks']}
|
||||
self.assertIn('qr', types)
|
||||
self.assertIn('ean13', types)
|
||||
self.assertIn('model', types)
|
||||
self.assertIn('inventory', types)
|
||||
inv_block = next(b for b in payload['blocks'] if b['type'] == 'inventory')
|
||||
self.assertEqual(inv_block['text'], 'INV-TXT-1')
|
||||
|
||||
r = self.client.get(f'/it-manager/equipment/labels/?ids={eq.pk}')
|
||||
self.assertEqual(r.status_code, 200)
|
||||
self.assertContains(r, 'INV-TXT-1')
|
||||
self.assertContains(r, 'block text')
|
||||
|
||||
def test_label_template_editor(self):
|
||||
import json
|
||||
|
||||
|
||||
Reference in New Issue
Block a user