@@ -33,6 +33,14 @@ def validate_regex_compiles(regex_string):
3333 raise ValidationError ('Invalid regular expression entered!' )
3434
3535
36+ class TimestampMixin (models .Model ):
37+ created_at = models .DateTimeField (default = tz_utils .now )
38+ updated_at = models .DateTimeField (default = tz_utils .now )
39+
40+ def update_timestamp (self ):
41+ self .updated_at = tz_utils .now ().isoformat ()
42+
43+
3644class Person (models .Model ):
3745 # properties
3846
@@ -823,6 +831,29 @@ class Meta:
823831 ]
824832
825833
834+ class Note (TimestampMixin , models .Model ):
835+ patch = models .ForeignKey (
836+ Patch ,
837+ related_name = 'note' ,
838+ related_query_name = 'note' ,
839+ on_delete = models .CASCADE ,
840+ )
841+ submitter = models .ForeignKey (User , on_delete = models .CASCADE )
842+ content = models .TextField (null = False , blank = True )
843+ maintainer_only = models .BooleanField (default = True )
844+ __original_content = None
845+
846+ def __init__ (self , * args , ** kwargs ):
847+ super ().__init__ (* args , ** kwargs )
848+ self .__original_content = self .content
849+
850+ def save (self , * args , ** kwargs ):
851+ if self .content != self .__original_content :
852+ self .update_timestamp ()
853+ self .__original_content = self .content
854+ super ().save (* args , ** kwargs )
855+
856+
826857class Series (FilenameMixin , models .Model ):
827858 """A collection of patches."""
828859
0 commit comments