profile/models.py
author Nishanth Amuluru <nishanth@fossee.in>
Fri, 07 Jan 2011 09:22:40 +0530
changeset 16 5c000bf6f241
parent 11 82e13f7d5877
child 40 60f363b6e9d8
permissions -rwxr-xr-x
Fixed a few typos
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3
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
4
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 3
diff changeset
     3
from django.contrib.auth.models import User
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 3
diff changeset
     4
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 3
diff changeset
     5
GENDER_CHOICES = (( 'M', 'Male'), ('F', 'Female'))
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 3
diff changeset
     6
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 3
diff changeset
     7
RIGHTS_CHOICES = (
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 3
diff changeset
     8
	("DC", "Director"),
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 3
diff changeset
     9
	("MG", "Manager"),
11
82e13f7d5877 Included department co-ordinators as a level in hierarchy
Nishanth Amuluru <nishanth@fossee.in>
parents: 6
diff changeset
    10
        ("CR", "Co-ordinator"),
4
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 3
diff changeset
    11
	("CT", "Contributor"),)
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 3
diff changeset
    12
5
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    13
ROLE_CHOICES = (
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    14
	("DC", "Request sent by Director \
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
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: 4
diff changeset
    16
	("MG", "Request sent by Manager \
6
132217e04b32 Fixed a typo
Nishanth Amuluru <nishanth@fossee.in>
parents: 5
diff changeset
    17
                to a user at lower level, asking him to act as a manager"),)
5
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    18
4
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 3
diff changeset
    19
class Profile(models.Model):
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 3
diff changeset
    20
    
5
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    21
    uniq_key = models.CharField(max_length=20)
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    22
4
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 3
diff changeset
    23
    user = models.ForeignKey(User, unique = True)
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 3
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: 3
diff changeset
    25
    pynts = models.PositiveSmallIntegerField(default = 0)
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 3
diff changeset
    26
    
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 3
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: 3
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: 3
diff changeset
    29
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 3
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: 3
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: 3
diff changeset
    32
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 3
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: 3
diff changeset
    34
                               be used to send any DDs/Cheques")
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 3
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: 3
diff changeset
    36
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 3
diff changeset
    37
    def __unicode__(self):
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 3
diff changeset
    38
        return unicode(self.user.username)
5
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    39
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    40
class Notification(models.Model):
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    41
    """ A model to hold notifications.
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    42
    All these are sent by the site to users.
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    43
    Hence there is no sent_from option.
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    44
    """
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    45
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    46
    uniq_key = models.CharField(max_length=20)
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    47
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
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: 4
diff changeset
    49
    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: 4
diff changeset
    50
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    51
    subject = models.CharField(max_length=100, blank=True)
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    52
    message = models.TextField()
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    53
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    54
    sent_date = models.DateTimeField()
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    55
    is_read = models.BooleanField(default = False)
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    56
    is_deleted = models.BooleanField(default = False)
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    57
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    58
class RoleRequest(models.Model):
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    59
    """ A request sent by one user to the other.
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    60
    Typically requesting to raise one's status.
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    61
    """
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    62
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    63
    uniq_key = models.CharField(max_length=20)
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    64
    role = models.CharField(max_length=2, choices=ROLE_CHOICES)
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    65
    is_accepted = models.BooleanField(default=False)
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    66
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    67
    message = models.TextField()
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    68
    response = models.TextField()
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    69
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    70
    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: 4
diff changeset
    71
    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: 4
diff changeset
    72
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    73
    sent_date = models.DateTimeField()
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    74
    is_read = models.BooleanField(default = False)
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    75
    is_deleted = models.BooleanField(default = False)
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 4
diff changeset
    76