# HG changeset patch # User nishanth # Date 1267247923 -19800 # Node ID f34e3a3e1439b66819895065655ac3fe741da4fa # Parent 71888e23f323170cf71d7dfcf9b82e8ed2aea511 modified the notifications model. the sent_to is now a foreign key. now if we have a new type to be added, we can generate message and sub while creating notification. we can keep track of history using the role field in notification and task/sent_from diff -r 71888e23f323 -r f34e3a3e1439 taskapp/models.py --- a/taskapp/models.py Sat Feb 27 01:27:35 2010 +0530 +++ b/taskapp/models.py Sat Feb 27 10:48:43 2010 +0530 @@ -25,6 +25,20 @@ ("DL", "Deleted"), ("CM", "Completed")) +NOTIFY_CHOICES = ( + ("MT", "Add Mentor"), + ("DV", "Developer"), + ("MG", "Manager"), + ("AD", "Admin"), + ("PY", "Assign credits"), + ("CM", "Task completed"), + ("CD", "Task closed"), + ("DL", "Task deleted"), + ("KD", "Kicked off"), + ("MS", "Message"), +) + + IMAGES_DIR = "./images" UPLOADS_DIR = "./uploads" @@ -156,11 +170,15 @@ class Notification(models.Model): - sent_to = models.ManyToManyField(User, related_name = "%(class)s_sent_to", blank = False) - sent_from = models.ManyToManyField(User, related_name = "%(class)s_sent_from", blank = True) + role = models.CharField(max_length = 2, choices = NOTIFY_CHOICES, blank = False) + sent_to = models.ForeignKey(User, related_name = "%(class)s_sent_to", blank = False) + sent_from = models.ForeignKey(User, related_name = "%(class)s_sent_from", blank = True) + task = models.ForeignKey(Task, related_name = "%(class)s_sent_for", blank = False) + sub = models.CharField(max_length = 100) message = models.TextField() + remark = models.CharField(max_length = 100) sent_date = models.DateTimeField() is_read = models.BooleanField(default = False)