# Generated by Django 5.0.14 on 2026-01-06 08:54

import django.db.models.deletion
import uuid
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('accounts', '0002_initial'),
    ]

    operations = [
        migrations.AddField(
            model_name='user',
            name='acknowledgement_completed',
            field=models.BooleanField(default=False, help_text='User has completed acknowledgement wizard'),
        ),
        migrations.AddField(
            model_name='user',
            name='acknowledgement_completed_at',
            field=models.DateTimeField(blank=True, help_text='When the acknowledgement was completed', null=True),
        ),
        migrations.AddField(
            model_name='user',
            name='current_wizard_step',
            field=models.IntegerField(default=0, help_text='Current step in onboarding wizard'),
        ),
        migrations.AddField(
            model_name='user',
            name='invitation_expires_at',
            field=models.DateTimeField(blank=True, help_text='When the invitation token expires', null=True),
        ),
        migrations.AddField(
            model_name='user',
            name='invitation_token',
            field=models.CharField(blank=True, help_text='Token for account activation', max_length=100, null=True, unique=True),
        ),
        migrations.AddField(
            model_name='user',
            name='is_provisional',
            field=models.BooleanField(default=False, help_text='User is in onboarding process'),
        ),
        migrations.AddField(
            model_name='user',
            name='wizard_completed_steps',
            field=models.JSONField(blank=True, default=list, help_text='List of completed wizard step IDs'),
        ),
        migrations.CreateModel(
            name='AcknowledgementContent',
            fields=[
                ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('role', models.CharField(blank=True, choices=[('px_admin', 'PX Admin'), ('hospital_admin', 'Hospital Admin'), ('department_manager', 'Department Manager'), ('px_coordinator', 'PX Coordinator'), ('physician', 'Physician'), ('nurse', 'Nurse'), ('staff', 'Staff'), ('viewer', 'Viewer')], help_text='Target role for this content', max_length=50, null=True)),
                ('code', models.CharField(help_text='Unique code for this content section', max_length=100, unique=True)),
                ('title_en', models.CharField(max_length=200)),
                ('title_ar', models.CharField(blank=True, max_length=200)),
                ('description_en', models.TextField()),
                ('description_ar', models.TextField(blank=True)),
                ('content_en', models.TextField(blank=True)),
                ('content_ar', models.TextField(blank=True)),
                ('icon', models.CharField(blank=True, help_text="Icon class (e.g., 'fa-user', 'fa-shield')", max_length=50)),
                ('color', models.CharField(blank=True, help_text="Hex color code (e.g., '#007bff')", max_length=7)),
                ('order', models.IntegerField(default=0, help_text='Display order in wizard')),
                ('is_active', models.BooleanField(default=True)),
            ],
            options={
                'ordering': ['role', 'order', 'code'],
                'indexes': [models.Index(fields=['role', 'is_active', 'order'], name='accounts_ac_role_6fe1fd_idx'), models.Index(fields=['code'], name='accounts_ac_code_48fa92_idx')],
            },
        ),
        migrations.CreateModel(
            name='AcknowledgementChecklistItem',
            fields=[
                ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('role', models.CharField(blank=True, choices=[('px_admin', 'PX Admin'), ('hospital_admin', 'Hospital Admin'), ('department_manager', 'Department Manager'), ('px_coordinator', 'PX Coordinator'), ('physician', 'Physician'), ('nurse', 'Nurse'), ('staff', 'Staff'), ('viewer', 'Viewer')], help_text='Target role for this item', max_length=50, null=True)),
                ('code', models.CharField(help_text='Unique code for this checklist item', max_length=100, unique=True)),
                ('text_en', models.CharField(max_length=500)),
                ('text_ar', models.CharField(blank=True, max_length=500)),
                ('description_en', models.TextField(blank=True)),
                ('description_ar', models.TextField(blank=True)),
                ('is_required', models.BooleanField(default=True, help_text='Item must be acknowledged')),
                ('order', models.IntegerField(default=0, help_text='Display order in checklist')),
                ('is_active', models.BooleanField(default=True)),
                ('content', models.ForeignKey(blank=True, help_text='Related content section', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='checklist_items', to='accounts.acknowledgementcontent')),
            ],
            options={
                'ordering': ['role', 'order', 'code'],
            },
        ),
        migrations.CreateModel(
            name='UserAcknowledgement',
            fields=[
                ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('is_acknowledged', models.BooleanField(default=True)),
                ('acknowledged_at', models.DateTimeField(auto_now_add=True)),
                ('signature', models.TextField(blank=True, help_text='Digital signature data (base64 encoded)')),
                ('signature_ip', models.GenericIPAddressField(blank=True, help_text='IP address when signed', null=True)),
                ('signature_user_agent', models.TextField(blank=True, help_text='User agent when signed')),
                ('metadata', models.JSONField(blank=True, default=dict, help_text='Additional metadata')),
                ('checklist_item', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user_acknowledgements', to='accounts.acknowledgementchecklistitem')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='acknowledgements', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['-acknowledged_at'],
            },
        ),
        migrations.CreateModel(
            name='UserProvisionalLog',
            fields=[
                ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('event_type', models.CharField(choices=[('created', 'User Created'), ('invitation_sent', 'Invitation Sent'), ('invitation_resent', 'Invitation Resent'), ('wizard_started', 'Wizard Started'), ('step_completed', 'Wizard Step Completed'), ('wizard_completed', 'Wizard Completed'), ('user_activated', 'User Activated'), ('invitation_expired', 'Invitation Expired')], db_index=True, max_length=50)),
                ('description', models.TextField()),
                ('ip_address', models.GenericIPAddressField(blank=True, null=True)),
                ('user_agent', models.TextField(blank=True)),
                ('metadata', models.JSONField(blank=True, default=dict, help_text='Additional event data')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='provisional_logs', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['-created_at'],
            },
        ),
        migrations.AddIndex(
            model_name='acknowledgementchecklistitem',
            index=models.Index(fields=['role', 'is_active', 'order'], name='accounts_ac_role_c556c1_idx'),
        ),
        migrations.AddIndex(
            model_name='acknowledgementchecklistitem',
            index=models.Index(fields=['code'], name='accounts_ac_code_b745de_idx'),
        ),
        migrations.AddIndex(
            model_name='useracknowledgement',
            index=models.Index(fields=['user', '-acknowledged_at'], name='accounts_us_user_id_7ba948_idx'),
        ),
        migrations.AddIndex(
            model_name='useracknowledgement',
            index=models.Index(fields=['checklist_item', '-acknowledged_at'], name='accounts_us_checkli_870e26_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='useracknowledgement',
            unique_together={('user', 'checklist_item')},
        ),
        migrations.AddIndex(
            model_name='userprovisionallog',
            index=models.Index(fields=['user', '-created_at'], name='accounts_us_user_id_c488d5_idx'),
        ),
        migrations.AddIndex(
            model_name='userprovisionallog',
            index=models.Index(fields=['event_type', '-created_at'], name='accounts_us_event_t_b7f691_idx'),
        ),
    ]
