seed_portfolio.py 927 B

123456789101112131415161718192021222324252627
  1. import db
  2. import os
  3. def seed_portfolio():
  4. print("Seeding portfolio...")
  5. # Portfolio items are order_photos with is_public = TRUE
  6. # Since they don't necessarily need an order, we can set order_id to NULL
  7. # But let's check if the table allows it
  8. portfolio_items = [
  9. {"path": "/uploads/portfolio/gear.png"},
  10. {"path": "/uploads/portfolio/villa.png"},
  11. {"path": "/uploads/portfolio/warrior.png"}
  12. ]
  13. for item in portfolio_items:
  14. # Check if already exists
  15. exists = db.execute_query("SELECT id FROM order_photos WHERE file_path = %s", (item["path"],))
  16. if not exists:
  17. db.execute_commit(
  18. "INSERT INTO order_photos (order_id, file_path, is_public) VALUES (NULL, %s, TRUE)",
  19. (item["path"],)
  20. )
  21. print(f"Added {item['path']} to portfolio")
  22. if __name__ == "__main__":
  23. seed_portfolio()