profile/models.py
author Nishanth Amuluru <nishanth@fossee.in>
Fri, 07 Jan 2011 13:37:38 +0530
changeset 291 5daf523e20b4
parent 278 60f363b6e9d8
child 299 8f50caa63cd1
permissions -rwxr-xr-x
added styles to base.css
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"),
249
82e13f7d5877 Included department co-ordinators as a level in hierarchy
Nishanth Amuluru <nishanth@fossee.in>
parents: 244
diff changeset
    10
        ("CR", "Co-ordinator"),
242
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    11
	("CT", "Contributor"),)
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    12
243
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    13
ROLE_CHOICES = (
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    14
	("DC", "Request sent by Director \
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    15
                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
    16
	("MG", "Request sent by Manager \
244
132217e04b32 Fixed a typo
Nishanth Amuluru <nishanth@fossee.in>
parents: 243
diff changeset
    17
                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
    18
242
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    19
class Profile(models.Model):
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    20
    
243
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    21
    uniq_key = models.CharField(max_length=20)
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    22
242
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    23
    user = models.ForeignKey(User, unique = True)
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    24
    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
    25
    pynts = models.PositiveSmallIntegerField(default = 0)
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    26
    
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    27
    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
    28
                               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
    29
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    30
    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
    31
    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
    32
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    33
    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
    34
                               be used to send any DDs/Cheques")
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    35
    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
    36
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    37
    def __unicode__(self):
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    38
        return unicode(self.user.username)
243
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    39
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    40
class Notification(models.Model):
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    41
    """ A model to hold notifications.
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    42
    All these are sent by the site to users.
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    43
    Hence there is no sent_from option.
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
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    46
    uniq_key = models.CharField(max_length=20)
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    47
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    48
    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
    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