# Generated by Django 5.2.8 on 2025-11-26 13:41 import django.db.models.deletion from django.conf import settings from django.db import migrations, models class Migration(migrations.Migration): initial = True dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( name='ConsentRecord', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('consent_type', models.CharField(choices=[('privacy_policy', 'Privacy Policy'), ('terms_of_service', 'Terms of Service'), ('data_processing', 'Data Processing'), ('marketing', 'Marketing Communications'), ('cookies', 'Cookie Consent')], max_length=50)), ('consent_given', models.BooleanField(default=False)), ('ip_address', models.GenericIPAddressField(blank=True, null=True)), ('user_agent', models.TextField(blank=True)), ('timestamp', models.DateTimeField(auto_now_add=True)), ('version', models.CharField(blank=True, help_text='Version of the policy/terms', max_length=20)), ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='consents', to=settings.AUTH_USER_MODEL)), ], options={ 'verbose_name': 'Consent Record', 'verbose_name_plural': 'Consent Records', 'db_table': 'legal_consentrecord', 'ordering': ['-timestamp'], 'indexes': [models.Index(fields=['user', 'consent_type'], name='legal_conse_user_id_c707fa_idx'), models.Index(fields=['consent_type', 'timestamp'], name='legal_conse_consent_216033_idx')], }, ), migrations.CreateModel( name='DataRequest', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('request_type', models.CharField(choices=[('access', 'Data Access Request'), ('deletion', 'Data Deletion Request'), ('portability', 'Data Portability Request'), ('rectification', 'Data Rectification Request'), ('objection', 'Objection to Processing'), ('restriction', 'Restriction of Processing')], max_length=50)), ('status', models.CharField(choices=[('pending', 'Pending'), ('in_progress', 'In Progress'), ('completed', 'Completed'), ('rejected', 'Rejected')], default='pending', max_length=20)), ('description', models.TextField(blank=True, help_text='Additional details about the request')), ('requested_at', models.DateTimeField(auto_now_add=True)), ('completed_at', models.DateTimeField(blank=True, null=True)), ('response_data', models.JSONField(blank=True, default=dict, help_text='Response data (e.g., exported data)')), ('response_file', models.FileField(blank=True, help_text='File containing requested data', null=True, upload_to='data_requests/')), ('notes', models.TextField(blank=True, help_text='Internal notes about handling the request')), ('handled_by', models.ForeignKey(blank=True, limit_choices_to={'role': 'admin'}, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='handled_data_requests', to=settings.AUTH_USER_MODEL)), ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='data_requests', to=settings.AUTH_USER_MODEL)), ], options={ 'verbose_name': 'Data Request', 'verbose_name_plural': 'Data Requests', 'db_table': 'legal_datarequest', 'ordering': ['-requested_at'], 'indexes': [models.Index(fields=['user', 'status'], name='legal_datar_user_id_da1063_idx'), models.Index(fields=['request_type', 'status'], name='legal_datar_request_ad226f_idx'), models.Index(fields=['status', 'requested_at'], name='legal_datar_status_392f15_idx')], }, ), migrations.CreateModel( name='SecurityEvent', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('event_type', models.CharField(choices=[('login_success', 'Successful Login'), ('login_failed', 'Failed Login'), ('password_change', 'Password Changed'), ('account_locked', 'Account Locked'), ('suspicious_activity', 'Suspicious Activity'), ('data_breach', 'Data Breach'), ('unauthorized_access', 'Unauthorized Access Attempt'), ('file_upload', 'File Upload'), ('data_export', 'Data Export'), ('admin_action', 'Admin Action')], max_length=50)), ('ip_address', models.GenericIPAddressField(blank=True, null=True)), ('user_agent', models.TextField(blank=True)), ('details', models.JSONField(blank=True, default=dict, help_text='Additional event details')), ('severity', models.CharField(choices=[('low', 'Low'), ('medium', 'Medium'), ('high', 'High'), ('critical', 'Critical')], default='low', max_length=20)), ('timestamp', models.DateTimeField(auto_now_add=True)), ('resolved', models.BooleanField(default=False)), ('resolved_at', models.DateTimeField(blank=True, null=True)), ('resolved_by', models.ForeignKey(blank=True, limit_choices_to={'role': 'admin'}, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='resolved_security_events', to=settings.AUTH_USER_MODEL)), ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='security_events', to=settings.AUTH_USER_MODEL)), ], options={ 'verbose_name': 'Security Event', 'verbose_name_plural': 'Security Events', 'db_table': 'security_securityevent', 'ordering': ['-timestamp'], 'indexes': [models.Index(fields=['event_type', 'timestamp'], name='security_se_event_t_1a00f0_idx'), models.Index(fields=['severity', 'timestamp'], name='security_se_severit_5c25b4_idx'), models.Index(fields=['user', 'timestamp'], name='security_se_user_id_6ceb62_idx'), models.Index(fields=['resolved', 'timestamp'], name='security_se_resolve_dbd0de_idx')], }, ), ]