feat: add address for order

This commit is contained in:
Vlad Stan 2023-03-06 18:07:52 +02:00
parent 1b317b1b9b
commit da41ed3651
3 changed files with 6 additions and 4 deletions

View file

@ -318,14 +318,15 @@ async def delete_product(user_id: str, product_id: str) -> None:
async def create_order(user_id: str, o: Order) -> Order:
await db.execute(
f"""
INSERT INTO nostrmarket.orders (user_id, id, event_id, pubkey, contact_data, order_items, invoice_id, total)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
INSERT INTO nostrmarket.orders (user_id, id, event_id, pubkey, address, contact_data, order_items, invoice_id, total)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
""",
(
user_id,
o.id,
o.event_id,
o.pubkey,
o.address,
json.dumps(o.contact.dict() if o.contact else {}),
json.dumps([i.dict() for i in o.items]),
o.invoice_id,

View file

@ -78,9 +78,10 @@ async def m001_initial(db):
user_id TEXT NOT NULL,
id TEXT PRIMARY KEY,
event_id TEXT,
pubkey TEXT,
pubkey EXT NOT NULL,
contact_data TEXT NOT NULL DEFAULT '{empty_object}',
order_items TEXT NOT NULL,
address TEXT,
total REAL NOT NULL,
invoice_id TEXT NOT NULL,
paid BOOLEAN NOT NULL DEFAULT false,

View file

@ -256,7 +256,6 @@ class OrderContact(BaseModel):
nostr: Optional[str]
phone: Optional[str]
email: Optional[str]
address: Optional[str]
class PartialOrder(BaseModel):
@ -265,6 +264,7 @@ class PartialOrder(BaseModel):
pubkey: str
items: List[OrderItem]
contact: Optional[OrderContact]
address: Optional[str]
def validate_order(self):
assert len(self.items) != 0, f"Order has no items. Order: '{self.id}'"