Skip to content

Commit dfc32e2

Browse files
committed
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.
1 parent e60a684 commit dfc32e2

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Generated by Django 4.0.6 on 2022-07-27 20:32
2+
3+
from django.db import migrations, models
4+
import django.utils.timezone
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('api', '0083_remove_embed_validation'),
11+
]
12+
13+
operations = [
14+
migrations.AddField(
15+
model_name='infraction',
16+
name='last_applied',
17+
field=models.DateTimeField(default=django.utils.timezone.now, help_text='The date and time of when this infraction was last applied.'),
18+
),
19+
]

pydis_site/apps/api/models/bot/infraction.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ class Infraction(ModelReprMixin, models.Model):
2323
default=timezone.now,
2424
help_text="The date and time of the creation of this infraction."
2525
)
26+
last_applied = models.DateTimeField(
27+
# This default is for backwards compatibility with bot versions
28+
# that don't explicitly give a value.
29+
default=timezone.now,
30+
help_text="The date and time of when this infraction was last applied."
31+
)
2632
expires_at = models.DateTimeField(
2733
null=True,
2834
help_text=(

0 commit comments

Comments
 (0)