Initial commit

This commit is contained in:
belviskhoremk
2026-03-06 22:57:58 +00:00
commit c4d836a0f9
60 changed files with 5423 additions and 0 deletions

70
scripts/seed.py Normal file
View File

@@ -0,0 +1,70 @@
"""Seed script — creates an admin user and sample data via Supabase Auth.
Usage:
python -m scripts.seed
"""
import os
import sys
# Add project root to path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from dotenv import load_dotenv
load_dotenv()
from app.core.supabase import get_supabase_admin
def _create_user(db, email: str, password: str, name: str, role: str, with_agency: bool = False):
"""Create a Supabase Auth user + profile row. Skip if already exists."""
existing = db.table("users").select("id").eq("email", email).execute()
if existing.data:
print(f" User already exists: {email}")
return
auth_response = db.auth.admin.create_user({
"email": email,
"password": password,
"email_confirm": True,
})
user_id = auth_response.user.id
db.table("users").insert({
"id": user_id,
"email": email,
"name": name,
"role": role,
"verified": True,
}).execute()
if with_agency:
db.table("agencies").insert({
"user_id": user_id,
"name": "Demo Real Estate Agency",
"description": "A demo agency for testing the platform.",
"address": "123 Demo Street, Lomé, Togo",
"phone": "+228 90 00 00 00",
"email": email,
"website": "https://demo-agency.deals24togo.com",
"verified": True,
}).execute()
print(f"✅ Created {role}: {email} / {password}")
def seed():
db = get_supabase_admin()
_create_user(db, "admin@deals24togo.com", "admin123456", "Admin", "admin")
_create_user(db, "agency@deals24togo.com", "agency123456", "Demo Agency", "agency", with_agency=True)
_create_user(db, "visitor@deals24togo.com", "visitor123456", "Demo Visitor", "visitor")
print("\n🎉 Seeding complete!")
print(" Admin: admin@deals24togo.com / admin123456")
print(" Agency: agency@deals24togo.com / agency123456")
print(" Visitor: visitor@deals24togo.com / visitor123456")
if __name__ == "__main__":
seed()