diff options
author | 2022-07-27 21:33:13 +0100 | |
---|---|---|
committer | 2022-07-27 21:33:13 +0100 | |
commit | dfc32e28103d652170868d09b49ba98ea95c91bf (patch) | |
tree | f8bc603df39ce4dfaabb6da3a6d3c34de977a38d | |
parent | Merge pull request #750 from python-discord/relax-websocket-rule (diff) |
Add a field to track the time an infraction was last applied
A default is set for backwards compatibility with bot version that don't explicitly give a value.
-rw-r--r-- | pydis_site/apps/api/migrations/0084_infraction_last_applied.py | 19 | ||||
-rw-r--r-- | pydis_site/apps/api/models/bot/infraction.py | 6 |
2 files changed, 25 insertions, 0 deletions
diff --git a/pydis_site/apps/api/migrations/0084_infraction_last_applied.py b/pydis_site/apps/api/migrations/0084_infraction_last_applied.py new file mode 100644 index 00000000..0977fa20 --- /dev/null +++ b/pydis_site/apps/api/migrations/0084_infraction_last_applied.py @@ -0,0 +1,19 @@ +# Generated by Django 4.0.6 on 2022-07-27 20:32 + +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + ('api', '0083_remove_embed_validation'), + ] + + operations = [ + migrations.AddField( + model_name='infraction', + name='last_applied', + field=models.DateTimeField(default=django.utils.timezone.now, help_text='The date and time of when this infraction was last applied.'), + ), + ] diff --git a/pydis_site/apps/api/models/bot/infraction.py b/pydis_site/apps/api/models/bot/infraction.py index c9303024..218ee5ec 100644 --- a/pydis_site/apps/api/models/bot/infraction.py +++ b/pydis_site/apps/api/models/bot/infraction.py @@ -23,6 +23,12 @@ class Infraction(ModelReprMixin, models.Model): default=timezone.now, help_text="The date and time of the creation of this infraction." ) + last_applied = models.DateTimeField( + # This default is for backwards compatibility with bot versions + # that don't explicitly give a value. + default=timezone.now, + help_text="The date and time of when this infraction was last applied." + ) expires_at = models.DateTimeField( null=True, help_text=( |