feat: attrs on product
This commit is contained in:
		@@ -1,3 +1,4 @@
 | 
				
			|||||||
 | 
					from .additional_info_attribute_getter import AdditionalInfoAttributeGetter
 | 
				
			||||||
from .article_attribute_getter import ArticleAttributeGetter
 | 
					from .article_attribute_getter import ArticleAttributeGetter
 | 
				
			||||||
from .brand_attribute_getter import BrandAttributeGetter
 | 
					from .brand_attribute_getter import BrandAttributeGetter
 | 
				
			||||||
from .client_name_attribute_getter import ClientNameAttributeGetter
 | 
					from .client_name_attribute_getter import ClientNameAttributeGetter
 | 
				
			||||||
@@ -31,5 +32,7 @@ class AttributeWriterFactory:
 | 
				
			|||||||
                return CompositionAttributeGetter()
 | 
					                return CompositionAttributeGetter()
 | 
				
			||||||
            case 'size':
 | 
					            case 'size':
 | 
				
			||||||
                return SizeAttributeGetter()
 | 
					                return SizeAttributeGetter()
 | 
				
			||||||
 | 
					            case 'additional_info':
 | 
				
			||||||
 | 
					                return AdditionalInfoAttributeGetter()
 | 
				
			||||||
            case _:
 | 
					            case _:
 | 
				
			||||||
                return None
 | 
					                return None
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										7
									
								
								barcodes/attributes/additional_info_attribute_getter.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								barcodes/attributes/additional_info_attribute_getter.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					from barcodes.attributes.base import BaseAttributeGetter
 | 
				
			||||||
 | 
					from models import Product
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class AdditionalInfoAttributeGetter(BaseAttributeGetter):
 | 
				
			||||||
 | 
					    def get_value(self, product: Product):
 | 
				
			||||||
 | 
					        return product.additional_info
 | 
				
			||||||
@@ -23,6 +23,7 @@ class Product(BaseModel):
 | 
				
			|||||||
    color = Column(String, nullable=True, comment='Цвет')
 | 
					    color = Column(String, nullable=True, comment='Цвет')
 | 
				
			||||||
    composition = Column(String, nullable=True, comment='Состав')
 | 
					    composition = Column(String, nullable=True, comment='Состав')
 | 
				
			||||||
    size = Column(String, nullable=True, comment='Размер')
 | 
					    size = Column(String, nullable=True, comment='Размер')
 | 
				
			||||||
 | 
					    additional_info = Column(String, nullable=True, comment='Дополнительное поле')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ProductBarcode(BaseModel):
 | 
					class ProductBarcode(BaseModel):
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,6 +20,7 @@ class ProductSchema(CustomModelCamel):
 | 
				
			|||||||
    color: str | None = None
 | 
					    color: str | None = None
 | 
				
			||||||
    composition: str | None = None
 | 
					    composition: str | None = None
 | 
				
			||||||
    size: str | None = None
 | 
					    size: str | None = None
 | 
				
			||||||
 | 
					    additional_info: str | None = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @field_validator('barcodes', mode="before")
 | 
					    @field_validator('barcodes', mode="before")
 | 
				
			||||||
    def barcodes_to_list(cls, v):
 | 
					    def barcodes_to_list(cls, v):
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user