+ return self.status == 1
+
+ def publication_date(self):
+ if self.published_at is None:
+ return self.created_at
+ else:
+ return self.published_at
+
+@receiver(pre_save, sender=Note)
+def note_pre_save(sender, instance, **kwargs):
+ if instance.pk is None:
+ if instance.status == 1:
+ instance.published_at = datetime.now()
+ else:
+ old_instance = Note.objects.get(pk=instance.pk)
+
+ if old_instance.status == 0 and instance.status == 1:
+ instance.published_at = datetime.now()
\ No newline at end of file