Counter view now has a "sign" to distinguish between purchases and anti-purchases.

This commit is contained in:
Christoffer Viken 2017-02-26 13:26:17 +00:00
parent a0ec131c49
commit 13dbdf5f60
2 changed files with 3 additions and 1 deletions

1
db.py
View File

@ -75,6 +75,7 @@ class UserProducts(Base):
user_name = Column(String(10), ForeignKey('users.name'), primary_key=True) user_name = Column(String(10), ForeignKey('users.name'), primary_key=True)
product_id = Column(Integer, ForeignKey("products.product_id"), primary_key=True) product_id = Column(Integer, ForeignKey("products.product_id"), primary_key=True)
count = Column(Integer) count = Column(Integer)
sign = Column(Integer)
user = relationship(User, backref=backref('products', order_by=count.desc()), lazy='joined') user = relationship(User, backref=backref('products', order_by=count.desc()), lazy='joined')
product = relationship(Product, backref="users", lazy='joined') product = relationship(Product, backref="users", lazy='joined')

View File

@ -114,7 +114,8 @@ class ShowUserMenu(Menu):
for ref in user.products: for ref in user.products:
product = ref.product product = ref.product
count = ref.count count = ref.count
products.append((product, count)) if count > 0:
products.append((product, count))
num_products = len(products) num_products = len(products)
if num_products == 0: if num_products == 0:
print 'No products purchased yet' print 'No products purchased yet'