diff options
author | 2024-05-23 22:49:34 +0200 | |
---|---|---|
committer | 2024-05-23 21:49:34 +0100 | |
commit | 089b7f4504c8d1316c5ad97f019735a090848582 (patch) | |
tree | 0364567ae31d79b6fd866a6f82cd89bfa4d2178e /pydis_site/apps/api/migrations | |
parent | Merge pull request #1325 from python-discord/dependabot/pip/ruff-0.4.5 (diff) |
Add alternate accounts to the user model
Introduce a way to store alternate accounts on the user, and add the
`PATCH /bot/users/<id:str>/alts` endpoint, which allows updating the
user's alt accounts to the alt accounts in the request..
Diffstat (limited to 'pydis_site/apps/api/migrations')
-rw-r--r-- | pydis_site/apps/api/migrations/0093_user_alts.py | 41 | ||||
-rw-r--r-- | pydis_site/apps/api/migrations/0096_merge_0093_user_alts_0095_user_display_name.py | 14 |
2 files changed, 55 insertions, 0 deletions
diff --git a/pydis_site/apps/api/migrations/0093_user_alts.py b/pydis_site/apps/api/migrations/0093_user_alts.py new file mode 100644 index 00000000..fa5f2102 --- /dev/null +++ b/pydis_site/apps/api/migrations/0093_user_alts.py @@ -0,0 +1,41 @@ +# Generated by Django 5.0 on 2023-12-14 13:14 + +import django.db.models.deletion +import pydis_site.apps.api.models.mixins +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('api', '0092_remove_redirect_filter_list'), + ] + + operations = [ + migrations.CreateModel( + name='UserAltRelationship', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('updated_at', models.DateTimeField(auto_now=True)), + ('context', models.TextField(help_text='The reason for why this account was associated as an alt.', max_length=1900)), + ('actor', models.ForeignKey(help_text='The moderator that associated these accounts together.', on_delete=django.db.models.deletion.CASCADE, related_name='+', to='api.user')), + ('source', models.ForeignKey(help_text='The source of this user to alternate account relationship', on_delete=django.db.models.deletion.CASCADE, to='api.user', verbose_name='Source')), + ('target', models.ForeignKey(help_text='The target of this user to alternate account relationship', on_delete=django.db.models.deletion.CASCADE, related_name='+', to='api.user', verbose_name='Target')), + ], + bases=(pydis_site.apps.api.models.mixins.ModelReprMixin, models.Model), + ), + migrations.AddField( + model_name='user', + name='alts', + field=models.ManyToManyField(help_text='Known alternate accounts of this user. Manually linked.', through='api.UserAltRelationship', to='api.user', verbose_name='Alternative accounts'), + ), + migrations.AddConstraint( + model_name='useraltrelationship', + constraint=models.UniqueConstraint(fields=('source', 'target'), name='api_useraltrelationship_unique_relationships'), + ), + migrations.AddConstraint( + model_name='useraltrelationship', + constraint=models.CheckConstraint(check=models.Q(('source', models.F('target')), _negated=True), name='api_useraltrelationship_prevent_alt_to_self'), + ), + ] diff --git a/pydis_site/apps/api/migrations/0096_merge_0093_user_alts_0095_user_display_name.py b/pydis_site/apps/api/migrations/0096_merge_0093_user_alts_0095_user_display_name.py new file mode 100644 index 00000000..eaf2b66e --- /dev/null +++ b/pydis_site/apps/api/migrations/0096_merge_0093_user_alts_0095_user_display_name.py @@ -0,0 +1,14 @@ +# Generated by Django 5.0 on 2024-05-20 05:14 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('api', '0093_user_alts'), + ('api', '0095_user_display_name'), + ] + + operations = [ + ] |