comparison messages/models.py @ 1206:02181fa5ac9d modernize tip

Update to Django 1.9.
author Brian Neal <bgneal@gmail.com>
date Wed, 22 Jan 2025 17:58:16 -0600
parents f0ac48aa8c64
children
comparison
equal deleted inserted replaced
1205:510ef3cbf3e6 1206:02181fa5ac9d
30 return self.filter(receiver=user, read_date__isnull=True).count() 30 return self.filter(receiver=user, read_date__isnull=True).count()
31 31
32 32
33 class Message(models.Model): 33 class Message(models.Model):
34 """The Message is a model for a private message between users.""" 34 """The Message is a model for a private message between users."""
35 sender = models.ForeignKey(User, related_name='sender') 35 sender = models.ForeignKey(User, related_name='sender',
36 receiver = models.ForeignKey(User, related_name='receiver') 36 on_delete=models.CASCADE)
37 receiver = models.ForeignKey(User, related_name='receiver',
38 on_delete=models.CASCADE)
37 send_date = models.DateTimeField('Date Sent', null=True, blank=True) 39 send_date = models.DateTimeField('Date Sent', null=True, blank=True)
38 read_date = models.DateTimeField('Date Received', null=True, blank=True) 40 read_date = models.DateTimeField('Date Received', null=True, blank=True)
39 reply_date = models.DateTimeField('Date Replied', null=True, blank=True) 41 reply_date = models.DateTimeField('Date Replied', null=True, blank=True)
40 subject = models.CharField(max_length=120) 42 subject = models.CharField(max_length=120)
41 message = models.TextField() 43 message = models.TextField()
89 return opts 91 return opts
90 92
91 93
92 class Options(models.Model): 94 class Options(models.Model):
93 """Options is a model for user private message options.""" 95 """Options is a model for user private message options."""
94 user = models.ForeignKey(User, editable=False) 96 user = models.ForeignKey(User, editable=False, on_delete=models.CASCADE)
95 attach_signature = models.BooleanField("Always attach signature?", default=True) 97 attach_signature = models.BooleanField("Always attach signature?", default=True)
96 notify_email = models.BooleanField("Notify me of new messages via email?", default=False) 98 notify_email = models.BooleanField("Notify me of new messages via email?", default=False)
97 99
98 objects = OptionsManager() 100 objects = OptionsManager()
99 101
107 class Flag(models.Model): 109 class Flag(models.Model):
108 """The Flag model is used to represent when a receiver of a private message 110 """The Flag model is used to represent when a receiver of a private message
109 has flagged the message for spam or abuse. 111 has flagged the message for spam or abuse.
110 112
111 """ 113 """
112 message = models.OneToOneField(Message) 114 message = models.OneToOneField(Message, on_delete=models.CASCADE)
113 flag_date = models.DateTimeField() 115 flag_date = models.DateTimeField()
114 comments = models.TextField(blank=True) 116 comments = models.TextField(blank=True)
115 117
116 def __unicode__(self): 118 def __unicode__(self):
117 msg = self.message 119 msg = self.message