refactor: rename Wizamart to Orion across entire codebase
Replace all ~1,086 occurrences of Wizamart/wizamart/WIZAMART/WizaMart with Orion/orion/ORION across 184 files. This includes database identifiers, email addresses, domain references, R2 bucket names, DNS prefixes, encryption salt, Celery app name, config defaults, Docker configs, CI configs, documentation, seed data, and templates. Renames homepage-wizamart.html template to homepage-orion.html. Fixes duplicate file_pattern key in api.yaml architecture rule. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,14 +2,14 @@
|
||||
|
||||
## Overview
|
||||
|
||||
The Wizamart API uses a unified custom exception system to provide consistent, meaningful error responses across all endpoints. This system was redesigned to eliminate competing exception handlers and provide a single source of truth for error handling.
|
||||
The Orion API uses a unified custom exception system to provide consistent, meaningful error responses across all endpoints. This system was redesigned to eliminate competing exception handlers and provide a single source of truth for error handling.
|
||||
|
||||
## Architecture
|
||||
|
||||
### Exception Hierarchy
|
||||
|
||||
```
|
||||
WizamartException (Base)
|
||||
OrionException (Base)
|
||||
├── ValidationException (422)
|
||||
├── AuthenticationException (401)
|
||||
├── AuthorizationException (403)
|
||||
@@ -91,7 +91,7 @@ The system handles four categories of exceptions:
|
||||
```python
|
||||
# app/exceptions/handler.py
|
||||
|
||||
@app.exception_handler(WizamartException)
|
||||
@app.exception_handler(OrionException)
|
||||
async def custom_exception_handler(request, exc):
|
||||
"""Handle all custom business exceptions"""
|
||||
return JSONResponse(
|
||||
@@ -99,7 +99,7 @@ async def custom_exception_handler(request, exc):
|
||||
content=exc.to_dict()
|
||||
)
|
||||
|
||||
@app.exception_handler(HTTPException)
|
||||
@app.exception_handler(HTTPException)
|
||||
async def http_exception_handler(request, exc):
|
||||
"""Handle FastAPI HTTP exceptions"""
|
||||
return JSONResponse(
|
||||
@@ -149,11 +149,11 @@ from app.exceptions.admin import UserNotFoundException, CannotModifySelfExceptio
|
||||
|
||||
def toggle_user_status(self, db: Session, user_id: int, current_admin_id: int):
|
||||
user = self._get_user_by_id_or_raise(db, user_id)
|
||||
|
||||
|
||||
# Prevent self-modification
|
||||
if user.id == current_admin_id:
|
||||
raise CannotModifySelfException(user_id, "deactivate account")
|
||||
|
||||
|
||||
# Prevent admin-to-admin modification
|
||||
if user.role == "admin" and user.id != current_admin_id:
|
||||
raise UserStatusChangeException(
|
||||
@@ -214,7 +214,7 @@ from .base import BusinessLogicException, ResourceNotFoundException
|
||||
|
||||
class PaymentNotFoundException(ResourceNotFoundException):
|
||||
"""Raised when payment record is not found."""
|
||||
|
||||
|
||||
def __init__(self, payment_id: str):
|
||||
super().__init__(
|
||||
resource_type="Payment",
|
||||
@@ -225,7 +225,7 @@ class PaymentNotFoundException(ResourceNotFoundException):
|
||||
|
||||
class InsufficientFundsException(BusinessLogicException):
|
||||
"""Raised when account has insufficient funds."""
|
||||
|
||||
|
||||
def __init__(self, required: float, available: float, account_id: str):
|
||||
super().__init__(
|
||||
message=f"Insufficient funds. Required: {required}, Available: {available}",
|
||||
@@ -246,7 +246,7 @@ from .payment import PaymentNotFoundException, InsufficientFundsException
|
||||
|
||||
__all__ = [
|
||||
# ... existing exports
|
||||
"PaymentNotFoundException",
|
||||
"PaymentNotFoundException",
|
||||
"InsufficientFundsException",
|
||||
]
|
||||
```
|
||||
@@ -259,10 +259,10 @@ from app.exceptions import PaymentNotFoundException, InsufficientFundsException
|
||||
|
||||
def process_payment(self, db: Session, payment_id: str, amount: float):
|
||||
payment = self._get_payment_by_id_or_raise(db, payment_id)
|
||||
|
||||
|
||||
if payment.account_balance < amount:
|
||||
raise InsufficientFundsException(amount, payment.account_balance, payment.account_id)
|
||||
|
||||
|
||||
# Process payment...
|
||||
return payment
|
||||
```
|
||||
@@ -280,7 +280,7 @@ from app.exceptions.admin import UserNotFoundException, CannotModifySelfExceptio
|
||||
|
||||
def test_user_not_found_exception():
|
||||
exc = UserNotFoundException("123")
|
||||
|
||||
|
||||
assert exc.error_code == "USER_NOT_FOUND"
|
||||
assert exc.status_code == 404
|
||||
assert "123" in exc.message
|
||||
@@ -288,7 +288,7 @@ def test_user_not_found_exception():
|
||||
|
||||
def test_cannot_modify_self_exception():
|
||||
exc = CannotModifySelfException(456, "deactivate account")
|
||||
|
||||
|
||||
assert exc.error_code == "CANNOT_MODIFY_SELF"
|
||||
assert exc.status_code == 400
|
||||
assert "deactivate account" in exc.message
|
||||
@@ -303,7 +303,7 @@ Test complete error handling flow:
|
||||
def test_toggle_user_status_cannot_modify_self(client, admin_headers, test_admin):
|
||||
"""Test that admin cannot modify their own account"""
|
||||
response = client.put(
|
||||
f"/api/v1/admin/users/{test_admin.id}/status",
|
||||
f"/api/v1/admin/users/{test_admin.id}/status",
|
||||
headers=admin_headers
|
||||
)
|
||||
|
||||
@@ -352,14 +352,14 @@ def test_get_all_users_non_admin(client, auth_headers):
|
||||
- `INVALID_TOKEN`: Malformed or invalid token
|
||||
- `USER_NOT_ACTIVE`: User account is deactivated
|
||||
|
||||
### Authorization (403)
|
||||
### Authorization (403)
|
||||
- `ADMIN_REQUIRED`: Admin privileges required for operation
|
||||
- `INSUFFICIENT_PERMISSIONS`: User lacks required permissions
|
||||
- `UNAUTHORIZED_SHOP_ACCESS`: Cannot access shop (not owner)
|
||||
|
||||
### Resource Not Found (404)
|
||||
- `USER_NOT_FOUND`: User with specified ID not found
|
||||
- `SHOP_NOT_FOUND`: Shop with specified code/ID not found
|
||||
- `SHOP_NOT_FOUND`: Shop with specified code/ID not found
|
||||
- `PRODUCT_NOT_FOUND`: MarketplaceProduct with specified ID not found
|
||||
|
||||
### Business Logic (400)
|
||||
|
||||
Reference in New Issue
Block a user