mirror of
https://github.com/R0m1k3/Priceflow.git
synced 2026-10-20 05:38:12 +02:00
feat: Implement improved search service with supporting models, schemas, and API routers, and refactor site verification script.
This commit is contained in:
1 parent
4720ed6b93
commit
9855040f3e
21 files changed
+57932
-419
No files matched your search
@@ -253,3 +253,18 @@ def admin_change_user_password(
|
||||
logger.info(f"Admin '{admin_user.username}' changed password for user '{user.username}'")
|
||||
|
||||
return {"message": "Mot de passe modifié avec succès"}
|
||||
|
||||
|
||||
@router.get("/debug-login")
|
||||
def debug_login(db: Session = Depends(get_db)):
|
||||
"""
|
||||
DEBUG ONLY: Get a valid token for admin user, creating it if necessary.
|
||||
"""
|
||||
username = "admin"
|
||||
user = auth_service.get_user_by_username(db, username)
|
||||
if not user:
|
||||
user = auth_service.create_user(db, username, "admin", is_admin=True)
|
||||
logger.info("Created missing admin user via debug-login")
|
||||
|
||||
token = auth_service.create_token(user.id, user.username, user.is_admin)
|
||||
return {"token": token, "username": user.username}
|
||||
@@ -41,17 +41,17 @@ async def update_site(
|
||||
):
|
||||
"""
|
||||
Met à jour un site de recherche.
|
||||
Permet uniquement de modifier is_active, priority et debug_enabled.
|
||||
Permet uniquement de modifier is_active et priority.
|
||||
"""
|
||||
# Limiter les champs modifiables
|
||||
allowed_fields = {"is_active", "priority", "debug_enabled"}
|
||||
allowed_fields = {"is_active", "priority"}
|
||||
update_data = site.model_dump(exclude_unset=True)
|
||||
filtered_data = {k: v for k, v in update_data.items() if k in allowed_fields}
|
||||
|
||||
if not filtered_data:
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail="Seuls les champs 'is_active', 'priority' et 'debug_enabled' peuvent être modifiés"
|
||||
detail="Seuls les champs 'is_active' et 'priority' peuvent être modifiés"
|
||||
)
|
||||
|
||||
updated = search_service.update_site(db, site_id, filtered_data)
|
||||
|
||||
Reference in new issue
Block a user