Files
igny8/backend/update_free_plan.py
2025-11-09 10:27:02 +00:00

61 lines
2.1 KiB
Python

#!/usr/bin/env python
"""
Script to fix and update the Free plan with proper values.
"""
import os
import django
import sys
# Setup Django
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'igny8_core.settings')
django.setup()
from igny8_core.auth.models import Plan
from decimal import Decimal
def update_free_plan():
"""Update the Free plan with proper values and fix JSON fields."""
try:
free_plan = Plan.objects.get(slug='free')
print(f"Found Free plan: {free_plan.name}")
print("Updating values...")
# Update free plan values - keeping existing values but fixing JSON fields
# Fix JSON fields - use proper Python lists/dicts
free_plan.image_model_choices = [] # Empty list for free plan (no image generation)
# Ensure features is a proper list (not dict)
if isinstance(free_plan.features, dict):
free_plan.features = []
elif not isinstance(free_plan.features, list):
free_plan.features = []
# Save the plan
free_plan.save()
print("✅ Successfully updated Free plan!")
print(f" - Image Model Choices: {free_plan.image_model_choices}")
print(f" - Features: {free_plan.features}")
print(f" - Max Sites: {free_plan.max_sites}")
print(f" - Max Users: {free_plan.max_users}")
print(f" - Max Keywords: {free_plan.max_keywords}")
print(f" - Max Clusters: {free_plan.max_clusters}")
print(f" - Max Content Ideas: {free_plan.max_content_ideas}")
print(f" - Monthly AI Credits: {free_plan.monthly_ai_credit_limit}")
print(f" - Daily AI Request Limit: {free_plan.daily_ai_request_limit}")
print(f" - Daily Image Generation Limit: {free_plan.daily_image_generation_limit}")
except Plan.DoesNotExist:
print("❌ Free plan not found!")
sys.exit(1)
except Exception as e:
print(f"❌ Error updating free plan: {e}")
import traceback
traceback.print_exc()
sys.exit(1)
if __name__ == '__main__':
update_free_plan()