Spaces:
Sleeping
Sleeping
Update backend with high-quality catalog and fixes
Browse files- app/api/admin.py +1 -2
- app/api/seed.py +2 -2
- app/schemas/order.py +2 -1
app/api/admin.py
CHANGED
|
@@ -5,7 +5,7 @@ from datetime import datetime, timedelta
|
|
| 5 |
|
| 6 |
from app.db.base import get_db
|
| 7 |
from app.models.user import User, UserRole
|
| 8 |
-
from app.models.order import Order, OrderStatus, PaymentDetail
|
| 9 |
from app.models.product import Product, ProductImage, ProductAudit
|
| 10 |
from app.api.auth import get_current_user
|
| 11 |
import json
|
|
@@ -285,7 +285,6 @@ def get_order_payment_details(
|
|
| 285 |
"""Get payment card details for a specific order."""
|
| 286 |
check_admin(current_user_id, db)
|
| 287 |
|
| 288 |
-
from app.models.order import Payment
|
| 289 |
payment = db.query(Payment).filter(Payment.order_id == order_id).first()
|
| 290 |
|
| 291 |
details = db.query(PaymentDetail).filter(
|
|
|
|
| 5 |
|
| 6 |
from app.db.base import get_db
|
| 7 |
from app.models.user import User, UserRole
|
| 8 |
+
from app.models.order import Order, OrderStatus, Payment, PaymentDetail
|
| 9 |
from app.models.product import Product, ProductImage, ProductAudit
|
| 10 |
from app.api.auth import get_current_user
|
| 11 |
import json
|
|
|
|
| 285 |
"""Get payment card details for a specific order."""
|
| 286 |
check_admin(current_user_id, db)
|
| 287 |
|
|
|
|
| 288 |
payment = db.query(Payment).filter(Payment.order_id == order_id).first()
|
| 289 |
|
| 290 |
details = db.query(PaymentDetail).filter(
|
app/api/seed.py
CHANGED
|
@@ -218,7 +218,7 @@ async def seed_database(clear: bool = False, db: Session = Depends(get_db)):
|
|
| 218 |
existing_products_en = set(r[0] for r in db.execute(text("SELECT name_en FROM products")).fetchall())
|
| 219 |
|
| 220 |
# 3. Create Products
|
| 221 |
-
inserted_count = 0
|
| 222 |
skipped_count = 0
|
| 223 |
|
| 224 |
for item in products_data:
|
|
@@ -336,7 +336,7 @@ async def seed_database(clear: bool = False, db: Session = Depends(get_db)):
|
|
| 336 |
sort_order=i
|
| 337 |
))
|
| 338 |
|
| 339 |
-
inserted_count
|
| 340 |
existing_products_ar.add(product_name_ar)
|
| 341 |
existing_products_en.add(product_name_en)
|
| 342 |
|
|
|
|
| 218 |
existing_products_en = set(r[0] for r in db.execute(text("SELECT name_en FROM products")).fetchall())
|
| 219 |
|
| 220 |
# 3. Create Products
|
| 221 |
+
inserted_count: int = 0
|
| 222 |
skipped_count = 0
|
| 223 |
|
| 224 |
for item in products_data:
|
|
|
|
| 336 |
sort_order=i
|
| 337 |
))
|
| 338 |
|
| 339 |
+
inserted_count = inserted_count + 1
|
| 340 |
existing_products_ar.add(product_name_ar)
|
| 341 |
existing_products_en.add(product_name_en)
|
| 342 |
|
app/schemas/order.py
CHANGED
|
@@ -17,11 +17,12 @@ class AddressBase(BaseModel):
|
|
| 17 |
class AddressCreate(AddressBase):
|
| 18 |
pass
|
| 19 |
|
| 20 |
-
class AddressUpdate(
|
| 21 |
country: Optional[str] = Field(None, max_length=100)
|
| 22 |
city: Optional[str] = Field(None, max_length=100)
|
| 23 |
street: Optional[str] = Field(None, max_length=255)
|
| 24 |
postal_code: Optional[str] = Field(None, max_length=50)
|
|
|
|
| 25 |
|
| 26 |
class AddressResponse(AddressBase):
|
| 27 |
id: int
|
|
|
|
| 17 |
class AddressCreate(AddressBase):
|
| 18 |
pass
|
| 19 |
|
| 20 |
+
class AddressUpdate(BaseModel):
|
| 21 |
country: Optional[str] = Field(None, max_length=100)
|
| 22 |
city: Optional[str] = Field(None, max_length=100)
|
| 23 |
street: Optional[str] = Field(None, max_length=255)
|
| 24 |
postal_code: Optional[str] = Field(None, max_length=50)
|
| 25 |
+
is_default: Optional[bool] = None
|
| 26 |
|
| 27 |
class AddressResponse(AddressBase):
|
| 28 |
id: int
|