aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pydis_site/apps/api/migrations/0075_infraction_dm_sent.py18
-rw-r--r--pydis_site/apps/api/migrations/0076_merge_20211125_1941.py14
-rw-r--r--pydis_site/apps/api/models/bot/infraction.py4
-rw-r--r--pydis_site/apps/api/serializers.py11
-rw-r--r--pydis_site/apps/api/viewsets/bot/infraction.py9
5 files changed, 52 insertions, 4 deletions
diff --git a/pydis_site/apps/api/migrations/0075_infraction_dm_sent.py b/pydis_site/apps/api/migrations/0075_infraction_dm_sent.py
new file mode 100644
index 00000000..c0ac709d
--- /dev/null
+++ b/pydis_site/apps/api/migrations/0075_infraction_dm_sent.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.0.14 on 2021-11-10 22:06
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('api', '0074_reminder_failures'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='infraction',
+ name='dm_sent',
+ field=models.BooleanField(help_text='Whether a DM was sent to the user when infraction was applied.', null=True),
+ ),
+ ]
diff --git a/pydis_site/apps/api/migrations/0076_merge_20211125_1941.py b/pydis_site/apps/api/migrations/0076_merge_20211125_1941.py
new file mode 100644
index 00000000..097d0a0c
--- /dev/null
+++ b/pydis_site/apps/api/migrations/0076_merge_20211125_1941.py
@@ -0,0 +1,14 @@
+# Generated by Django 3.0.14 on 2021-11-25 19:41
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('api', '0075_infraction_dm_sent'),
+ ('api', '0075_add_redirects_filter'),
+ ]
+
+ operations = [
+ ]
diff --git a/pydis_site/apps/api/models/bot/infraction.py b/pydis_site/apps/api/models/bot/infraction.py
index 60c1e8dd..913631d4 100644
--- a/pydis_site/apps/api/models/bot/infraction.py
+++ b/pydis_site/apps/api/models/bot/infraction.py
@@ -57,6 +57,10 @@ class Infraction(ModelReprMixin, models.Model):
default=False,
help_text="Whether the infraction is a shadow infraction."
)
+ dm_sent = models.BooleanField(
+ null=True,
+ help_text="Whether a DM was sent to the user when infraction was applied."
+ )
def __str__(self):
"""Returns some info on the current infraction, for display purposes."""
diff --git a/pydis_site/apps/api/serializers.py b/pydis_site/apps/api/serializers.py
index 3e213d43..de2fccff 100644
--- a/pydis_site/apps/api/serializers.py
+++ b/pydis_site/apps/api/serializers.py
@@ -145,7 +145,16 @@ class InfractionSerializer(ModelSerializer):
model = Infraction
fields = (
- 'id', 'inserted_at', 'expires_at', 'active', 'user', 'actor', 'type', 'reason', 'hidden'
+ 'id',
+ 'inserted_at',
+ 'expires_at',
+ 'active',
+ 'user',
+ 'actor',
+ 'type',
+ 'reason',
+ 'hidden',
+ 'dm_sent'
)
validators = [
UniqueTogetherValidator(
diff --git a/pydis_site/apps/api/viewsets/bot/infraction.py b/pydis_site/apps/api/viewsets/bot/infraction.py
index f8b0cb9d..8a48ed1f 100644
--- a/pydis_site/apps/api/viewsets/bot/infraction.py
+++ b/pydis_site/apps/api/viewsets/bot/infraction.py
@@ -70,7 +70,8 @@ class InfractionViewSet(
... 'actor': 125435062127820800,
... 'type': 'ban',
... 'reason': 'He terk my jerb!',
- ... 'hidden': True
+ ... 'hidden': True,
+ ... 'dm_sent': True
... }
... ]
@@ -100,7 +101,8 @@ class InfractionViewSet(
... 'hidden': True,
... 'type': 'ban',
... 'reason': 'He terk my jerb!',
- ... 'user': 172395097705414656
+ ... 'user': 172395097705414656,
+ ... 'dm_sent': False
... }
#### Response format
@@ -118,7 +120,8 @@ class InfractionViewSet(
>>> {
... 'active': True,
... 'expires_at': '4143-02-15T21:04:31+00:00',
- ... 'reason': 'durka derr'
+ ... 'reason': 'durka derr',
+ ... 'dm_sent': True
... }
#### Response format