diff options
author | 2023-03-20 14:07:30 +0200 | |
---|---|---|
committer | 2023-03-20 14:14:46 +0200 | |
commit | d4dda1cfcb3949e7303bef1457ca395da7cd89f6 (patch) | |
tree | e07a90e7ffb4840ab3d9e5198ddfa05501591cbe /pydis_site/apps/api | |
parent | Migrate infraction type `mute` to `timeout` (diff) | |
parent | Merge pull request #902 from python-discord/dependabot/pip/flake8-bugbear-23.... (diff) |
Merge branch 'main' into mbaruh/timeout
Diffstat (limited to 'pydis_site/apps/api')
-rw-r--r-- | pydis_site/apps/api/migrations/0086_infraction_jump_url.py | 18 | ||||
-rw-r--r-- | pydis_site/apps/api/migrations/0087_alter_mute_to_timeout.py (renamed from pydis_site/apps/api/migrations/0086_alter_mute_to_timeout.py) | 2 | ||||
-rw-r--r-- | pydis_site/apps/api/models/bot/infraction.py | 9 | ||||
-rw-r--r-- | pydis_site/apps/api/serializers.py | 3 | ||||
-rw-r--r-- | pydis_site/apps/api/viewsets/bot/infraction.py | 8 |
5 files changed, 35 insertions, 5 deletions
diff --git a/pydis_site/apps/api/migrations/0086_infraction_jump_url.py b/pydis_site/apps/api/migrations/0086_infraction_jump_url.py new file mode 100644 index 00000000..7ae65751 --- /dev/null +++ b/pydis_site/apps/api/migrations/0086_infraction_jump_url.py @@ -0,0 +1,18 @@ +# Generated by Django 4.1.7 on 2023-03-10 17:25 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('api', '0085_add_thread_id_to_nominations'), + ] + + operations = [ + migrations.AddField( + model_name='infraction', + name='jump_url', + field=models.URLField(default=None, help_text='The jump url to message invoking the infraction.', max_length=88, null=True), + ), + ] diff --git a/pydis_site/apps/api/migrations/0086_alter_mute_to_timeout.py b/pydis_site/apps/api/migrations/0087_alter_mute_to_timeout.py index 8eb3ff6d..8a826ba5 100644 --- a/pydis_site/apps/api/migrations/0086_alter_mute_to_timeout.py +++ b/pydis_site/apps/api/migrations/0087_alter_mute_to_timeout.py @@ -12,7 +12,7 @@ def rename_type(apps: Apps, _) -> None: class Migration(migrations.Migration): dependencies = [ - ('api', '0085_add_thread_id_to_nominations'), + ('api', '0086_infraction_jump_url'), ] operations = [ diff --git a/pydis_site/apps/api/models/bot/infraction.py b/pydis_site/apps/api/models/bot/infraction.py index fcf8651e..381b5b9d 100644 --- a/pydis_site/apps/api/models/bot/infraction.py +++ b/pydis_site/apps/api/models/bot/infraction.py @@ -69,6 +69,15 @@ class Infraction(ModelReprMixin, models.Model): help_text="Whether a DM was sent to the user when infraction was applied." ) + jump_url = models.URLField( + default=None, + null=True, + max_length=88, + help_text=( + "The jump url to message invoking the infraction." + ) + ) + def __str__(self): """Returns some info on the current infraction, for display purposes.""" s = f"#{self.id}: {self.type} on {self.user_id}" diff --git a/pydis_site/apps/api/serializers.py b/pydis_site/apps/api/serializers.py index 4303e7d0..e74ca102 100644 --- a/pydis_site/apps/api/serializers.py +++ b/pydis_site/apps/api/serializers.py @@ -184,7 +184,8 @@ class InfractionSerializer(ModelSerializer): 'type', 'reason', 'hidden', - 'dm_sent' + 'dm_sent', + 'jump_url' ) def validate(self, attrs: dict) -> dict: diff --git a/pydis_site/apps/api/viewsets/bot/infraction.py b/pydis_site/apps/api/viewsets/bot/infraction.py index 93d29391..ec8b83a1 100644 --- a/pydis_site/apps/api/viewsets/bot/infraction.py +++ b/pydis_site/apps/api/viewsets/bot/infraction.py @@ -72,7 +72,8 @@ class InfractionViewSet( ... 'type': 'ban', ... 'reason': 'He terk my jerb!', ... 'hidden': True, - ... 'dm_sent': True + ... 'dm_sent': True, + ... 'jump_url': '<discord message link>' ... } ... ] @@ -103,7 +104,8 @@ class InfractionViewSet( ... 'type': 'ban', ... 'reason': 'He terk my jerb!', ... 'user': 172395097705414656, - ... 'dm_sent': False + ... 'dm_sent': False, + ... 'jump_url': '<discord message link>' ... } #### Response format @@ -138,7 +140,7 @@ class InfractionViewSet( #### Status codes - 204: returned on success - - 404: if a infraction with the given `id` does not exist + - 404: if an infraction with the given `id` does not exist ### Expanded routes All routes support expansion of `user` and `actor` in responses. To use an expanded route, |