pedagogy: don't update uv comment publish date at each save

This commit is contained in:
Antoine Bartuccio 2019-06-18 21:55:12 +02:00
parent d18f0aa829
commit 2aa465b138
Signed by: klmp200
GPG Key ID: E7245548C53F904B
3 changed files with 10 additions and 4 deletions

View File

@ -1640,7 +1640,7 @@ def migrate_pedagogy():
grade_interest=convert_number(comment["note_interet"], -1),
grade_teaching=convert_number(comment["note_enseignement"], -1),
grade_work_load=convert_number(comment["note_travail"], -1),
publish_date=comment["date"],
publish_date=comment["date"].replace(tzinfo=timezone("Europe/Paris")),
).save()
print("Migrating UV Results")

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-06-18 15:02
# Generated by Django 1.11.20 on 2019-06-18 20:07
from __future__ import unicode_literals
from django.conf import settings
@ -248,7 +248,7 @@ class Migration(migrations.Migration):
),
(
"publish_date",
models.DateTimeField(auto_now=True, verbose_name="publish date"),
models.DateTimeField(blank=True, verbose_name="publish date"),
),
(
"author",

View File

@ -24,6 +24,7 @@
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils import timezone
from django.core import validators
from django.conf import settings
@ -211,7 +212,12 @@ class UVComment(models.Model):
null=False,
default=-1,
)
publish_date = models.DateTimeField(_("publish date"), auto_now=True)
publish_date = models.DateTimeField(_("publish date"), blank=True)
def save(self, *args, **kwargs):
if self.publish_date is None:
self.publish_date = timezone.now()
super(UVComment, self).save(*args, **kwargs)
class UVResult(models.Model):