backup before mayor changes
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
from django.utils import timezone
|
||||
|
||||
from library.models import Project
|
||||
|
||||
@@ -63,12 +64,21 @@ class AnnouncementComment(models.Model):
|
||||
related_name='announcement_comments',
|
||||
)
|
||||
body = models.TextField()
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
created_at = models.DateTimeField(default=timezone.now)
|
||||
updated_at = models.DateTimeField(default=timezone.now)
|
||||
|
||||
class Meta:
|
||||
ordering = ['created_at', 'pk']
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if self._state.adding:
|
||||
now = timezone.now()
|
||||
self.created_at = now
|
||||
self.updated_at = now
|
||||
else:
|
||||
self.updated_at = timezone.now()
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.user.username}: {self.body[:40]}'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user