author | Madhusudan.C.S <madhusudancs@gmail.com> |
Mon, 17 Jan 2011 04:37:07 +0530 | |
changeset 440 | 56ea209e559f |
parent 438 | f861c753e55a |
child 444 | 92062f38d2c0 |
permissions | -rwxr-xr-x |
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 |
|
f861c753e55a
Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
403
diff
changeset
|
35 |
role = models.CharField(max_length=2, |
f861c753e55a
Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
403
diff
changeset
|
36 |
choices=ROLES_CHOICES, |
f861c753e55a
Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
403
diff
changeset
|
37 |
default=u"Contributor") |
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 |
|
f861c753e55a
Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
403
diff
changeset
|
49 |
gender = models.CharField(max_length=24, choices=GENDER_CHOICES) |
242
93bee6c96c35
Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents:
241
diff
changeset
|
50 |
|
438
f861c753e55a
Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
403
diff
changeset
|
51 |
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
|
52 |
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
|
53 |
"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
|
54 |
|
f861c753e55a
Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
403
diff
changeset
|
55 |
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
|
56 |
verbose_name = u"Phone Number") |
242
93bee6c96c35
Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents:
241
diff
changeset
|
57 |
|
93bee6c96c35
Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents:
241
diff
changeset
|
58 |
def __unicode__(self): |
93bee6c96c35
Added the model for holding user info
Nishanth Amuluru <nishanth@fossee.in>
parents:
241
diff
changeset
|
59 |
return unicode(self.user.username) |
243
4c3aff34ae9c
Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents:
242
diff
changeset
|
60 |
|
438
f861c753e55a
Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
403
diff
changeset
|
61 |
|
243
4c3aff34ae9c
Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents:
242
diff
changeset
|
62 |
class Notification(models.Model): |
4c3aff34ae9c
Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents:
242
diff
changeset
|
63 |
""" A model to hold notifications. |
4c3aff34ae9c
Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents:
242
diff
changeset
|
64 |
All these are sent by the site to users. |
4c3aff34ae9c
Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents:
242
diff
changeset
|
65 |
Hence there is no sent_from option. |
4c3aff34ae9c
Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents:
242
diff
changeset
|
66 |
""" |
4c3aff34ae9c
Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents:
242
diff
changeset
|
67 |
|
438
f861c753e55a
Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
403
diff
changeset
|
68 |
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
|
69 |
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
|
70 |
blank = False) |
243
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 |
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
|
73 |
|
243
4c3aff34ae9c
Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents:
242
diff
changeset
|
74 |
message = models.TextField() |
4c3aff34ae9c
Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents:
242
diff
changeset
|
75 |
|
4c3aff34ae9c
Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents:
242
diff
changeset
|
76 |
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
|
77 |
|
243
4c3aff34ae9c
Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents:
242
diff
changeset
|
78 |
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
|
79 |
|
243
4c3aff34ae9c
Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents:
242
diff
changeset
|
80 |
is_deleted = models.BooleanField(default = False) |
4c3aff34ae9c
Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents:
242
diff
changeset
|
81 |
|
438
f861c753e55a
Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
403
diff
changeset
|
82 |
|
243
4c3aff34ae9c
Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents:
242
diff
changeset
|
83 |
class RoleRequest(models.Model): |
4c3aff34ae9c
Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents:
242
diff
changeset
|
84 |
""" A request sent by one user to the other. |
4c3aff34ae9c
Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents:
242
diff
changeset
|
85 |
Typically requesting to raise one's status. |
4c3aff34ae9c
Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents:
242
diff
changeset
|
86 |
""" |
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 |
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
|
89 |
|
243
4c3aff34ae9c
Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents:
242
diff
changeset
|
90 |
is_accepted = models.BooleanField(default=False) |
4c3aff34ae9c
Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents:
242
diff
changeset
|
91 |
|
4c3aff34ae9c
Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents:
242
diff
changeset
|
92 |
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
|
93 |
|
243
4c3aff34ae9c
Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents:
242
diff
changeset
|
94 |
response = models.TextField() |
4c3aff34ae9c
Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents:
242
diff
changeset
|
95 |
|
438
f861c753e55a
Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
403
diff
changeset
|
96 |
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
|
97 |
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
|
98 |
null = True, blank = True) |
243
4c3aff34ae9c
Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents:
242
diff
changeset
|
99 |
|
4c3aff34ae9c
Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents:
242
diff
changeset
|
100 |
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
|
101 |
|
243
4c3aff34ae9c
Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents:
242
diff
changeset
|
102 |
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
|
103 |
|
243
4c3aff34ae9c
Created notification and request models.
Nishanth Amuluru <nishanth@fossee.in>
parents:
242
diff
changeset
|
104 |
is_deleted = models.BooleanField(default = False) |