Counter view now has a "sign" to distinguish between purchases and anti-purchases.
This commit is contained in:
parent
a0ec131c49
commit
13dbdf5f60
1
db.py
1
db.py
|
@ -75,6 +75,7 @@ class UserProducts(Base):
|
|||
user_name = Column(String(10), ForeignKey('users.name'), primary_key=True)
|
||||
product_id = Column(Integer, ForeignKey("products.product_id"), primary_key=True)
|
||||
count = Column(Integer)
|
||||
sign = Column(Integer)
|
||||
|
||||
user = relationship(User, backref=backref('products', order_by=count.desc()), lazy='joined')
|
||||
product = relationship(Product, backref="users", lazy='joined')
|
||||
|
|
|
@ -114,6 +114,7 @@ class ShowUserMenu(Menu):
|
|||
for ref in user.products:
|
||||
product = ref.product
|
||||
count = ref.count
|
||||
if count > 0:
|
||||
products.append((product, count))
|
||||
num_products = len(products)
|
||||
if num_products == 0:
|
||||
|
|
Loading…
Reference in New Issue