production-taskbar / backend / informing / migrations / 0001_initial.py
0001_initial.py
Raw
# Generated by Django 3.2.12 on 2022-04-02 13:20

import ckeditor_uploader.fields
import datetime
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('taskbar', '0010_auto_20220402_1620'),
    ]

    operations = [
        migrations.CreateModel(
            name='Notification',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=40, verbose_name='Назва сповіщення')),
                ('description', models.CharField(blank=True, default='', max_length=200, verbose_name='Опис')),
                ('is_active', models.BooleanField(default=True, verbose_name='Активне')),
                ('need_confirmation', models.BooleanField(default=False, verbose_name='Потрібне підтвердження перегляду працівником')),
                ('interval', models.IntegerField(blank=True, help_text='Періодичність оповіщення в хв (10-500).<br/>Якщо обрані зміни то рахується від початку зміни.', null=True, validators=[django.core.validators.MaxValueValidator(500), django.core.validators.MinValueValidator(10)], verbose_name='Інтервал')),
                ('show_on_shift_start', models.IntegerField(blank=True, help_text='Від 0 до 30 хв, показати на початку зміни з затримкою', null=True, validators=[django.core.validators.MaxValueValidator(30), django.core.validators.MinValueValidator(0)], verbose_name='Показувати на початку зміни')),
                ('show_on_shift_end', models.IntegerField(blank=True, help_text='Від 0 до 30 хв, показати перед кінцем зміни', null=True, validators=[django.core.validators.MaxValueValidator(30), django.core.validators.MinValueValidator(0)], verbose_name='Показувати в кінці зміни')),
                ('start_datetime', models.DateTimeField(default=datetime.datetime.now, null=True, verbose_name='Показувати з')),
                ('expires_datetime', models.DateTimeField(blank=True, null=True, verbose_name='Показувати по')),
                ('one_off', models.BooleanField(default=False, help_text='Запустити лише раз', verbose_name='Одноразове сповіщення')),
                ('last_run_at', models.DateTimeField(blank=True, editable=False, null=True, verbose_name='Востаннє показувалось')),
                ('content', ckeditor_uploader.fields.RichTextUploadingField(blank=True)),
                ('location', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='taskbar.location')),
            ],
            options={
                'verbose_name': 'сповіщення',
                'verbose_name_plural': '1. Сповіщення',
                'ordering': ['-id'],
            },
        ),
        migrations.CreateModel(
            name='Weekday',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=15)),
                ('number', models.PositiveSmallIntegerField()),
            ],
            options={
                'ordering': ['id'],
                'unique_together': {('name', 'number')},
            },
        ),
        migrations.CreateModel(
            name='Shift',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=40)),
                ('start_time', models.TimeField(null=True)),
                ('end_time', models.TimeField(null=True)),
                ('is_active', models.BooleanField(default=True)),
                ('location', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='taskbar.location')),
                ('weekdays', models.ManyToManyField(to='informing.Weekday')),
            ],
            options={
                'verbose_name_plural': '3. Зміни',
                'ordering': ['-id'],
                'unique_together': {('name', 'location')},
            },
        ),
        migrations.CreateModel(
            name='OrganizationalUnit',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=40)),
                ('description', models.CharField(blank=True, default='', max_length=200)),
                ('location', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='taskbar.location')),
                ('parent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='informing.organizationalunit')),
                ('workplaces', models.ManyToManyField(blank=True, to='taskbar.Workplace')),
            ],
            options={
                'verbose_name_plural': '4. Дільниці',
                'ordering': ['-id'],
                'unique_together': {('name', 'location')},
            },
        ),
        migrations.CreateModel(
            name='NotificationConfirmation',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('user_id', models.PositiveIntegerField()),
                ('datetime', models.DateTimeField(auto_now_add=True)),
                ('notification', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='informing.notification')),
            ],
            options={
                'verbose_name_plural': '2. Підтведження перегляду сповіщення',
                'ordering': ['-id'],
            },
        ),
        migrations.AddField(
            model_name='notification',
            name='recipients',
            field=models.ManyToManyField(blank=True, help_text='Оберіть отримувача по дільницям, для яких буде сповіщення, або лишіть порожнім для оповіщення всієї локації.<br/>', related_name='recipients_notification', to='informing.OrganizationalUnit', verbose_name='Отримувач'),
        ),
        migrations.AddField(
            model_name='notification',
            name='shifts',
            field=models.ManyToManyField(blank=True, help_text='Оберіть зміни, для яких буде сповіщення, або лишіть порожнім для оповіщення на протязи доби.<br/>', to='informing.Shift', verbose_name='зміни'),
        ),
        migrations.AlterUniqueTogether(
            name='notification',
            unique_together={('name',)},
        ),
    ]