pytask/profile/models.py
author Madhusudan.C.S <madhusudancs@gmail.com>
Fri, 28 Jan 2011 02:27:40 +0530
changeset 519 84709567f47a
parent 472 f9011a1dfe1c
permissions -rwxr-xr-x
Use the release version of South than the latest version. South is very critical for our application. So don't take any risk with the users data. Use the release version.
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
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
     5
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
     6
GENDER_CHOICES = (
440
56ea209e559f Use the right form of names to be stored in the database.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
     7
  ('Male', 'Male'),
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
     8
  ('Female', 'Female'),
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
     9
)
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    10
242
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    11
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    12
ROLES_CHOICES = (
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    13
  ("Administrator", "Administrator"),
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    14
  ("Coordinator", "Coordinator"),
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    15
  ("Mentor", "Mentor"),
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    16
  ("Contributor", "Contributor"),
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    17
)
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    18
242
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
ROLE_CHOICES = (
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    21
  ("Administrator", "Request sent by Administrator \
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    22
    to a user at lower level, asking him to act as a administrator"),
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    23
  ("Coordinator", "Request sent by Coordinator \
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    24
    to a user at lower level, asking him to act as a coordinator"),
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    25
)
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    26
243
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    27
242
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    28
class Profile(models.Model):
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    29
    full_name = models.CharField(
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    30
      max_length=50, verbose_name="Name as on bank account",
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    31
      help_text="Any DD/Cheque will be issued on this name")
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    32
242
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    33
    user = models.ForeignKey(User, unique = True)
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    34
444
92062f38d2c0 Fix style issue in the profile model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 440
diff changeset
    35
    role = models.CharField(max_length=255,
92062f38d2c0 Fix style issue in the profile model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 440
diff changeset
    36
                            choices=ROLES_CHOICES,
92062f38d2c0 Fix style issue in the profile model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 440
diff changeset
    37
                            default=u"Contributor")
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    38
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    39
    pynts = models.PositiveSmallIntegerField(default=0)
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    40
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    41
    aboutme = models.TextField(
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    42
      blank = True,
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    43
      help_text="This information will be used to judge the eligibility "
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    44
        "for any task")
242
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    45
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    46
    dob = models.DateField(verbose_name=u"Date of Birth",
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    47
                           help_text="YYYY-MM-DD")
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    48
463
c7c595c0bed3 Make changes to the code style so that it is consistent across the code base.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 444
diff changeset
    49
    gender = models.CharField(verbose_name=u'Gender',
c7c595c0bed3 Make changes to the code style so that it is consistent across the code base.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 444
diff changeset
    50
                              max_length=24, choices=GENDER_CHOICES)
242
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    51
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    52
    address = models.TextField(
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    53
      blank=False, help_text="This information will be used to send "
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    54
        "any DDs/Cheques.")
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    55
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    56
    phonenum = models.CharField(max_length = 15, blank = True,
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    57
                                verbose_name = u"Phone Number")
242
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    58
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    59
    def __unicode__(self):
93bee6c96c35 Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents: 241
diff changeset
    60
        return unicode(self.user.username)
243
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    61
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    62
243
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    63
class Notification(models.Model):
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    64
    """ A model to hold notifications.
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    65
    All these are sent by the site to users.
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    66
    Hence there is no sent_from option.
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    67
    """
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    68
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    69
    sent_to = models.ForeignKey(User,
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    70
                                related_name = "%(class)s_sent_to",
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    71
                                blank = False)
243
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    72
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    73
    subject = models.CharField(max_length=100, blank=True)
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    74
243
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    75
    message = models.TextField()
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    76
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    77
    sent_date = models.DateTimeField()
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    78
243
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    79
    is_read = models.BooleanField(default = False)
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    80
243
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    81
    is_deleted = models.BooleanField(default = False)
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    82
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    83
243
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    84
class RoleRequest(models.Model):
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    85
    """ A request sent by one user to the other.
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    86
    Typically requesting to raise one's status.
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    87
    """
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    88
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    89
    role = models.CharField(max_length=2, choices=ROLE_CHOICES)
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    90
243
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    91
    is_accepted = models.BooleanField(default=False)
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    92
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    93
    message = models.TextField()
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    94
243
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    95
    response = models.TextField()
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
    96
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    97
    sent_from = models.ForeignKey(User,
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    98
                                  related_name = "%(class)s_sent_from",
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    99
                                  null = True, blank = True)
243
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
   100
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
   101
    sent_date = models.DateTimeField()
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
   102
243
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
   103
    is_read = models.BooleanField(default = False)
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
   104
243
4c3aff34ae9c Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents: 242
diff changeset
   105
    is_deleted = models.BooleanField(default = False)