feat: attrs on product
This commit is contained in:
@@ -2,7 +2,9 @@ from .article_attribute_getter import ArticleAttributeGetter
|
||||
from .brand_attribute_getter import BrandAttributeGetter
|
||||
from .client_name_attribute_getter import ClientNameAttributeGetter
|
||||
from .color_attribute_getter import ColorAttributeGetter
|
||||
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
|
||||
|
||||
|
||||
@@ -16,6 +18,10 @@ class AttributeWriterFactory:
|
||||
return ArticleAttributeGetter()
|
||||
case 'client.name':
|
||||
return ClientNameAttributeGetter()
|
||||
case 'client.company_name':
|
||||
return CompanyNameAttributeGetter()
|
||||
case 'client.inn':
|
||||
return InnAttributeGetter()
|
||||
case 'brand':
|
||||
return BrandAttributeGetter()
|
||||
case 'color':
|
||||
|
||||
11
barcodes/attributes/company_name_attribute_getter.py
Normal file
11
barcodes/attributes/company_name_attribute_getter.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from barcodes.attributes.base import BaseAttributeGetter
|
||||
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
|
||||
12
barcodes/attributes/inn_attribute_getter.py
Normal file
12
barcodes/attributes/inn_attribute_getter.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from barcodes.attributes.base import BaseAttributeGetter
|
||||
from models import Product, Client, ClientDetails
|
||||
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user