1
Fork 0
mirror of https://github.com/Steffo99/greed.git synced 2024-11-24 14:54:18 +00:00

fix-2 sqlalchemy exception

This commit is contained in:
valentino-sm 2021-05-05 07:46:58 +05:00 committed by Stefano Pigozzi
parent d0b7da2ab2
commit 6a70a45211
2 changed files with 2 additions and 1 deletions

View file

@ -297,6 +297,7 @@ class OrderItem(DeferredReflection, TableDeclarativeBase):
product = relationship("Product")
# The order in which this item is being purchased
order_id = Column(Integer, ForeignKey("orders.order_id"), nullable=False)
order = relationship("Order")
# Extra table parameters
__tablename__ = "orderitems"

View file

@ -652,7 +652,7 @@ class Worker(threading.Thread):
# Create {quantity} new OrderItems
for i in range(0, cart[product][1]):
order_item = db.OrderItem(product=cart[product][0],
order_id=order.order_id)
order=order)
self.session.add(order_item)
# Ensure the user has enough credit to make the purchase
credit_required = self.__get_cart_value(cart) - self.user.credit