Skip to content

Commit cc3a0ec

Browse files
committed
models: Add Note model
Signed-off-by: andrepapoti <andrepapoti@gmail.com>
1 parent 7494873 commit cc3a0ec

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

patchwork/models.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,30 @@ class Meta:
823823
]
824824

825825

826+
class Note(models.Model):
827+
patch = models.ForeignKey(
828+
Patch,
829+
related_name='note',
830+
related_query_name='note',
831+
on_delete=models.CASCADE,
832+
)
833+
submitter = models.ForeignKey(User, on_delete=models.CASCADE)
834+
last_modified = models.DateTimeField(default=tz_utils.now)
835+
content = models.TextField(null=False, blank=True)
836+
maintainer_only = models.BooleanField(default=True)
837+
__original_content = None
838+
839+
def __init__(self, *args, **kwargs):
840+
super().__init__(*args, **kwargs)
841+
self.__original_content = self.content
842+
843+
def save(self, *args, **kwargs):
844+
if self.content != self.__original_content:
845+
self.last_modified = tz_utils.now().isoformat()
846+
self.__original_content = self.content
847+
super(Note, self).save(*args, **kwargs)
848+
849+
826850
class Series(FilenameMixin, models.Model):
827851
"""A collection of patches."""
828852

0 commit comments

Comments
 (0)