|
| 1 | +# |
| 2 | +# Copyright © Michal Čihař <michal@weblate.org> |
| 3 | +# |
| 4 | +# This file is part of Weblate <https://weblate.org/> |
| 5 | +# |
| 6 | +# This program is free software: you can redistribute it and/or modify |
| 7 | +# it under the terms of the GNU General Public License as published by |
| 8 | +# the Free Software Foundation, either version 3 of the License, or |
| 9 | +# (at your option) any later version. |
| 10 | +# |
| 11 | +# This program is distributed in the hope that it will be useful, |
| 12 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | +# GNU General Public License for more details. |
| 15 | +# |
| 16 | +# You should have received a copy of the GNU General Public License |
| 17 | +# along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 18 | +# |
| 19 | + |
| 20 | +from __future__ import annotations |
| 21 | + |
| 22 | +import django.core.serializers.json |
| 23 | +import django.db.models.deletion |
| 24 | +import django.utils.timezone |
| 25 | +from django.conf import settings |
| 26 | +from django.db import migrations, models |
| 27 | + |
| 28 | + |
| 29 | +class Migration(migrations.Migration): |
| 30 | + dependencies = [ |
| 31 | + ("weblate_web", "0050_subscription_payment_fk"), |
| 32 | + migrations.swappable_dependency(settings.AUTH_USER_MODEL), |
| 33 | + ] |
| 34 | + |
| 35 | + operations = [ |
| 36 | + migrations.CreateModel( |
| 37 | + name="ExternalSyncState", |
| 38 | + fields=[ |
| 39 | + ( |
| 40 | + "id", |
| 41 | + models.AutoField( |
| 42 | + auto_created=True, |
| 43 | + primary_key=True, |
| 44 | + serialize=False, |
| 45 | + verbose_name="ID", |
| 46 | + ), |
| 47 | + ), |
| 48 | + ("key", models.CharField(max_length=100, unique=True)), |
| 49 | + ("cursor", models.CharField(blank=True, max_length=255)), |
| 50 | + ("updated", models.DateTimeField(auto_now=True)), |
| 51 | + ], |
| 52 | + options={ |
| 53 | + "verbose_name": "External sync state", |
| 54 | + "verbose_name_plural": "External sync states", |
| 55 | + }, |
| 56 | + ), |
| 57 | + migrations.CreateModel( |
| 58 | + name="SamlIdentity", |
| 59 | + fields=[ |
| 60 | + ( |
| 61 | + "id", |
| 62 | + models.AutoField( |
| 63 | + auto_created=True, |
| 64 | + primary_key=True, |
| 65 | + serialize=False, |
| 66 | + verbose_name="ID", |
| 67 | + ), |
| 68 | + ), |
| 69 | + ("provider", models.CharField(max_length=255)), |
| 70 | + ("external_id", models.CharField(max_length=255)), |
| 71 | + ( |
| 72 | + "last_seen", |
| 73 | + models.DateTimeField(default=django.utils.timezone.now), |
| 74 | + ), |
| 75 | + ( |
| 76 | + "raw_attrs", |
| 77 | + models.JSONField( |
| 78 | + blank=True, |
| 79 | + default=dict, |
| 80 | + encoder=django.core.serializers.json.DjangoJSONEncoder, |
| 81 | + ), |
| 82 | + ), |
| 83 | + ( |
| 84 | + "user", |
| 85 | + models.ForeignKey( |
| 86 | + on_delete=django.db.models.deletion.CASCADE, |
| 87 | + related_name="saml_identities", |
| 88 | + to=settings.AUTH_USER_MODEL, |
| 89 | + ), |
| 90 | + ), |
| 91 | + ], |
| 92 | + options={ |
| 93 | + "verbose_name": "SAML identity", |
| 94 | + "verbose_name_plural": "SAML identities", |
| 95 | + }, |
| 96 | + ), |
| 97 | + migrations.AddConstraint( |
| 98 | + model_name="samlidentity", |
| 99 | + constraint=models.UniqueConstraint( |
| 100 | + fields=("provider", "external_id"), |
| 101 | + name="weblate_web_saml_identity_unique", |
| 102 | + ), |
| 103 | + ), |
| 104 | + ] |
0 commit comments