feat: temp barcode templates
This commit is contained in:
@@ -1,21 +1,24 @@
|
||||
# from abc import abstractmethod, ABC
|
||||
#
|
||||
# from .article_attribute_writer import ArticleAttributeWriter
|
||||
# from .name_attribute_writer import NameAttributeWriter
|
||||
# from ..barcode import Barcode
|
||||
#
|
||||
#
|
||||
# class BaseAttributeWriter(ABC):
|
||||
# @abstractmethod
|
||||
# def write(self, barcode: Barcode):
|
||||
# pass
|
||||
#
|
||||
#
|
||||
# class AttributeWriterFactory:
|
||||
# @staticmethod
|
||||
# def get_writer(key: str):
|
||||
# match key:
|
||||
# case 'name':
|
||||
# return NameAttributeWriter()
|
||||
# case 'article':
|
||||
# return ArticleAttributeWriter()
|
||||
from abc import abstractmethod, ABC
|
||||
|
||||
from models import Product
|
||||
from .article_attribute_getter import ArticleAttributeGetter
|
||||
from .client_name_attribute_getter import ClientNameAttributeGetter
|
||||
from .name_attribute_getter import NameAttributeGetter
|
||||
|
||||
|
||||
class BaseAttributeGetter(ABC):
|
||||
@abstractmethod
|
||||
def get_value(self, product: Product):
|
||||
pass
|
||||
|
||||
|
||||
class AttributeWriterFactory:
|
||||
@staticmethod
|
||||
def get_writer(key: str):
|
||||
match key:
|
||||
case 'name':
|
||||
return NameAttributeGetter()
|
||||
case 'article':
|
||||
return ArticleAttributeGetter()
|
||||
case 'client.name':
|
||||
return ClientNameAttributeGetter()
|
||||
|
||||
7
barcodes/attributes/article_attribute_getter.py
Normal file
7
barcodes/attributes/article_attribute_getter.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from barcodes.attributes import BaseAttributeGetter
|
||||
from models import Product
|
||||
|
||||
|
||||
class ArticleAttributeGetter(BaseAttributeGetter):
|
||||
def get_value(self, product: Product):
|
||||
return product.article
|
||||
@@ -1,7 +0,0 @@
|
||||
# from barcodes.attributes import BaseAttributeWriter
|
||||
# from barcodes.barcode import Barcode
|
||||
#
|
||||
#
|
||||
# class ArticleAttributeWriter(BaseAttributeWriter):
|
||||
# def write(self, barcode: Barcode):
|
||||
# pass
|
||||
8
barcodes/attributes/client_name_attribute_getter.py
Normal file
8
barcodes/attributes/client_name_attribute_getter.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from barcodes.attributes import BaseAttributeGetter
|
||||
from models import Product, Client
|
||||
|
||||
|
||||
class ClientNameAttributeGetter(BaseAttributeGetter):
|
||||
def get_value(self, product: Product):
|
||||
client: Client = product.client
|
||||
return client.name
|
||||
7
barcodes/attributes/name_attribute_getter.py
Normal file
7
barcodes/attributes/name_attribute_getter.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from barcodes.attributes import BaseAttributeGetter
|
||||
from models import Product
|
||||
|
||||
|
||||
class NameAttributeGetter(BaseAttributeGetter):
|
||||
def get_value(self, product: Product):
|
||||
return product.name
|
||||
@@ -1,7 +0,0 @@
|
||||
# from barcodes.attributes import BaseAttributeWriter
|
||||
# from barcodes.barcode import Barcode
|
||||
#
|
||||
#
|
||||
# class NameAttributeWriter(BaseAttributeWriter):
|
||||
# def write(self, barcode: Barcode):
|
||||
# pass
|
||||
@@ -1,15 +0,0 @@
|
||||
# from .attributes import AttributeWriterFactory
|
||||
# from models import ProductBarcode, BarcodeTemplate, BarcodeTemplateAttribute
|
||||
#
|
||||
#
|
||||
# class Barcode:
|
||||
# def __init__(self, session, barcode: ProductBarcode):
|
||||
# self.session = session
|
||||
# self.barcode = barcode
|
||||
#
|
||||
# def render(self, template: BarcodeTemplate):
|
||||
# for attribute in template.attributes:
|
||||
# attribute: BarcodeTemplateAttribute
|
||||
# writer = AttributeWriterFactory.get_writer(attribute.key)
|
||||
# writer.write(self)
|
||||
#
|
||||
@@ -1,6 +0,0 @@
|
||||
# from models import ProductBarcode
|
||||
#
|
||||
#
|
||||
# class BarcodeGenerator:
|
||||
# def __init__(self, barcode: ProductBarcode):
|
||||
# self.barcode = barcode
|
||||
Reference in New Issue
Block a user