Skip to content

Commit 1122f5a

Browse files
Merge branch 'main' into speedup-tests
2 parents 98fa159 + 1ca8b4d commit 1122f5a

File tree

26 files changed

+354
-990
lines changed

26 files changed

+354
-990
lines changed

poetry.lock

Lines changed: 243 additions & 183 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Generated by Django 4.0.6 on 2022-07-27 20:32
2+
3+
import django.utils.timezone
4+
from django.db import migrations, models
5+
from django.apps.registry import Apps
6+
7+
8+
def set_last_applied_to_inserted_at(apps: Apps, schema_editor):
9+
Infractions = apps.get_model("api", "infraction")
10+
Infractions.objects.all().update(last_applied=models.F("inserted_at"))
11+
12+
13+
class Migration(migrations.Migration):
14+
15+
dependencies = [
16+
('api', '0083_remove_embed_validation'),
17+
]
18+
19+
operations = [
20+
migrations.AddField(
21+
model_name='infraction',
22+
name='last_applied',
23+
field=models.DateTimeField(default=django.utils.timezone.now, help_text='The date and time of when this infraction was last applied.'),
24+
),
25+
migrations.RunPython(set_last_applied_to_inserted_at)
26+
]

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=(

pydis_site/apps/api/pagination.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import typing
2-
31
from rest_framework.pagination import LimitOffsetPagination
42
from rest_framework.response import Response
3+
from rest_framework.utils.serializer_helpers import ReturnList
54

65

76
class LimitOffsetPaginationExtended(LimitOffsetPagination):
@@ -44,6 +43,6 @@ class LimitOffsetPaginationExtended(LimitOffsetPagination):
4443

4544
default_limit = 100
4645

47-
def get_paginated_response(self, data: typing.Any) -> Response:
46+
def get_paginated_response(self, data: ReturnList) -> Response:
4847
"""Override to skip metadata i.e. `count`, `next`, and `previous`."""
4948
return Response(data)

pydis_site/apps/api/tests/migrations/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

pydis_site/apps/api/tests/migrations/base.py

Lines changed: 0 additions & 102 deletions
This file was deleted.

0 commit comments

Comments
 (0)