Mercurial > public > sg101
comparison messages/models.py @ 810:4a4fa174a0ec
Private message refactor: adding ability to report PM's.
See also Bitbucket issue #57.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 06 Sep 2014 16:58:08 -0500 |
parents | ee87ea74d46b |
children | 82f1f6f905eb |
comparison
equal
deleted
inserted
replaced
809:ab3deff7672a | 810:4a4fa174a0ec |
---|---|
99 | 99 |
100 class Meta: | 100 class Meta: |
101 verbose_name_plural = "Options" | 101 verbose_name_plural = "Options" |
102 | 102 |
103 | 103 |
104 class Flag(models.Model): | |
105 """The Flag model is used to represent when a receiver of a private message | |
106 has flagged the message for spam or abuse. | |
107 | |
108 """ | |
109 message = models.OneToOneField(Message) | |
110 flag_date = models.DateTimeField() | |
111 comments = models.TextField(blank=True) | |
112 | |
113 def __unicode__(self): | |
114 msg = self.message | |
115 return "{} has flagged a PM from {}".format(msg.receiver.username, | |
116 msg.sender.username) | |
117 | |
118 def save(self, *args, **kwargs): | |
119 if not self.id: | |
120 self.flag_date = datetime.datetime.now() | |
121 super(Flag, self).save(*args, **kwargs) | |
122 |