uchill/backend/update_plans.py

90 lines
3.3 KiB
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
Скрипт для обновления тарифных планов
"""
import os
import django
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
django.setup()
from apps.subscriptions.models import SubscriptionPlan
# Обновляем бесплатный план
free_plan = SubscriptionPlan.objects.get(name='Бесплатно')
free_plan.max_clients = 3
free_plan.max_lessons_per_month = 10
free_plan.trial_days = 30
free_plan.allow_video_calls = False
free_plan.allow_whiteboard = False
free_plan.allow_analytics = False
free_plan.allow_telegram_bot = True
free_plan.allow_homework = True
free_plan.allow_materials = True
free_plan.description = 'Базовый функционал для начала работы'
free_plan.billing_period = 'monthly'
free_plan.save()
print(f"✅ Обновлен план: {free_plan.name}")
# Обновляем про план
pro_plan = SubscriptionPlan.objects.get(name='Про')
pro_plan.max_clients = 10
pro_plan.max_lessons_per_month = 100
pro_plan.trial_days = 7
pro_plan.allow_video_calls = True
pro_plan.allow_whiteboard = True
pro_plan.allow_analytics = True
pro_plan.allow_telegram_bot = True
pro_plan.allow_homework = True
pro_plan.allow_materials = True
pro_plan.allow_screen_sharing = True
pro_plan.description = 'Полный доступ ко всем функциям платформы'
pro_plan.billing_period = 'monthly'
pro_plan.save()
print(f"✅ Обновлен план: {pro_plan.name}")
# Создадим еще один план - Премиум
premium_plan, created = SubscriptionPlan.objects.get_or_create(
name='Премиум',
defaults={
'slug': 'premium',
'description': 'Для профессиональных менторов с большой базой учеников',
'price': 1200,
'max_clients': 50,
'max_lessons_per_month': None, # Безлимит
'trial_days': 14,
'allow_video_calls': True,
'allow_whiteboard': True,
'allow_analytics': True,
'allow_telegram_bot': True,
'allow_homework': True,
'allow_materials': True,
'allow_screen_sharing': True,
'allow_api_access': True,
'is_active': True,
'is_featured': True,
'sort_order': 3,
'billing_period': 'monthly',
}
)
if created:
print(f"✅ Создан план: {premium_plan.name}")
else:
print(f" План уже существует: {premium_plan.name}")
print("\n📊 Все тарифные планы:")
for plan in SubscriptionPlan.objects.all().order_by('price'):
print(f"\n{plan.name} - {plan.price}")
print(f" Биллинг: {plan.get_billing_period_display()}")
print(f" Учеников: {plan.max_clients if plan.max_clients else 'Безлимит'}")
print(f" Занятий/мес: {plan.max_lessons_per_month if plan.max_lessons_per_month else 'Безлимит'}")
features = []
if plan.allow_video_calls:
features.append('Видеозвонки')
if plan.allow_whiteboard:
features.append('Доска')
if plan.allow_analytics:
features.append('Аналитика')
if plan.allow_telegram_bot:
features.append('Telegram')
print(f" Функции: {', '.join(features)}")