diff options
| author | 2021-10-29 03:19:37 +0400 | |
|---|---|---|
| committer | 2021-10-29 03:19:37 +0400 | |
| commit | 367c01a7b3cd5cc5ee25644ae92f917ceb00562c (patch) | |
| tree | 3be351f403e75d56eb7b08a5e20aa432b2a64ec5 | |
| parent | Merge pull request #617 from python-discord/mbaruh-patch-1 (diff) | |
Adds Failures Field To Reminders
Adds an integer field to reminders, to keep track of how many failed
attempts at delivering the reminder were made.
Updates documentation and serialization.
Signed-off-by: Hassan Abouelela <[email protected]>
| -rw-r--r-- | pydis_site/apps/api/migrations/0074_reminder_failures.py | 18 | ||||
| -rw-r--r-- | pydis_site/apps/api/models/bot/reminder.py | 4 | ||||
| -rw-r--r-- | pydis_site/apps/api/serializers.py | 10 | ||||
| -rw-r--r-- | pydis_site/apps/api/viewsets/bot/reminder.py | 13 | 
4 files changed, 39 insertions, 6 deletions
| diff --git a/pydis_site/apps/api/migrations/0074_reminder_failures.py b/pydis_site/apps/api/migrations/0074_reminder_failures.py new file mode 100644 index 00000000..2860046e --- /dev/null +++ b/pydis_site/apps/api/migrations/0074_reminder_failures.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.14 on 2021-10-27 17:44 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + +    dependencies = [ +        ('api', '0073_otn_allow_GT_and_LT'), +    ] + +    operations = [ +        migrations.AddField( +            model_name='reminder', +            name='failures', +            field=models.IntegerField(default=0, help_text='Number of times we attempted to send the reminder and failed.'), +        ), +    ] diff --git a/pydis_site/apps/api/models/bot/reminder.py b/pydis_site/apps/api/models/bot/reminder.py index 7d968a0e..173900ee 100644 --- a/pydis_site/apps/api/models/bot/reminder.py +++ b/pydis_site/apps/api/models/bot/reminder.py @@ -59,6 +59,10 @@ class Reminder(ModelReprMixin, models.Model):          blank=True,          help_text="IDs of roles or users to ping with the reminder."      ) +    failures = models.IntegerField( +        default=0, +        help_text="Number of times we attempted to send the reminder and failed." +    )      def __str__(self):          """Returns some info on the current reminder, for display purposes.""" diff --git a/pydis_site/apps/api/serializers.py b/pydis_site/apps/api/serializers.py index f47bedca..3e213d43 100644 --- a/pydis_site/apps/api/serializers.py +++ b/pydis_site/apps/api/serializers.py @@ -231,7 +231,15 @@ class ReminderSerializer(ModelSerializer):          model = Reminder          fields = ( -            'active', 'author', 'jump_url', 'channel_id', 'content', 'expiration', 'id', 'mentions' +            'active', +            'author', +            'jump_url', +            'channel_id', +            'content', +            'expiration', +            'id', +            'mentions', +            'failures'          ) diff --git a/pydis_site/apps/api/viewsets/bot/reminder.py b/pydis_site/apps/api/viewsets/bot/reminder.py index 111660d9..78d7cb3b 100644 --- a/pydis_site/apps/api/viewsets/bot/reminder.py +++ b/pydis_site/apps/api/viewsets/bot/reminder.py @@ -42,7 +42,8 @@ class ReminderViewSet(      ...         'expiration': '5018-11-20T15:52:00Z',      ...         'id': 11,      ...         'channel_id': 634547009956872193, -    ...         'jump_url': "https://discord.com/channels/<guild_id>/<channel_id>/<message_id>" +    ...         'jump_url': "https://discord.com/channels/<guild_id>/<channel_id>/<message_id>", +    ...         'failures': 3      ...     },      ...     ...      ... ] @@ -67,7 +68,8 @@ class ReminderViewSet(      ...     'expiration': '5018-11-20T15:52:00Z',      ...     'id': 11,      ...     'channel_id': 634547009956872193, -    ...     'jump_url': "https://discord.com/channels/<guild_id>/<channel_id>/<message_id>" +    ...     'jump_url': "https://discord.com/channels/<guild_id>/<channel_id>/<message_id>", +    ...     'failures': 3      ... }      #### Status codes @@ -80,7 +82,7 @@ class ReminderViewSet(      #### Request body      >>> {      ...     'author': int, -    ...     'mentions': List[int], +    ...     'mentions': list[int],      ...     'content': str,      ...     'expiration': str,  # ISO-formatted datetime      ...     'channel_id': int, @@ -98,9 +100,10 @@ class ReminderViewSet(      #### Request body      >>> { -    ...     'mentions': List[int], +    ...     'mentions': list[int],      ...     'content': str, -    ...     'expiration': str  # ISO-formatted datetime +    ...     'expiration': str,  # ISO-formatted datetime +    ...     'failures': int      ... }      #### Status codes | 
