51 lines
2.3 KiB
Python
51 lines
2.3 KiB
Python
# Generated by Django 4.2.7 on 2024-05-03 21:02
|
|
|
|
from django.conf import settings
|
|
from django.db import migrations, models
|
|
import django.db.models.deletion
|
|
|
|
from notifications.defaults import auto_reply_body, new_issue_notification, reply_issue_notification
|
|
from notifications.models import MessageTemplate
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
initial = True
|
|
|
|
dependencies = [
|
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
]
|
|
|
|
def create_required_templates(apps, schema_editor):
|
|
MessageTemplate.objects.create(name='auto_reply', message=auto_reply_body, marked_required=True)
|
|
MessageTemplate.objects.create(name='new_issue_notification', message=new_issue_notification,
|
|
marked_required=True)
|
|
MessageTemplate.objects.create(name='reply_issue_notification', message=reply_issue_notification,
|
|
marked_required=True)
|
|
|
|
operations = [
|
|
migrations.CreateModel(
|
|
name='MessageTemplate',
|
|
fields=[
|
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('name', models.CharField(max_length=255)),
|
|
('message', models.TextField()),
|
|
('created', models.DateTimeField(auto_now_add=True)),
|
|
('marked_confidential', models.BooleanField(default=False)),
|
|
('marked_required', models.BooleanField(default=False)),
|
|
],
|
|
),
|
|
migrations.CreateModel(
|
|
name='UserNotificationChannel',
|
|
fields=[
|
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('channel_type',
|
|
models.CharField(choices=[('telegram', 'telegram'), ('email', 'email')], max_length=255)),
|
|
('channel_target', models.CharField(max_length=255)),
|
|
('event_filter', models.CharField(max_length=255)),
|
|
('active', models.BooleanField(default=True)),
|
|
('created', models.DateTimeField(auto_now_add=True)),
|
|
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
|
],
|
|
),
|
|
migrations.RunPython(create_required_templates),
|
|
]
|