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
authornishanth
Sat, 27 Feb 2010 10:48:43 +0530
changeset 128 f34e3a3e1439
parent 127 71888e23f323
child 129 e747da8bc110
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
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)