Created notification and request models.
authorNishanth Amuluru <nishanth@fossee.in>
Thu, 06 Jan 2011 17:11:56 +0530
changeset 243 4c3aff34ae9c
parent 242 93bee6c96c35
child 244 132217e04b32
Created notification and request models.
profile/models.py
--- a/profile/models.py	Thu Jan 06 16:48:29 2011 +0530
+++ b/profile/models.py	Thu Jan 06 17:11:56 2011 +0530
@@ -9,8 +9,16 @@
 	("MG", "Manager"),
 	("CT", "Contributor"),)
 
+ROLE_CHOICES = (
+	("DC", "Request sent by Director \
+                to a user at lower level, asking him to act as a director"),
+	("MG", "Request sent by Manager \
+                to a user at lower level, asking him to act as a manager"),
+
 class Profile(models.Model):
     
+    uniq_key = models.CharField(max_length=20)
+
     user = models.ForeignKey(User, unique = True)
     rights = models.CharField(max_length = 2, choices = RIGHTS_CHOICES, default = u"CT")
     pynts = models.PositiveSmallIntegerField(default = 0)
@@ -27,3 +35,41 @@
 
     def __unicode__(self):
         return unicode(self.user.username)
+
+class Notification(models.Model):
+    """ A model to hold notifications.
+    All these are sent by the site to users.
+    Hence there is no sent_from option.
+    """
+
+    uniq_key = models.CharField(max_length=20)
+
+    sent_to = models.ForeignKey(User, related_name = "%(class)s_sent_to", blank = False)
+    sent_from = models.ForeignKey(User, related_name = "%(class)s_sent_from", null = True, blank = True)
+
+    subject = models.CharField(max_length=100, blank=True)
+    message = models.TextField()
+
+    sent_date = models.DateTimeField()
+    is_read = models.BooleanField(default = False)
+    is_deleted = models.BooleanField(default = False)
+
+class RoleRequest(models.Model):
+    """ A request sent by one user to the other.
+    Typically requesting to raise one's status.
+    """
+
+    uniq_key = models.CharField(max_length=20)
+    role = models.CharField(max_length=2, choices=ROLE_CHOICES)
+    is_accepted = models.BooleanField(default=False)
+
+    message = models.TextField()
+    response = models.TextField()
+
+    sent_to = models.ForeignKey(User, related_name = "%(class)s_sent_to", blank = False)
+    sent_from = models.ForeignKey(User, related_name = "%(class)s_sent_from", null = True, blank = True)
+
+    sent_date = models.DateTimeField()
+    is_read = models.BooleanField(default = False)
+    is_deleted = models.BooleanField(default = False)
+