Implement ability for moderators to send notices to organisations

Notices entered will be sent to the organisations email address - so there
needs to be one (if not, the notification field doesn't show up).

Notifications also go in the database, and show up on each object so you
can see the previous history of it, and get emailed to the slaves list.

Finally, it's possible to reject-with-notification, in which case the
notification is sent off to the user and after that the object is deleted.
The notification history stays in the database, but is not linked anywhere
(but can be viewed from the admin interface on that model directly).
Unfortunately, this seems to cause double notifications to the slaves list,
but we'll have to live with that for now.

Closes #137
This commit is contained in:
Magnus Hagander
2012-06-26 14:11:22 +02:00
parent ca08e6a2da
commit 7855d1b06c
4 changed files with 147 additions and 0 deletions

View File

@ -119,3 +119,19 @@ class UserProfile(models.Model):
user = models.ForeignKey(User, null=False, blank=False, unique=True, primary_key=True)
sshkey = models.TextField(null=False, blank=True, verbose_name="SSH key", help_text= "Paste one or more public keys in OpenSSH format, one per line.")
lastmodified = models.DateTimeField(null=False, blank=False, auto_now=True)
# Notifications sent for any moderated content.
# Yes, we uglify it by storing the type of object as a string, so we don't
# end up with a bazillion fields being foreign keys. Ugly, but works.
class ModerationNotification(models.Model):
objectid = models.IntegerField(null=False, blank=False, db_index=True)
objecttype = models.CharField(null=False, blank=False, max_length=100)
text = models.TextField(null=False, blank=False)
author = models.CharField(null=False, blank=False, max_length=100)
date = models.DateTimeField(null=False, blank=False, auto_now=True)
def __unicode__(self):
return "%s id %s (%s): %s" % (self.objecttype, self.objectid, self.date, self.text[:50])
class Meta:
ordering = ('-date', )