feat: bigger product size

This commit is contained in:
2024-10-06 13:04:42 +03:00
parent 4e5365b946
commit e153d4a1c0
3 changed files with 9 additions and 3 deletions

View File

@@ -4,4 +4,6 @@ from models import Product
class SizeAttributeGetter(BaseAttributeGetter): class SizeAttributeGetter(BaseAttributeGetter):
def get_value(self, product: Product): def get_value(self, product: Product):
return product.size if not product.size:
return None
return f'<font size="8" name="Helvetica-Bold"><b>{product.size}</b></font>'

View File

@@ -21,11 +21,15 @@ class DefaultBarcodeGenerator(BaseBarcodeGenerator):
if not attribute_getter: if not attribute_getter:
continue continue
value = attribute_getter.get_value(barcode_data["product"]) value = attribute_getter.get_value(barcode_data["product"])
if not value or not value.strip(): if not value or not value.strip():
continue continue
attributes[attribute.name] = value attributes[attribute.name] = value
for additional_attribute in barcode_data["template"].additional_attributes: for additional_attribute in barcode_data["template"].additional_attributes:
attributes[additional_attribute.name] = additional_attribute.value value = additional_attribute.value
if not value:
continue
attributes[additional_attribute.name] = value
barcode_text = '<br/>'.join([f'{key}: {value}' for key, value in attributes.items()]) barcode_text = '<br/>'.join([f'{key}: {value}' for key, value in attributes.items()])
pdf_barcodes_gen_data.append( pdf_barcodes_gen_data.append(

View File

@@ -34,7 +34,7 @@ class PDFGenerator:
leading=7, leading=7,
spaceAfter=2, spaceAfter=2,
leftIndent=2, leftIndent=2,
rightIndent=2 rightIndent=2,
) )
def generate_small_text(self, barcode_value, text, num_duplicates=1): def generate_small_text(self, barcode_value, text, num_duplicates=1):