forked from crudo/macao-pos
Database schema change. Removed 'currency' column from 'Product'.
This commit is contained in:
parent
27983883d7
commit
1dddddb97d
10
cli.py
10
cli.py
|
@ -99,19 +99,17 @@ def product():
|
||||||
|
|
||||||
|
|
||||||
def tabulate_products(products):
|
def tabulate_products(products):
|
||||||
tab = [["UID", "Name", "Price", "Currency", "Enabled", "Created at"]]
|
tab = [["UID", "Name", "Price", "Enabled", "Created at"]]
|
||||||
for p in products:
|
for p in products:
|
||||||
tab.append([p.uid, p.name, p.price, p.currency,
|
tab.append([p.uid, p.name, p.price, p.is_active, p.created_at])
|
||||||
p.is_active, p.created_at])
|
|
||||||
return tabulate(tab, headers='firstrow')
|
return tabulate(tab, headers='firstrow')
|
||||||
|
|
||||||
|
|
||||||
@product.command('add')
|
@product.command('add')
|
||||||
@click.argument('name')
|
@click.argument('name')
|
||||||
@click.argument('price')
|
@click.argument('price')
|
||||||
@click.option('--currency')
|
def product_add(name, price):
|
||||||
def product_add(name, price, currency):
|
product = Product(name=name, price=price)
|
||||||
product = Product(name=name, currency=currency, price=price)
|
|
||||||
with db.get_session() as session:
|
with db.get_session() as session:
|
||||||
session.add(product)
|
session.add(product)
|
||||||
print("Product succesfully added.")
|
print("Product succesfully added.")
|
||||||
|
|
|
@ -10,7 +10,6 @@ from sqlalchemy.orm import relationship
|
||||||
|
|
||||||
from sqlalchemy_utils import force_auto_coercion
|
from sqlalchemy_utils import force_auto_coercion
|
||||||
from sqlalchemy_utils.types.password import PasswordType
|
from sqlalchemy_utils.types.password import PasswordType
|
||||||
from sqlalchemy_utils.types.currency import CurrencyType
|
|
||||||
|
|
||||||
from pos.logging import get_logger
|
from pos.logging import get_logger
|
||||||
|
|
||||||
|
@ -23,7 +22,6 @@ ENGINE_SQLITE = "sqlite:///{path}"
|
||||||
ENGINE_SQLITE_MEMORY = "sqlite://"
|
ENGINE_SQLITE_MEMORY = "sqlite://"
|
||||||
|
|
||||||
PASSWORD_SCHEMES = ['pbkdf2_sha512']
|
PASSWORD_SCHEMES = ['pbkdf2_sha512']
|
||||||
DEFAULT_CURRENCY = 'EUR'
|
|
||||||
|
|
||||||
|
|
||||||
Base = sqlalchemy.ext.declarative.declarative_base()
|
Base = sqlalchemy.ext.declarative.declarative_base()
|
||||||
|
@ -119,7 +117,6 @@ class Product(Base):
|
||||||
__tablename__ = 'products'
|
__tablename__ = 'products'
|
||||||
uid = Column(Integer, primary_key=True)
|
uid = Column(Integer, primary_key=True)
|
||||||
name = Column(String, nullable=False)
|
name = Column(String, nullable=False)
|
||||||
currency = Column(CurrencyType, nullable=False, default=DEFAULT_CURRENCY)
|
|
||||||
price = Column(Integer, nullable=False)
|
price = Column(Integer, nullable=False)
|
||||||
created_at = Column(DateTime, nullable=False, default=datetime.now)
|
created_at = Column(DateTime, nullable=False, default=datetime.now)
|
||||||
is_active = Column(Boolean, nullable=False, server_default='1')
|
is_active = Column(Boolean, nullable=False, server_default='1')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user