profile/models.py
changeset 243 4c3aff34ae9c
parent 242 93bee6c96c35
child 244 132217e04b32
equal deleted inserted replaced
242:93bee6c96c35 243:4c3aff34ae9c
     7 RIGHTS_CHOICES = (
     7 RIGHTS_CHOICES = (
     8 	("DC", "Director"),
     8 	("DC", "Director"),
     9 	("MG", "Manager"),
     9 	("MG", "Manager"),
    10 	("CT", "Contributor"),)
    10 	("CT", "Contributor"),)
    11 
    11 
       
    12 ROLE_CHOICES = (
       
    13 	("DC", "Request sent by Director \
       
    14                 to a user at lower level, asking him to act as a director"),
       
    15 	("MG", "Request sent by Manager \
       
    16                 to a user at lower level, asking him to act as a manager"),
       
    17 
    12 class Profile(models.Model):
    18 class Profile(models.Model):
    13     
    19     
       
    20     uniq_key = models.CharField(max_length=20)
       
    21 
    14     user = models.ForeignKey(User, unique = True)
    22     user = models.ForeignKey(User, unique = True)
    15     rights = models.CharField(max_length = 2, choices = RIGHTS_CHOICES, default = u"CT")
    23     rights = models.CharField(max_length = 2, choices = RIGHTS_CHOICES, default = u"CT")
    16     pynts = models.PositiveSmallIntegerField(default = 0)
    24     pynts = models.PositiveSmallIntegerField(default = 0)
    17     
    25     
    18     aboutme = models.TextField(blank = True, help_text="This information will\
    26     aboutme = models.TextField(blank = True, help_text="This information will\
    25                                be used to send any DDs/Cheques")
    33                                be used to send any DDs/Cheques")
    26     phonenum = models.CharField(max_length = 15, blank = True, verbose_name = u"Phone Number")
    34     phonenum = models.CharField(max_length = 15, blank = True, verbose_name = u"Phone Number")
    27 
    35 
    28     def __unicode__(self):
    36     def __unicode__(self):
    29         return unicode(self.user.username)
    37         return unicode(self.user.username)
       
    38 
       
    39 class Notification(models.Model):
       
    40     """ A model to hold notifications.
       
    41     All these are sent by the site to users.
       
    42     Hence there is no sent_from option.
       
    43     """
       
    44 
       
    45     uniq_key = models.CharField(max_length=20)
       
    46 
       
    47     sent_to = models.ForeignKey(User, related_name = "%(class)s_sent_to", blank = False)
       
    48     sent_from = models.ForeignKey(User, related_name = "%(class)s_sent_from", null = True, blank = True)
       
    49 
       
    50     subject = models.CharField(max_length=100, blank=True)
       
    51     message = models.TextField()
       
    52 
       
    53     sent_date = models.DateTimeField()
       
    54     is_read = models.BooleanField(default = False)
       
    55     is_deleted = models.BooleanField(default = False)
       
    56 
       
    57 class RoleRequest(models.Model):
       
    58     """ A request sent by one user to the other.
       
    59     Typically requesting to raise one's status.
       
    60     """
       
    61 
       
    62     uniq_key = models.CharField(max_length=20)
       
    63     role = models.CharField(max_length=2, choices=ROLE_CHOICES)
       
    64     is_accepted = models.BooleanField(default=False)
       
    65 
       
    66     message = models.TextField()
       
    67     response = models.TextField()
       
    68 
       
    69     sent_to = models.ForeignKey(User, related_name = "%(class)s_sent_to", blank = False)
       
    70     sent_from = models.ForeignKey(User, related_name = "%(class)s_sent_from", null = True, blank = True)
       
    71 
       
    72     sent_date = models.DateTimeField()
       
    73     is_read = models.BooleanField(default = False)
       
    74     is_deleted = models.BooleanField(default = False)
       
    75