aboutsummaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorGravatar Johannes Christ <[email protected]>2019-01-09 20:51:48 +0100
committerGravatar Johannes Christ <[email protected]>2019-01-09 20:51:48 +0100
commite70114dfded579cec72f57f6490f134e520ee7b9 (patch)
treec81609623e19846a5a43962e2de67ec791a900c6 /api
parentAllow custom `inserted_at` infraction field for now. (diff)
Use proper default for infraction insertion date.
Diffstat (limited to 'api')
-rw-r--r--api/migrations/0026_use_proper_default_for_infraction_insertion_date.py19
-rw-r--r--api/models.py4
2 files changed, 21 insertions, 2 deletions
diff --git a/api/migrations/0026_use_proper_default_for_infraction_insertion_date.py b/api/migrations/0026_use_proper_default_for_infraction_insertion_date.py
new file mode 100644
index 00000000..56f3b2b8
--- /dev/null
+++ b/api/migrations/0026_use_proper_default_for_infraction_insertion_date.py
@@ -0,0 +1,19 @@
+# Generated by Django 2.1.5 on 2019-01-09 19:50
+
+from django.db import migrations, models
+import django.utils.timezone
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('api', '0025_allow_custom_inserted_at_infraction_field'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='infraction',
+ name='inserted_at',
+ field=models.DateTimeField(default=django.utils.timezone.now, help_text='The date and time of the creation of this infraction.'),
+ ),
+ ]
diff --git a/api/models.py b/api/models.py
index 176b7c46..092c2e8e 100644
--- a/api/models.py
+++ b/api/models.py
@@ -1,9 +1,9 @@
-import datetime
from operator import itemgetter
from django.contrib.postgres import fields as pgfields
from django.core.validators import MaxValueValidator, MinValueValidator, RegexValidator
from django.db import models
+from django.utils import timezone
from .validators import validate_tag_embed
@@ -250,7 +250,7 @@ class Infraction(ModelReprMixin, models.Model):
("superstar", "Superstar")
)
inserted_at = models.DateTimeField(
- default=datetime.datetime.utcnow,
+ default=timezone.now,
help_text="The date and time of the creation of this infraction."
)
expires_at = models.DateTimeField(