|
| 1 | +# Generated by Django 4.2.3 on 2024-10-18 14:52 |
| 2 | + |
| 3 | +from django.conf import settings |
| 4 | +from django.db import migrations, models |
| 5 | +import django.db.models.deletion |
| 6 | +import django.db.models.functions.datetime |
| 7 | +import django.utils.timezone |
| 8 | + |
| 9 | + |
| 10 | +class Migration(migrations.Migration): |
| 11 | + initial = True |
| 12 | + |
| 13 | + dependencies = [ |
| 14 | + ("geo", "0003_location_timezone"), |
| 15 | + migrations.swappable_dependency(settings.AUTH_USER_MODEL), |
| 16 | + ] |
| 17 | + |
| 18 | + operations = [ |
| 19 | + migrations.CreateModel( |
| 20 | + name="BoundaryAuthorization", |
| 21 | + fields=[ |
| 22 | + ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), |
| 23 | + ("created_at", models.DateTimeField(blank=True, default=django.utils.timezone.now, editable=False)), |
| 24 | + ("updated_at", models.DateTimeField(blank=True, default=django.utils.timezone.now, editable=False)), |
| 25 | + ("supervisor_exclusivity_days", models.PositiveSmallIntegerField(default=15)), |
| 26 | + ("members_only", models.BooleanField(default=False)), |
| 27 | + ( |
| 28 | + "boundary", |
| 29 | + models.OneToOneField( |
| 30 | + on_delete=django.db.models.deletion.CASCADE, related_name="authorization", to="geo.boundary" |
| 31 | + ), |
| 32 | + ), |
| 33 | + ], |
| 34 | + options={ |
| 35 | + "verbose_name": "Boundary Authorization", |
| 36 | + "verbose_name_plural": "Boundary Authorizations", |
| 37 | + "abstract": False, |
| 38 | + }, |
| 39 | + ), |
| 40 | + migrations.CreateModel( |
| 41 | + name="BoundaryMembership", |
| 42 | + fields=[ |
| 43 | + ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), |
| 44 | + ("created_at", models.DateTimeField(blank=True, default=django.utils.timezone.now, editable=False)), |
| 45 | + ("updated_at", models.DateTimeField(blank=True, default=django.utils.timezone.now, editable=False)), |
| 46 | + ( |
| 47 | + "role", |
| 48 | + models.CharField( |
| 49 | + choices=[("s", "Supervisor"), ("i", "Identificator"), ("v", "Viewer")], |
| 50 | + db_index=True, |
| 51 | + max_length=1, |
| 52 | + ), |
| 53 | + ), |
| 54 | + ( |
| 55 | + "boundary_authorization", |
| 56 | + models.ForeignKey( |
| 57 | + on_delete=django.db.models.deletion.CASCADE, |
| 58 | + related_name="memberships", |
| 59 | + to="authorization.boundaryauthorization", |
| 60 | + ), |
| 61 | + ), |
| 62 | + ( |
| 63 | + "user", |
| 64 | + models.ForeignKey( |
| 65 | + on_delete=django.db.models.deletion.CASCADE, |
| 66 | + related_name="boundary_memberships", |
| 67 | + to=settings.AUTH_USER_MODEL, |
| 68 | + ), |
| 69 | + ), |
| 70 | + ], |
| 71 | + options={ |
| 72 | + "abstract": False, |
| 73 | + }, |
| 74 | + ), |
| 75 | + migrations.AddField( |
| 76 | + model_name="boundaryauthorization", |
| 77 | + name="users", |
| 78 | + field=models.ManyToManyField(through="authorization.BoundaryMembership", to=settings.AUTH_USER_MODEL), |
| 79 | + ), |
| 80 | + migrations.AddConstraint( |
| 81 | + model_name="boundarymembership", |
| 82 | + constraint=models.CheckConstraint( |
| 83 | + check=models.Q(("created_at__lte", django.db.models.functions.datetime.Now())), |
| 84 | + name="authorization_boundarymembership_created_at_cannot_be_future_dated", |
| 85 | + ), |
| 86 | + ), |
| 87 | + migrations.AddConstraint( |
| 88 | + model_name="boundarymembership", |
| 89 | + constraint=models.CheckConstraint( |
| 90 | + check=models.Q(("updated_at__lte", django.db.models.functions.datetime.Now())), |
| 91 | + name="authorization_boundarymembership_updated_at_cannot_be_future_dated", |
| 92 | + ), |
| 93 | + ), |
| 94 | + migrations.AddConstraint( |
| 95 | + model_name="boundarymembership", |
| 96 | + constraint=models.CheckConstraint( |
| 97 | + check=models.Q(("updated_at__gte", models.F("created_at"))), |
| 98 | + name="authorization_boundarymembership_updated_at_must_be_after_created_at", |
| 99 | + ), |
| 100 | + ), |
| 101 | + migrations.AddConstraint( |
| 102 | + model_name="boundaryauthorization", |
| 103 | + constraint=models.CheckConstraint( |
| 104 | + check=models.Q(("created_at__lte", django.db.models.functions.datetime.Now())), |
| 105 | + name="authorization_boundaryauthorization_created_at_cannot_be_future_dated", |
| 106 | + ), |
| 107 | + ), |
| 108 | + migrations.AddConstraint( |
| 109 | + model_name="boundaryauthorization", |
| 110 | + constraint=models.CheckConstraint( |
| 111 | + check=models.Q(("updated_at__lte", django.db.models.functions.datetime.Now())), |
| 112 | + name="authorization_boundaryauthorization_updated_at_cannot_be_future_dated", |
| 113 | + ), |
| 114 | + ), |
| 115 | + migrations.AddConstraint( |
| 116 | + model_name="boundaryauthorization", |
| 117 | + constraint=models.CheckConstraint( |
| 118 | + check=models.Q(("updated_at__gte", models.F("created_at"))), |
| 119 | + name="authorization_boundaryauthorization_updated_at_must_be_after_created_at", |
| 120 | + ), |
| 121 | + ), |
| 122 | + ] |
0 commit comments