# HG changeset patch # User Nishanth Amuluru # Date 1294314116 -19800 # Node ID 4c3aff34ae9cfe541e61b8077e0ef660f905ebc5 # Parent 93bee6c96c353e4bf20d6deb7f2e23a90c3b129d Created notification and request models. diff -r 93bee6c96c35 -r 4c3aff34ae9c 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) +