|
| 1 | +# Generated by Django 5.2.10 on 2026-01-26 10:21 |
| 2 | + |
| 3 | +import django.db.models.deletion |
| 4 | +import simple_history.models |
| 5 | +from django.conf import settings |
| 6 | +from django.db import migrations, models |
| 7 | + |
| 8 | + |
| 9 | +class Migration(migrations.Migration): |
| 10 | + dependencies = [ |
| 11 | + ("agreements", "0006_useragreementrecord"), |
| 12 | + migrations.swappable_dependency(settings.AUTH_USER_MODEL), |
| 13 | + ] |
| 14 | + |
| 15 | + operations = [ |
| 16 | + migrations.CreateModel( |
| 17 | + name="HistoricalUserAgreement", |
| 18 | + fields=[ |
| 19 | + ("id", models.IntegerField(auto_created=True, blank=True, db_index=True, verbose_name="ID")), |
| 20 | + ("type", models.CharField(db_index=True, max_length=255)), |
| 21 | + ( |
| 22 | + "name", |
| 23 | + models.CharField( |
| 24 | + help_text="Human-readable name for the agreement type. Will be displayed to users in alert to accept the agreement.", |
| 25 | + max_length=255, |
| 26 | + ), |
| 27 | + ), |
| 28 | + ( |
| 29 | + "summary", |
| 30 | + models.TextField( |
| 31 | + help_text="Brief summary of the agreement content. Will be displayed to users in alert to accept the agreement.", |
| 32 | + max_length=1024, |
| 33 | + ), |
| 34 | + ), |
| 35 | + ( |
| 36 | + "text", |
| 37 | + models.TextField( |
| 38 | + blank=True, help_text="Full text of the agreement. (Required if url is not provided)", null=True |
| 39 | + ), |
| 40 | + ), |
| 41 | + ( |
| 42 | + "url", |
| 43 | + models.URLField( |
| 44 | + blank=True, |
| 45 | + help_text='URL where the full agreement can be accessed. Will be used for "Learn More" link in alert to accept the agreement.', |
| 46 | + null=True, |
| 47 | + ), |
| 48 | + ), |
| 49 | + ("created", models.DateTimeField(blank=True, editable=False)), |
| 50 | + ( |
| 51 | + "updated", |
| 52 | + models.DateTimeField( |
| 53 | + help_text="Timestamp of the last update to this agreement. If changed users will be prompted to accept the agreement again." |
| 54 | + ), |
| 55 | + ), |
| 56 | + ("history_id", models.AutoField(primary_key=True, serialize=False)), |
| 57 | + ("history_date", models.DateTimeField()), |
| 58 | + ("history_change_reason", models.CharField(max_length=100, null=True)), |
| 59 | + ( |
| 60 | + "history_type", |
| 61 | + models.CharField(choices=[("+", "Created"), ("~", "Changed"), ("-", "Deleted")], max_length=1), |
| 62 | + ), |
| 63 | + ( |
| 64 | + "history_user", |
| 65 | + models.ForeignKey( |
| 66 | + null=True, |
| 67 | + on_delete=django.db.models.deletion.SET_NULL, |
| 68 | + related_name="+", |
| 69 | + to=settings.AUTH_USER_MODEL, |
| 70 | + ), |
| 71 | + ), |
| 72 | + ], |
| 73 | + options={ |
| 74 | + "verbose_name": "historical user agreement", |
| 75 | + "verbose_name_plural": "historical user agreements", |
| 76 | + "ordering": ("-history_date", "-history_id"), |
| 77 | + "get_latest_by": ("history_date", "history_id"), |
| 78 | + }, |
| 79 | + bases=(simple_history.models.HistoricalChanges, models.Model), |
| 80 | + ), |
| 81 | + migrations.CreateModel( |
| 82 | + name="UserAgreement", |
| 83 | + fields=[ |
| 84 | + ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), |
| 85 | + ("type", models.CharField(max_length=255, unique=True)), |
| 86 | + ( |
| 87 | + "name", |
| 88 | + models.CharField( |
| 89 | + help_text="Human-readable name for the agreement type. Will be displayed to users in alert to accept the agreement.", |
| 90 | + max_length=255, |
| 91 | + ), |
| 92 | + ), |
| 93 | + ( |
| 94 | + "summary", |
| 95 | + models.TextField( |
| 96 | + help_text="Brief summary of the agreement content. Will be displayed to users in alert to accept the agreement.", |
| 97 | + max_length=1024, |
| 98 | + ), |
| 99 | + ), |
| 100 | + ( |
| 101 | + "text", |
| 102 | + models.TextField( |
| 103 | + blank=True, help_text="Full text of the agreement. (Required if url is not provided)", null=True |
| 104 | + ), |
| 105 | + ), |
| 106 | + ( |
| 107 | + "url", |
| 108 | + models.URLField( |
| 109 | + blank=True, |
| 110 | + help_text='URL where the full agreement can be accessed. Will be used for "Learn More" link in alert to accept the agreement.', |
| 111 | + null=True, |
| 112 | + ), |
| 113 | + ), |
| 114 | + ("created", models.DateTimeField(auto_now_add=True)), |
| 115 | + ( |
| 116 | + "updated", |
| 117 | + models.DateTimeField( |
| 118 | + help_text="Timestamp of the last update to this agreement. If changed users will be prompted to accept the agreement again." |
| 119 | + ), |
| 120 | + ), |
| 121 | + ], |
| 122 | + options={ |
| 123 | + "constraints": [ |
| 124 | + models.CheckConstraint( |
| 125 | + condition=models.Q(("text__isnull", False), ("url__isnull", False), _connector="OR"), |
| 126 | + name="agreement_has_text_or_url", |
| 127 | + ) |
| 128 | + ], |
| 129 | + }, |
| 130 | + ), |
| 131 | + migrations.AddField( |
| 132 | + model_name="useragreementrecord", |
| 133 | + name="agreement", |
| 134 | + field=models.ForeignKey( |
| 135 | + null=True, |
| 136 | + on_delete=django.db.models.deletion.CASCADE, |
| 137 | + related_name="records", |
| 138 | + to="agreements.useragreement", |
| 139 | + ), |
| 140 | + ), |
| 141 | + ] |
0 commit comments