This commit is contained in:
Iliyan Angelov
2025-12-03 01:31:34 +02:00
parent e32527ae8c
commit 5fb50983a9
37 changed files with 5844 additions and 201 deletions

View File

@@ -1,11 +1,13 @@
import sys
import os
from pathlib import Path
# Add both the seeds_data directory and the Backend directory to the path
sys.path.insert(0, str(Path(__file__).parent))
sys.path.insert(0, str(Path(__file__).parent.parent))
from sqlalchemy.orm import Session
from src.shared.config.database import SessionLocal
from src.models.role import Role
from src.models.user import User
from src.auth.models.role import Role
from src.auth.models.user import User
import bcrypt
from datetime import datetime
@@ -25,6 +27,7 @@ def seed_users(db: Session):
admin_role = db.query(Role).filter(Role.name == 'admin').first()
staff_role = db.query(Role).filter(Role.name == 'staff').first()
customer_role = db.query(Role).filter(Role.name == 'customer').first()
housekeeping_role = db.query(Role).filter(Role.name == 'housekeeping').first()
if not admin_role or not staff_role or not customer_role:
print(' ❌ Roles not found! Please seed roles first.')
@@ -105,12 +108,38 @@ def seed_users(db: Session):
}
]
# Add housekeeping users if role exists
if housekeeping_role:
users_data.extend([
{
'email': 'housekeeping@gnxsoft.com',
'password': 'housekeeping123',
'full_name': 'Housekeeping Staff',
'phone': '+1 (555) 999-0000',
'role': 'housekeeping',
'currency': 'EUR',
'is_active': True
},
{
'email': 'housekeeping2@gnxsoft.com',
'password': 'housekeeping123',
'full_name': 'Housekeeping Staff 2',
'phone': '+1 (555) 999-0001',
'role': 'housekeeping',
'currency': 'EUR',
'is_active': True
}
])
role_map = {
'admin': admin_role.id,
'staff': staff_role.id,
'customer': customer_role.id
}
if housekeeping_role:
role_map['housekeeping'] = housekeeping_role.id
created_count = 0
skipped_count = 0