[PATCH 1/9] models: Add Note model

andrepapoti andrepapoti at gmail.com
Wed Mar 13 17:56:33 AEDT 2024


Signed-off-by: andrepapoti <andrepapoti at gmail.com>
---
 patchwork/models.py | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/patchwork/models.py b/patchwork/models.py
index 9a619bc..b73a95a 100644
--- a/patchwork/models.py
+++ b/patchwork/models.py
@@ -823,6 +823,30 @@ class PatchComment(EmailMixin, models.Model):
         ]
 
 
+class Note(models.Model):
+    patch = models.ForeignKey(
+        Patch,
+        related_name='note',
+        related_query_name='note',
+        on_delete=models.CASCADE,
+    )
+    submitter = models.ForeignKey(Person, on_delete=models.CASCADE)
+    last_modified = models.DateTimeField(default=tz_utils.now)
+    content = models.TextField(null=False, blank=True)
+    maintainer_only = models.BooleanField(default=True)
+    __original_content = None
+
+    def __init__(self, *args, **kwargs):
+        super().__init__(*args, **kwargs)
+        self.__original_content = self.content
+
+    def save(self, *args, **kwargs):
+        if self.content != self.__original_content:
+            self.last_modified = tz_utils.now().isoformat()
+            self.__original_content = self.content
+        super(Note, self).save(*args, **kwargs)
+
+
 class Series(FilenameMixin, models.Model):
     """A collection of patches."""
 
-- 
2.44.0



More information about the Patchwork mailing list