From 78cd76b2dc0aabcbc67ca634668aa9d521197183 Mon Sep 17 00:00:00 2001 From: Santiago Valenzuela Date: Wed, 9 Dec 2020 04:07:15 -0600 Subject: [PATCH] database.py: Categories implementation --- .vs/greed-mastersuv-categories-impl/v16/.suo | Bin 0 -> 6144 bytes database.py | 15 +++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 .vs/greed-mastersuv-categories-impl/v16/.suo diff --git a/.vs/greed-mastersuv-categories-impl/v16/.suo b/.vs/greed-mastersuv-categories-impl/v16/.suo new file mode 100644 index 0000000000000000000000000000000000000000..e1d196f92ea618ea96546ea4f57fc502ad6febed GIT binary patch literal 6144 zcmca`Uhu)fjZzO8(10BSGsD0CoD6J8;*3aa1_1`J97ycn|Ns9%QXn>vISPhQ2m~?Y z17Qh+0)s0<9*{0#s02kN(LjuW6&~kI1auu}=im}Pca4z~sO|tWL~#Jn#(ah>22Y^v zX+V}MLj?g-P^HBfnBew97y5@8VpQ~pmfgy#KhVUGVK6}00Ls{H-ad|N&@XC+5e!R-v>2~9Z3Jhl3qc1 z8iYZB3#bOhhKP)k!zBdhng1s|NO>m&%m2{Af(rSc5jifP$r>*OO3&2J|DZetatB_E zkt7d5*;L5?VE>a+{vhXnSlF=w-2*BIkn=rA4#ejG%7NIUVEBaqsO|z~MNmA0(hw*e zfY_jV0Tl0`x*9!A48KqqxjrJM{4oZm0bGEb_6Mj>aRirvWQZfj9vRvx)-sgsCpQ0c z14D@ih^+mw3 zl~kaNE|AUznverDs~jwz4Yn1M_JZXNW=xz~WOGV$Lc{IiFJTqteqVYcohyX$*KYpK zcg7dwNA$GUF<|ZojT>bGeNqg~Ii)3A<%%u|9f?->EN3ORIrK^Osd*Bc{tjn>-B1n`xFwo^60P>S=2><{9 literal 0 HcmV?d00001 diff --git a/database.py b/database.py index cbc9457..d708598 100644 --- a/database.py +++ b/database.py @@ -92,6 +92,8 @@ class Product(DeferredReflection, TableDeclarativeBase): # Product id id = Column(Integer, primary_key=True) + # Category id + category_id = Column(Integer, ForeignKey("categories.id")) # Product name name = Column(String) # Product description @@ -150,6 +152,18 @@ class Product(DeferredReflection, TableDeclarativeBase): # Store the photo in the database record self.image = r.content +class Category(DeferredReflection, TableDeclarativeBase): + """A purchasable product.""" + + # Category id + id = Column(Integer, primary_key=True) + # Category name + name = Column(String) + # Category has been deleted + deleted = Column(Boolean, nullable=False) + + # Extra table parameters + __tablename__ = "categories" class Transaction(DeferredReflection, TableDeclarativeBase): """A greed wallet transaction. @@ -209,6 +223,7 @@ class Admin(DeferredReflection, TableDeclarativeBase): user = relationship("User") # Permissions edit_products = Column(Boolean, default=False) + edit_categories = Column(Boolean, default=False) receive_orders = Column(Boolean, default=False) create_transactions = Column(Boolean, default=False) display_on_help = Column(Boolean, default=False)