Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions pydis_site/apps/api/migrations/0084_infraction_last_applied.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 4.0.6 on 2022-07-27 20:32

import django.utils.timezone
from django.db import migrations, models
from django.apps.registry import Apps


def set_last_applied_to_inserted_at(apps: Apps, schema_editor):
Infractions = apps.get_model("api", "infraction")
Infractions.objects.all().update(last_applied=models.F("inserted_at"))


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.'),
),
migrations.RunPython(set_last_applied_to_inserted_at)
]
6 changes: 6 additions & 0 deletions pydis_site/apps/api/models/bot/infraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=(
Expand Down