django admin Groups reorg, Frontend udpates for site settings, #Migration runs

This commit is contained in:
IGNY8 VPS (Salman)
2026-01-05 01:21:52 +00:00
parent 6e30d2d4e8
commit dc7a459ebb
39 changed files with 3142 additions and 1589 deletions

View File

@@ -202,9 +202,53 @@ Django Admin
---
## Next Steps (From Original Plan)
## Phase 2: AI Models & Credits Refactor - COMPLETED
### IntegrationProvider Model Created
- New model: `IntegrationProvider` in `modules/system/models.py`
- Centralized storage for ALL external service API keys
- Supports: AI providers, payment gateways, email services, storage
- Migrated OpenAI and Runware API keys from GlobalIntegrationSettings
- Admin interface added in `modules/system/admin.py`
- Added to admin sidebar under "Global Settings"
### AIModelConfig Enhanced
- Added `tokens_per_credit` - for text models (e.g., 1000 tokens = 1 credit)
- Added `credits_per_image` - for image models (e.g., 1, 5, 15 credits)
- Added `quality_tier` - for frontend UI (basic/quality/premium)
- Migration `0025_add_aimodel_credit_fields` adds fields
- Migration `0026_populate_aimodel_credits` sets initial values
### ModelRegistry Updated
- Removed fallback to `constants.py` - database is now authoritative
- Added `get_provider()`, `get_api_key()`, `get_api_secret()`, `get_webhook_secret()`
- Provider caching with TTL
### CreditService Updated
- Added `calculate_credits_for_image(model_name, num_images)` - uses AIModelConfig.credits_per_image
- Added `calculate_credits_from_tokens_by_model(model_name, total_tokens)` - uses AIModelConfig.tokens_per_credit
- Added `deduct_credits_for_image()` - convenience method
### Files Changed (Phase 2)
| File | Change |
|------|--------|
| `modules/system/models.py` | Added IntegrationProvider model |
| `modules/system/admin.py` | Added IntegrationProviderAdmin |
| `business/billing/models.py` | Added tokens_per_credit, credits_per_image, quality_tier to AIModelConfig |
| `business/billing/services/credit_service.py` | Added image/model-based credit calculation |
| `ai/model_registry.py` | Removed constants fallback, added provider methods |
| `ai/ai_core.py` | Use ModelRegistry for API keys, removed constants fallback |
| `ai/constants.py` | Marked MODEL_RATES, IMAGE_MODEL_RATES as DEPRECATED |
| `ai/settings.py` | Use ModelRegistry for model validation |
| `ai/validators.py` | Removed constants fallback |
| `modules/system/integration_views.py` | Use ModelRegistry for cost calculation |
| `modules/billing/serializers.py` | Added new fields to AIModelConfigSerializer |
---
## Next Steps
1.**Django Admin Cleanup** - DONE
2.**Simplify AI Settings** - Merge content + image settings into AccountSettings
3. **Create IntegrationProvider** - Move API keys to dedicated model
4. **AIModelConfig Enhancement** - Add tokens_per_credit, credits_per_image, quality_tier
3. **Create IntegrationProvider** - DONE (API keys now in dedicated model)
4. **AIModelConfig Enhancement** - DONE (tokens_per_credit, credits_per_image, quality_tier added)