# Generated by Django 5.0.14 on 2026-01-08 06:56 import django.core.validators import django.db.models.deletion import uuid from django.conf import settings from django.db import migrations, models class Migration(migrations.Migration): initial = True dependencies = [ ('organizations', '0001_initial'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( name='StandardCategory', 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', models.CharField(max_length=100)), ('name_ar', models.CharField(blank=True, max_length=100, verbose_name='Name (Arabic)')), ('description', models.TextField(blank=True)), ('order', models.PositiveIntegerField(default=0, help_text='Display order')), ('is_active', models.BooleanField(db_index=True, default=True)), ], options={ 'verbose_name': 'Standard Category', 'verbose_name_plural': 'Standard Categories', 'ordering': ['order', 'name'], }, ), migrations.CreateModel( name='StandardSource', 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', models.CharField(max_length=100)), ('name_ar', models.CharField(blank=True, max_length=100, verbose_name='Name (Arabic)')), ('code', models.CharField(db_index=True, max_length=50, unique=True)), ('description', models.TextField(blank=True)), ('website', models.URLField(blank=True)), ('is_active', models.BooleanField(db_index=True, default=True)), ], options={ 'verbose_name': 'Standard Source', 'verbose_name_plural': 'Standard Sources', 'ordering': ['name'], }, ), migrations.CreateModel( name='Standard', 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(db_index=True, help_text='e.g., CBAHI-PS-01', max_length=50)), ('title', models.CharField(max_length=300)), ('title_ar', models.CharField(blank=True, max_length=300, verbose_name='Title (Arabic)')), ('description', models.TextField(help_text='Full description of the standard')), ('effective_date', models.DateField(blank=True, help_text='When standard becomes effective', null=True)), ('review_date', models.DateField(blank=True, help_text='Next review date', null=True)), ('is_active', models.BooleanField(db_index=True, default=True)), ('department', models.ForeignKey(blank=True, help_text='Department-specific standard (null if applicable to all)', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='standards', to='organizations.department')), ('category', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='standards', to='standards.standardcategory')), ('source', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='standards', to='standards.standardsource')), ], options={ 'verbose_name': 'Standard', 'verbose_name_plural': 'Standards', 'ordering': ['source', 'category', 'code'], }, ), migrations.CreateModel( name='StandardCompliance', 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)), ('status', models.CharField(choices=[('not_assessed', 'Not Assessed'), ('met', 'Met'), ('partially_met', 'Partially Met'), ('not_met', 'Not Met')], db_index=True, default='not_assessed', max_length=20)), ('last_assessed_date', models.DateField(blank=True, help_text='Date of last assessment', null=True)), ('notes', models.TextField(blank=True, help_text='Assessment notes')), ('evidence_summary', models.TextField(blank=True, help_text='Summary of evidence')), ('assessor', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='assessments', to=settings.AUTH_USER_MODEL)), ('department', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='compliance_records', to='organizations.department')), ('standard', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='compliance_records', to='standards.standard')), ], options={ 'verbose_name': 'Standard Compliance', 'verbose_name_plural': 'Standard Compliance', 'ordering': ['-created_at'], 'unique_together': {('department', 'standard')}, }, ), migrations.CreateModel( name='StandardAttachment', 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)), ('file', models.FileField(upload_to='standards/attachments/%Y/%m/', validators=[django.core.validators.FileExtensionValidator(allowed_extensions=['pdf', 'doc', 'docx', 'xls', 'xlsx', 'jpg', 'jpeg', 'png', 'zip'])])), ('filename', models.CharField(help_text='Original filename', max_length=255)), ('description', models.TextField(blank=True, help_text='Attachment description')), ('uploaded_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='uploaded_standards_attachments', to=settings.AUTH_USER_MODEL)), ('compliance', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='attachments', to='standards.standardcompliance')), ], options={ 'verbose_name': 'Standard Attachment', 'verbose_name_plural': 'Standard Attachments', 'ordering': ['-created_at'], }, ), ]