profile/models.py
author Nishanth Amuluru <nishanth@fossee.in>
Thu, 06 Jan 2011 17:21:06 +0530
changeset 245 9e963a791df1
parent 244 132217e04b32
child 249 82e13f7d5877
permissions -rwxr-xr-x
Added profile module to settings
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
241
479cbf5c822a Added an app called profile to manage user profiles
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
     1
from django.db import models
479cbf5c822a Added an app called profile to manage user profiles
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
     2
242
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
     3
from django.contrib.auth.models import User
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
     4
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
     5
GENDER_CHOICES = (( 'M', 'Male'), ('F', 'Female'))
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
     6
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
     7
RIGHTS_CHOICES = (
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
     8
	("DC", "Director"),
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
     9
	("MG", "Manager"),
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    10
	("CT", "Contributor"),)
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    11
243
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    12
ROLE_CHOICES = (
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    13
	("DC", "Request sent by Director \
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    14
                to a user at lower level, asking him to act as a director"),
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    15
	("MG", "Request sent by Manager \
244
132217e04b32 Fixed a typo
Nishanth Amuluru <nishanth@fossee.in>
parents: 243
diff changeset
    16
                to a user at lower level, asking him to act as a manager"),)
243
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    17
242
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    18
class Profile(models.Model):
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    19
    
243
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    20
    uniq_key = models.CharField(max_length=20)
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    21
242
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    22
    user = models.ForeignKey(User, unique = True)
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    23
    rights = models.CharField(max_length = 2, choices = RIGHTS_CHOICES, default = u"CT")
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    24
    pynts = models.PositiveSmallIntegerField(default = 0)
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    25
    
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    26
    aboutme = models.TextField(blank = True, help_text="This information will\
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    27
                               be used to judge the eligibility for any task")
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    28
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    29
    dob = models.DateField(verbose_name = u"Date of Birth", help_text = "YYYY-MM-DD")
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    30
    gender = models.CharField(max_length = 1, choices = GENDER_CHOICES)
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    31
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    32
    address = models.TextField(blank = False, help_text="This information will\
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    33
                               be used to send any DDs/Cheques")
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    34
    phonenum = models.CharField(max_length = 15, blank = True, verbose_name = u"Phone Number")
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    35
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    36
    def __unicode__(self):
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    37
        return unicode(self.user.username)
243
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    38
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    39
class Notification(models.Model):
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    40
    """ A model to hold notifications.
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    41
    All these are sent by the site to users.
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    42
    Hence there is no sent_from option.
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    43
    """
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    44
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    45
    uniq_key = models.CharField(max_length=20)
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    46
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    47
    sent_to = models.ForeignKey(User, related_name = "%(class)s_sent_to", blank = False)
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    48
    sent_from = models.ForeignKey(User, related_name = "%(class)s_sent_from", null = True, blank = True)
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    49
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    50
    subject = models.CharField(max_length=100, blank=True)
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    51
    message = models.TextField()
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    52
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    53
    sent_date = models.DateTimeField()
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    54
    is_read = models.BooleanField(default = False)
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    55
    is_deleted = models.BooleanField(default = False)
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    56
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    57
class RoleRequest(models.Model):
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    58
    """ A request sent by one user to the other.
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    59
    Typically requesting to raise one's status.
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    60
    """
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    61
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    62
    uniq_key = models.CharField(max_length=20)
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    63
    role = models.CharField(max_length=2, choices=ROLE_CHOICES)
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    64
    is_accepted = models.BooleanField(default=False)
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    65
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    66
    message = models.TextField()
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    67
    response = models.TextField()
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    68
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    69
    sent_to = models.ForeignKey(User, related_name = "%(class)s_sent_to", blank = False)
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    70
    sent_from = models.ForeignKey(User, related_name = "%(class)s_sent_from", null = True, blank = True)
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    71
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    72
    sent_date = models.DateTimeField()
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    73
    is_read = models.BooleanField(default = False)
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    74
    is_deleted = models.BooleanField(default = False)
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    75