backup before mayor changes

This commit is contained in:
2026-08-05 16:35:09 -05:00
parent f5954247fc
commit 203ff88af1
8 changed files with 145 additions and 15 deletions
+12 -2
View File
@@ -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]}'