You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
208 lines
13 KiB
208 lines
13 KiB
from django.core.management.base import BaseCommand
|
|
from apps.account.models import NotificationTemplate
|
|
|
|
class Command(BaseCommand):
|
|
help = 'Seeds default NotificationTemplate records in the database with RU and EN translations.'
|
|
|
|
def handle(self, *args, **options):
|
|
default_templates = [
|
|
{
|
|
"notification_type": "course_access_granted",
|
|
"name": "Доступ к курсу активирован",
|
|
"title_ru": "Доступ к курсу активирован",
|
|
"title_en": "Course Access Granted",
|
|
"body_ru": "Ваш доступ к курсу «{course_title}» успешно активирован.",
|
|
"body_en": "Your access to the course '{course_title}' has been activated.",
|
|
"placeholders_info": "{course_title}, {course_name}, {course_slug}, {student_name}, {fullname}"
|
|
},
|
|
{
|
|
"notification_type": "course_registered",
|
|
"name": "Регистрация на курс",
|
|
"title_ru": "Успешная регистрация на курс",
|
|
"title_en": "Course Registration Successful",
|
|
"body_ru": "Вы успешно зарегистрировались на курс «{course_title}».",
|
|
"body_en": "You have successfully registered for the course '{course_title}'.",
|
|
"placeholders_info": "{course_title}, {course_name}, {course_slug}, {student_name}, {fullname}"
|
|
},
|
|
{
|
|
"notification_type": "lesson_completed",
|
|
"name": "Урок завершен",
|
|
"title_ru": "Урок завершен",
|
|
"title_en": "Lesson Completed",
|
|
"body_ru": "Поздравляем! Вы завершили изучение урока «{lesson_title}».",
|
|
"body_en": "Congratulations! You completed the lesson '{lesson_title}'.",
|
|
"placeholders_info": "{course_title}, {course_name}, {lesson_title}, {student_name}, {fullname}"
|
|
},
|
|
{
|
|
"notification_type": "course_completed",
|
|
"name": "Курс завершен",
|
|
"title_ru": "Курс завершен",
|
|
"title_en": "Course Completed",
|
|
"body_ru": "Отличная работа! Вы успешно завершили курс «{course_title}».",
|
|
"body_en": "Well done! You have completed the course '{course_title}'.",
|
|
"placeholders_info": "{course_title}, {course_name}, {course_slug}, {student_name}, {fullname}"
|
|
},
|
|
{
|
|
"notification_type": "new_course_weekly",
|
|
"name": "Новый курс за неделю",
|
|
"title_ru": "Добавлен новый курс",
|
|
"title_en": "New Course Registered",
|
|
"body_ru": "Зарегистрирован новый курс «{course_title}». Вы можете записаться прямо сейчас.",
|
|
"body_en": "A new course '{course_title}' has been registered. You can enroll now.",
|
|
"placeholders_info": "{course_title}, {course_name}, {course_slug}"
|
|
},
|
|
{
|
|
"notification_type": "low_quiz_result",
|
|
"name": "Предложение пересдать тест",
|
|
"title_ru": "Предложение пересдать тест",
|
|
"title_en": "Quiz Retake Suggestion",
|
|
"body_ru": "Вы набрали балл ниже проходного в тесте «{quiz_title}». Рекомендуем пройти его повторно.",
|
|
"body_en": "You scored below the passing threshold on quiz '{quiz_title}'. We suggest taking it again.",
|
|
"placeholders_info": "{quiz_title}, {student_name}, {fullname}"
|
|
},
|
|
{
|
|
"notification_type": "live_class_rescheduled",
|
|
"name": "Время живого урока изменено",
|
|
"title_ru": "Время живого урока изменено",
|
|
"title_en": "Live Class Rescheduled",
|
|
"body_ru": "Время проведения живого урока по курсу «{course_title}» было изменено.",
|
|
"body_en": "The live class for '{course_title}' has been rescheduled.",
|
|
"placeholders_info": "{course_title}, {course_name}, {session_subject}, {session_start_time}"
|
|
},
|
|
{
|
|
"notification_type": "live_class_cancelled",
|
|
"name": "Живой урок отменен",
|
|
"title_ru": "Живой урок отменен",
|
|
"title_en": "Live Class Cancelled",
|
|
"body_ru": "Живой урок по курсу «{course_title}» был отменен.",
|
|
"body_en": "The live class for '{course_title}' has been cancelled.",
|
|
"placeholders_info": "{course_title}, {course_name}, {session_subject}"
|
|
},
|
|
{
|
|
"notification_type": "live_recording_available",
|
|
"name": "Доступна запись живого урока",
|
|
"title_ru": "Доступна запись урока",
|
|
"title_en": "Live Recording Available",
|
|
"body_ru": "Запись живого урока по курсу «{course_title}» уже доступна для просмотра.",
|
|
"body_en": "The recorded video of the live class for '{course_title}' is now available.",
|
|
"placeholders_info": "{course_title}, {course_name}"
|
|
},
|
|
{
|
|
"notification_type": "missed_live_sessions",
|
|
"name": "Пропуск живых уроков",
|
|
"title_ru": "Пропуск живых уроков",
|
|
"title_en": "Missed Live Sessions",
|
|
"body_ru": "Вы пропустили 2 живых урока подряд по курсу «{course_title}». Рекомендуем посмотреть их в записи.",
|
|
"body_en": "You have missed 2 consecutive live sessions in the course '{course_title}'. We recommend watching the recordings.",
|
|
"placeholders_info": "{course_title}, {course_name}, {student_name}, {fullname}"
|
|
},
|
|
{
|
|
"notification_type": "payment_successful",
|
|
"name": "Оплата успешна",
|
|
"title_ru": "Оплата успешна",
|
|
"title_en": "Payment Successful",
|
|
"body_ru": "Ваша оплата за курс «{course_title}» успешно проведена.",
|
|
"body_en": "Your payment for course '{course_title}' was successful.",
|
|
"placeholders_info": "{course_title}, {course_name}, {student_name}, {fullname}"
|
|
},
|
|
{
|
|
"notification_type": "payment_failed",
|
|
"name": "Ошибка оплаты",
|
|
"title_ru": "Ошибка оплаты",
|
|
"title_en": "Payment Failed",
|
|
"body_ru": "Произошла ошибка при обработке вашей оплаты за курс «{course_title}».",
|
|
"body_en": "We encountered an issue processing your payment for '{course_title}'.",
|
|
"placeholders_info": "{course_title}, {course_name}, {student_name}, {fullname}"
|
|
},
|
|
{
|
|
"notification_type": "refund_completed",
|
|
"name": "Возврат средств",
|
|
"title_ru": "Возврат средств выполнен",
|
|
"title_en": "Refund Completed",
|
|
"body_ru": "Возврат средств за курс «{course_title}» успешно завершен.",
|
|
"body_en": "A refund has been successfully completed for the course '{course_title}'.",
|
|
"placeholders_info": "{course_title}, {course_name}, {student_name}, {fullname}"
|
|
},
|
|
{
|
|
"notification_type": "student_inactivity",
|
|
"name": "Мы скучаем по вам",
|
|
"title_ru": "Мы скучаем по вам!",
|
|
"title_en": "We Miss You!",
|
|
"body_ru": "Вы не изучали уроки за последнюю неделю. Ждем вас для продолжения обучения!",
|
|
"body_en": "You haven't taken any lessons in the last week. Come back and continue your learning journey!",
|
|
"placeholders_info": "{student_name}, {fullname}"
|
|
},
|
|
{
|
|
"notification_type": "teacher_reply",
|
|
"name": "Ответ преподавателя",
|
|
"title_ru": "Новое сообщение от преподавателя",
|
|
"title_en": "New Message from Teacher",
|
|
"body_ru": "Преподаватель ответил на ваше сообщение.",
|
|
"body_en": "The teacher has replied to your message.",
|
|
"placeholders_info": "{student_name}, {fullname}"
|
|
},
|
|
{
|
|
"notification_type": "teacher_reply_private",
|
|
"name": "Личное сообщение от преподавателя",
|
|
"title_ru": "Новое сообщение от преподавателя",
|
|
"title_en": "New Message from Teacher",
|
|
"body_ru": "Преподаватель ответил на ваше сообщение.",
|
|
"body_en": "The teacher has replied to your message.",
|
|
"placeholders_info": "{student_name}, {fullname}"
|
|
},
|
|
{
|
|
"notification_type": "teacher_reply_course",
|
|
"name": "Сообщение от преподавателя в чате курса",
|
|
"title_ru": "Сообщение от преподавателя в чате курса",
|
|
"title_en": "Teacher Post in Course Chat",
|
|
"body_ru": "Преподаватель опубликовал новое сообщение в чате курса.",
|
|
"body_en": "The teacher posted in the course chat.",
|
|
"placeholders_info": "{course_title}, {course_name}, {student_name}, {fullname}"
|
|
},
|
|
{
|
|
"notification_type": "support_reply",
|
|
"name": "Ответ поддержки",
|
|
"title_ru": "Новое сообщение от поддержки",
|
|
"title_en": "New Message from Support",
|
|
"body_ru": "Служба поддержки ответила на ваше сообщение.",
|
|
"body_en": "The support agent has replied to your message.",
|
|
"placeholders_info": "{student_name}, {fullname}"
|
|
},
|
|
{
|
|
"notification_type": "certificate_issued",
|
|
"name": "Сертификат выдан",
|
|
"title_ru": "Сертификат выдан",
|
|
"title_en": "Certificate Issued",
|
|
"body_ru": "Ваш сертификат по курсу «{course_title}» успешно выпущен.",
|
|
"body_en": "Your certificate for the course '{course_title}' has been issued.",
|
|
"placeholders_info": "{course_title}, {course_name}, {student_name}, {fullname}"
|
|
},
|
|
{
|
|
"notification_type": "live_class_reminder",
|
|
"name": "Напоминание о живом уроке",
|
|
"title_ru": "Напоминание о живом уроке",
|
|
"title_en": "Live Class Reminder",
|
|
"body_ru": "Напоминаем, что живой урок «{session_subject}» начнется в {session_start_time}.",
|
|
"body_en": "Reminder: The live class '{session_subject}' will start at {session_start_time}.",
|
|
"placeholders_info": "{session_subject}, {session_start_time}, {student_name}, {fullname}"
|
|
}
|
|
]
|
|
|
|
count = 0
|
|
for item in default_templates:
|
|
obj, created = NotificationTemplate.objects.update_or_create(
|
|
notification_type=item['notification_type'],
|
|
defaults={
|
|
'name': item['name'],
|
|
'title_ru': item['title_ru'],
|
|
'title_en': item['title_en'],
|
|
'body_ru': item['body_ru'],
|
|
'body_en': item['body_en'],
|
|
'placeholders_info': item['placeholders_info'],
|
|
'is_active': True
|
|
}
|
|
)
|
|
if created:
|
|
count += 1
|
|
|
|
self.stdout.write(self.style.SUCCESS(f"Seeding completed! Created {count} new templates, updated existing ones."))
|