mirror of
https://github.com/Steffo99/greed.git
synced 2024-11-24 06:44:19 +00:00
database.py: Categories implementation
This commit is contained in:
parent
20f62ede25
commit
78cd76b2dc
2 changed files with 15 additions and 0 deletions
BIN
.vs/greed-mastersuv-categories-impl/v16/.suo
Normal file
BIN
.vs/greed-mastersuv-categories-impl/v16/.suo
Normal file
Binary file not shown.
15
database.py
15
database.py
|
@ -92,6 +92,8 @@ class Product(DeferredReflection, TableDeclarativeBase):
|
||||||
|
|
||||||
# Product id
|
# Product id
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
|
# Category id
|
||||||
|
category_id = Column(Integer, ForeignKey("categories.id"))
|
||||||
# Product name
|
# Product name
|
||||||
name = Column(String)
|
name = Column(String)
|
||||||
# Product description
|
# Product description
|
||||||
|
@ -150,6 +152,18 @@ class Product(DeferredReflection, TableDeclarativeBase):
|
||||||
# Store the photo in the database record
|
# Store the photo in the database record
|
||||||
self.image = r.content
|
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):
|
class Transaction(DeferredReflection, TableDeclarativeBase):
|
||||||
"""A greed wallet transaction.
|
"""A greed wallet transaction.
|
||||||
|
@ -209,6 +223,7 @@ class Admin(DeferredReflection, TableDeclarativeBase):
|
||||||
user = relationship("User")
|
user = relationship("User")
|
||||||
# Permissions
|
# Permissions
|
||||||
edit_products = Column(Boolean, default=False)
|
edit_products = Column(Boolean, default=False)
|
||||||
|
edit_categories = Column(Boolean, default=False)
|
||||||
receive_orders = Column(Boolean, default=False)
|
receive_orders = Column(Boolean, default=False)
|
||||||
create_transactions = Column(Boolean, default=False)
|
create_transactions = Column(Boolean, default=False)
|
||||||
display_on_help = Column(Boolean, default=False)
|
display_on_help = Column(Boolean, default=False)
|
||||||
|
|
Loading…
Reference in a new issue