feat: attrs on product
This commit is contained in:
@@ -6,6 +6,7 @@ from .company_name_attribute_getter import CompanyNameAttributeGetter
|
||||
from .composition_attribute_getter import CompositionAttributeGetter
|
||||
from .inn_attribute_getter import InnAttributeGetter
|
||||
from .name_attribute_getter import NameAttributeGetter
|
||||
from .size_attribute_getter import SizeAttributeGetter
|
||||
|
||||
|
||||
class AttributeWriterFactory:
|
||||
@@ -28,5 +29,7 @@ class AttributeWriterFactory:
|
||||
return ColorAttributeGetter()
|
||||
case 'composition':
|
||||
return CompositionAttributeGetter()
|
||||
case 'size':
|
||||
return SizeAttributeGetter()
|
||||
case _:
|
||||
return None
|
||||
|
||||
@@ -5,7 +5,5 @@ from models import Product
|
||||
class BrandAttributeGetter(BaseAttributeGetter):
|
||||
|
||||
def get_value(self, product: Product):
|
||||
result = product.brand
|
||||
if not result:
|
||||
result = ''
|
||||
return result
|
||||
return product.brand
|
||||
|
||||
|
||||
@@ -5,7 +5,4 @@ from models import Product
|
||||
class ColorAttributeGetter(BaseAttributeGetter):
|
||||
|
||||
def get_value(self, product: Product):
|
||||
result = product.color
|
||||
if not result:
|
||||
result = ''
|
||||
return result
|
||||
return product.color
|
||||
|
||||
@@ -5,7 +5,4 @@ from models import Product, Client
|
||||
class CompanyNameAttributeGetter(BaseAttributeGetter):
|
||||
def get_value(self, product: Product):
|
||||
client: Client = product.client
|
||||
result = client.company_name
|
||||
if not result:
|
||||
result = ''
|
||||
return result
|
||||
return client.company_name
|
||||
|
||||
@@ -5,7 +5,4 @@ from models import Product
|
||||
class CompositionAttributeGetter(BaseAttributeGetter):
|
||||
|
||||
def get_value(self, product: Product):
|
||||
result = product.composition
|
||||
if not result:
|
||||
result = ''
|
||||
return result
|
||||
return product.composition
|
||||
|
||||
@@ -6,7 +6,4 @@ class InnAttributeGetter(BaseAttributeGetter):
|
||||
def get_value(self, product: Product):
|
||||
client: Client = product.client
|
||||
client_details: ClientDetails = client.details
|
||||
result = client_details.inn
|
||||
if not result:
|
||||
result = ''
|
||||
return result
|
||||
return client_details.inn
|
||||
|
||||
7
barcodes/attributes/size_attribute_getter.py
Normal file
7
barcodes/attributes/size_attribute_getter.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from barcodes.attributes.base import BaseAttributeGetter
|
||||
from models import Product
|
||||
|
||||
|
||||
class SizeAttributeGetter(BaseAttributeGetter):
|
||||
def get_value(self, product: Product):
|
||||
return product.size
|
||||
Reference in New Issue
Block a user