Add initial Shopfoo pattern feature
data models, import/export, web views etc.
This commit is contained in:
parent
a7656928f5
commit
852f9d4902
19 changed files with 515 additions and 1 deletions
|
@ -0,0 +1,75 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""initial tables
|
||||
|
||||
Revision ID: 2108f9efa758
|
||||
Revises: efb7cd318947
|
||||
Create Date: 2020-08-19 20:02:15.501843
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '2108f9efa758'
|
||||
down_revision = None
|
||||
branch_labels = ('rattail_demo',)
|
||||
depends_on = None
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import rattail.db.types
|
||||
|
||||
|
||||
|
||||
def upgrade():
|
||||
|
||||
# demo_shopfoo_product
|
||||
op.create_table('demo_shopfoo_product',
|
||||
sa.Column('uuid', sa.String(length=32), nullable=False),
|
||||
sa.Column('product_uuid', sa.String(length=32), nullable=True),
|
||||
sa.Column('upc', sa.String(length=14), nullable=True),
|
||||
sa.Column('description', sa.String(length=255), nullable=True),
|
||||
sa.Column('price', sa.Numeric(precision=13, scale=2), nullable=True),
|
||||
sa.Column('enabled', sa.Boolean(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['product_uuid'], ['product.uuid'], name='demo_shopfoo_product_fk_product'),
|
||||
sa.PrimaryKeyConstraint('uuid')
|
||||
)
|
||||
op.create_table('demo_shopfoo_product_version',
|
||||
sa.Column('uuid', sa.String(length=32), autoincrement=False, nullable=False),
|
||||
sa.Column('product_uuid', sa.String(length=32), autoincrement=False, nullable=True),
|
||||
sa.Column('upc', sa.String(length=14), autoincrement=False, nullable=True),
|
||||
sa.Column('description', sa.String(length=255), autoincrement=False, nullable=True),
|
||||
sa.Column('price', sa.Numeric(precision=13, scale=2), autoincrement=False, nullable=True),
|
||||
sa.Column('enabled', sa.Boolean(), autoincrement=False, nullable=True),
|
||||
sa.Column('transaction_id', sa.BigInteger(), autoincrement=False, nullable=False),
|
||||
sa.Column('end_transaction_id', sa.BigInteger(), nullable=True),
|
||||
sa.Column('operation_type', sa.SmallInteger(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('uuid', 'transaction_id')
|
||||
)
|
||||
op.create_index(op.f('ix_demo_shopfoo_product_version_end_transaction_id'), 'demo_shopfoo_product_version', ['end_transaction_id'], unique=False)
|
||||
op.create_index(op.f('ix_demo_shopfoo_product_version_operation_type'), 'demo_shopfoo_product_version', ['operation_type'], unique=False)
|
||||
op.create_index(op.f('ix_demo_shopfoo_product_version_transaction_id'), 'demo_shopfoo_product_version', ['transaction_id'], unique=False)
|
||||
|
||||
# demo_shopfoo_product_export
|
||||
op.create_table('demo_shopfoo_product_export',
|
||||
sa.Column('uuid', sa.String(length=32), nullable=False),
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('created', sa.DateTime(), nullable=False),
|
||||
sa.Column('created_by_uuid', sa.String(length=32), nullable=False),
|
||||
sa.Column('record_count', sa.Integer(), nullable=True),
|
||||
sa.Column('filename', sa.String(length=255), nullable=True),
|
||||
sa.Column('uploaded', sa.Boolean(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['created_by_uuid'], ['user.uuid'], name='demo_shopfoo_product_export_fk_created_by'),
|
||||
sa.PrimaryKeyConstraint('uuid')
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
|
||||
# demo_shopfoo_product_export
|
||||
op.drop_table('demo_shopfoo_product_export')
|
||||
|
||||
# demo_shopfoo_product
|
||||
op.drop_index(op.f('ix_demo_shopfoo_product_version_transaction_id'), table_name='demo_shopfoo_product_version')
|
||||
op.drop_index(op.f('ix_demo_shopfoo_product_version_operation_type'), table_name='demo_shopfoo_product_version')
|
||||
op.drop_index(op.f('ix_demo_shopfoo_product_version_end_transaction_id'), table_name='demo_shopfoo_product_version')
|
||||
op.drop_table('demo_shopfoo_product_version')
|
||||
op.drop_table('demo_shopfoo_product')
|
|
@ -8,3 +8,6 @@ from rattail.db.model import *
|
|||
|
||||
# also bring in CORE integration models
|
||||
from rattail_corepos.db.model import *
|
||||
|
||||
# now bring in Demo-specific models
|
||||
from .shopfoo import ShopfooProduct, ShopfooProductExport
|
37
rattail_demo/db/model/shopfoo.py
Normal file
37
rattail_demo/db/model/shopfoo.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
"""
|
||||
Database schema extensions for Shopfoo integration
|
||||
"""
|
||||
|
||||
import sqlalchemy as sa
|
||||
|
||||
from rattail.db import model
|
||||
from rattail.db.model.shopfoo import ShopfooProductBase, ShopfooProductExportBase
|
||||
|
||||
|
||||
class ShopfooProduct(ShopfooProductBase, model.Base):
|
||||
"""
|
||||
Shopfoo-specific product cache table. Each record in this table *should*
|
||||
match exactly, what is in the actual "Shopfoo" system (even though that's
|
||||
made-up in this case).
|
||||
"""
|
||||
__tablename__ = 'demo_shopfoo_product'
|
||||
__versioned__ = {}
|
||||
|
||||
upc = sa.Column(sa.String(length=14), nullable=True)
|
||||
|
||||
description = sa.Column(sa.String(length=255), nullable=True)
|
||||
|
||||
price = sa.Column(sa.Numeric(precision=13, scale=2), nullable=True)
|
||||
|
||||
enabled = sa.Column(sa.Boolean(), nullable=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.description or self.upc or ""
|
||||
|
||||
|
||||
class ShopfooProductExport(ShopfooProductExportBase, model.Base):
|
||||
"""
|
||||
Shopfoo product exports
|
||||
"""
|
||||
__tablename__ = 'demo_shopfoo_product_export'
|
Loading…
Add table
Add a link
Reference in a new issue