All checks were successful
Build and Push Docker Image / build (push) Successful in 1m5s
295 lines
20 KiB
Python
295 lines
20 KiB
Python
# Generated by Django 6.0.1 on 2026-05-11 20:32
|
|
|
|
import django.utils.timezone
|
|
import uuid
|
|
from django.db import migrations, models
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
initial = True
|
|
|
|
dependencies = [
|
|
]
|
|
|
|
operations = [
|
|
migrations.CreateModel(
|
|
name='User',
|
|
fields=[
|
|
('password', models.CharField(max_length=128, verbose_name='password')),
|
|
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
|
|
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
|
|
('first_name', models.CharField(blank=True, max_length=150, verbose_name='first name')),
|
|
('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')),
|
|
('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
|
|
('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
|
|
('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)),
|
|
('email', models.EmailField(max_length=254, unique=True)),
|
|
('username', models.CharField(blank=True, default='', max_length=150)),
|
|
('phone', models.CharField(blank=True, max_length=20)),
|
|
('employee_id', models.CharField(blank=True, max_length=50)),
|
|
('avatar', models.ImageField(blank=True, null=True, upload_to='avatars/')),
|
|
('bio', models.TextField(blank=True)),
|
|
('language', models.CharField(choices=[('en', 'English'), ('ar', 'Arabic')], default='en', max_length=5)),
|
|
('notification_email_enabled', models.BooleanField(default=True, help_text='Enable email notifications')),
|
|
('notification_sms_enabled', models.BooleanField(default=False, help_text='Enable SMS notifications')),
|
|
('preferred_notification_channel', models.CharField(choices=[('email', 'Email'), ('sms', 'SMS'), ('both', 'Both')], default='email', help_text='Preferred notification channel for general notifications', max_length=10)),
|
|
('explanation_notification_channel', models.CharField(choices=[('email', 'Email'), ('sms', 'SMS'), ('both', 'Both')], default='email', help_text='Preferred channel for explanation requests', max_length=10)),
|
|
('is_active', models.BooleanField(default=True)),
|
|
('is_provisional', models.BooleanField(default=False, help_text='User is in onboarding process')),
|
|
('invitation_token', models.CharField(blank=True, help_text='Token for account activation', max_length=100, null=True, unique=True)),
|
|
('invitation_expires_at', models.DateTimeField(blank=True, help_text='When the invitation token expires', null=True)),
|
|
('acknowledgement_completed', models.BooleanField(default=False, help_text='User has completed acknowledgement wizard')),
|
|
('acknowledgement_completed_at', models.DateTimeField(blank=True, help_text='When acknowledgement was completed', null=True)),
|
|
('current_wizard_step', models.IntegerField(default=0, help_text='Current step in onboarding wizard')),
|
|
('wizard_completed_steps', models.JSONField(blank=True, default=list, help_text='List of completed wizard step IDs')),
|
|
],
|
|
options={
|
|
'ordering': ['-date_joined'],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name='AcknowledgementCategory',
|
|
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)),
|
|
('name_en', models.CharField(max_length=200)),
|
|
('name_ar', models.CharField(blank=True, help_text='Arabic name', max_length=200)),
|
|
('code', models.CharField(help_text='Unique code (e.g., CLINICS, ADMISSIONS)', max_length=50, unique=True)),
|
|
('description', models.TextField(blank=True, help_text='Category description')),
|
|
('icon', models.CharField(blank=True, help_text="Icon class (e.g., 'building', 'user')", max_length=50)),
|
|
('color', models.CharField(default='#007bbd', help_text='Hex color code', max_length=7)),
|
|
('order', models.IntegerField(default=0, help_text='Display order')),
|
|
('is_active', models.BooleanField(db_index=True, default=True)),
|
|
('is_default', models.BooleanField(default=False, help_text='One of the 14 default categories')),
|
|
],
|
|
options={
|
|
'verbose_name_plural': 'Acknowledgement Categories',
|
|
'ordering': ['order', 'name_en'],
|
|
},
|
|
),
|
|
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)),
|
|
('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)),
|
|
],
|
|
options={
|
|
'ordering': ['category', 'order', 'code'],
|
|
},
|
|
),
|
|
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)),
|
|
('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')),
|
|
('is_active', models.BooleanField(default=True)),
|
|
],
|
|
options={
|
|
'ordering': ['category', 'order', 'code'],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name='ChecklistItemVersion',
|
|
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)),
|
|
('version_number', models.PositiveIntegerField(help_text='Version number (1, 2, 3, ...)')),
|
|
('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)),
|
|
('is_active', models.BooleanField(default=True)),
|
|
('order', models.IntegerField(default=0)),
|
|
('role', models.CharField(blank=True, max_length=50, null=True)),
|
|
('change_reason', models.TextField(blank=True, help_text='Reason for this change')),
|
|
],
|
|
options={
|
|
'verbose_name': 'Checklist Item Version',
|
|
'verbose_name_plural': 'Checklist Item Versions',
|
|
'ordering': ['-version_number'],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name='ContentChangeLog',
|
|
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)),
|
|
('action', models.CharField(choices=[('create', 'Created'), ('update', 'Updated'), ('delete', 'Deleted'), ('activate', 'Activated'), ('deactivate', 'Deactivated'), ('reorder', 'Reordered')], max_length=20)),
|
|
('content_type', models.CharField(choices=[('content', 'Acknowledgement Content'), ('checklist_item', 'Checklist Item')], max_length=20)),
|
|
('object_id', models.CharField(help_text='UUID of the content/checklist item', max_length=50)),
|
|
('object_code', models.CharField(help_text='Human-readable code of the object', max_length=100)),
|
|
('snapshot', models.JSONField(default=dict, help_text='JSON snapshot of the object after change')),
|
|
('changes_summary', models.TextField(blank=True, help_text='Human-readable summary of changes')),
|
|
('ip_address', models.GenericIPAddressField(blank=True, null=True)),
|
|
('user_agent', models.TextField(blank=True)),
|
|
],
|
|
options={
|
|
'verbose_name': 'Content Change Log',
|
|
'verbose_name_plural': 'Content Change Logs',
|
|
'ordering': ['-created_at'],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name='ContentVersion',
|
|
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)),
|
|
('version_number', models.PositiveIntegerField(help_text='Version number (1, 2, 3, ...)')),
|
|
('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)),
|
|
('role', models.CharField(blank=True, max_length=50, null=True)),
|
|
('order', models.IntegerField(default=0)),
|
|
('is_active', models.BooleanField(default=True)),
|
|
('change_reason', models.TextField(blank=True, help_text='Reason for this change')),
|
|
],
|
|
options={
|
|
'verbose_name': 'Content Version',
|
|
'verbose_name_plural': 'Content Versions',
|
|
'ordering': ['-version_number'],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name='EmployeeAcknowledgement',
|
|
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)),
|
|
('sent_at', models.DateTimeField(blank=True, help_text='When acknowledgement was sent to employee', null=True)),
|
|
('is_signed', models.BooleanField(default=False)),
|
|
('signed_at', models.DateTimeField(blank=True, null=True)),
|
|
('signature_name', models.CharField(blank=True, help_text='Name used when signing', max_length=200)),
|
|
('signature_employee_id', models.CharField(blank=True, help_text='Employee ID when signing', max_length=100)),
|
|
('signed_pdf', models.FileField(blank=True, help_text='PDF with employee signature', null=True, upload_to='acknowledgements/signed/%Y/%m/')),
|
|
('ip_address', models.GenericIPAddressField(blank=True, null=True)),
|
|
('user_agent', models.TextField(blank=True)),
|
|
('notes', models.TextField(blank=True, help_text='Admin notes about this acknowledgement')),
|
|
],
|
|
options={
|
|
'verbose_name': 'Employee Acknowledgement',
|
|
'verbose_name_plural': 'Employee Acknowledgements',
|
|
'ordering': ['-sent_at', '-signed_at'],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name='Role',
|
|
fields=[
|
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('name', models.CharField(choices=[('px_admin', 'PX Admin'), ('hospital_admin', 'Hospital Admin'), ('department_manager', 'Department Manager'), ('director', 'Director'), ('champion', 'Champion'), ('px_management', 'PX Management'), ('px_employee', 'PX Employee'), ('staff', 'Staff'), ('viewer', 'Viewer'), ('executive', 'Executive')], max_length=50, unique=True)),
|
|
('display_name', models.CharField(max_length=100)),
|
|
('description', models.TextField(blank=True)),
|
|
('level', models.IntegerField(default=0, help_text='Higher number = higher authority')),
|
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
|
('updated_at', models.DateTimeField(auto_now=True)),
|
|
],
|
|
options={
|
|
'ordering': ['-level', 'name'],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name='SimpleAcknowledgement',
|
|
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)),
|
|
('title', models.CharField(help_text='Acknowledgement title', max_length=200)),
|
|
('description', models.TextField(blank=True, help_text='Detailed description')),
|
|
('pdf_document', models.FileField(blank=True, help_text='PDF document for employees to review', null=True, upload_to='acknowledgements/documents/')),
|
|
('is_active', models.BooleanField(default=True, help_text='Show in employee checklist')),
|
|
('is_required', models.BooleanField(default=True, help_text='Must be signed by all employees')),
|
|
('order', models.IntegerField(default=0)),
|
|
],
|
|
options={
|
|
'verbose_name': 'Acknowledgement',
|
|
'verbose_name_plural': 'Acknowledgements',
|
|
'ordering': ['order', 'title'],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name='StaffActivityLog',
|
|
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)),
|
|
('activity_type', models.CharField(choices=[('login', 'Login'), ('logout', 'Logout'), ('create', 'Create'), ('update', 'Update'), ('delete', 'Delete'), ('view', 'View'), ('assign', 'Assign'), ('transfer', 'Transfer'), ('send', 'Send'), ('approve', 'Approve'), ('reject', 'Reject'), ('resolve', 'Resolve'), ('reopen', 'Reopen'), ('export', 'Export'), ('analyze', 'Analyze')], db_index=True, max_length=20)),
|
|
('description', models.TextField(blank=True)),
|
|
('object_id', models.UUIDField(blank=True, null=True)),
|
|
('module', models.CharField(blank=True, help_text='App/module name (e.g., complaints, surveys)', max_length=50)),
|
|
('action', models.CharField(blank=True, help_text='Specific action identifier', max_length=100)),
|
|
('ip_address', models.GenericIPAddressField(blank=True, null=True)),
|
|
('user_agent', models.TextField(blank=True)),
|
|
('metadata', models.JSONField(blank=True, default=dict)),
|
|
],
|
|
options={
|
|
'verbose_name': 'Staff Activity Log',
|
|
'verbose_name_plural': 'Staff Activity Logs',
|
|
'ordering': ['-created_at'],
|
|
},
|
|
),
|
|
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')),
|
|
('pdf_file', models.FileField(blank=True, help_text='PDF document of signed acknowledgement', null=True, upload_to='acknowledgements/pdfs/')),
|
|
('metadata', models.JSONField(blank=True, default=dict, help_text='Additional metadata')),
|
|
],
|
|
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')),
|
|
],
|
|
options={
|
|
'ordering': ['-created_at'],
|
|
},
|
|
),
|
|
]
|