author | Madhusudan.C.S <madhusudancs@gmail.com> |
Sat, 08 Aug 2009 23:54:36 +0530 | |
changeset 18 | 05b9e60e6a10 |
parent 16 | bed14c9685a5 |
child 19 | 0c9bdcfac9f7 |
permissions | -rw-r--r-- |
0 | 1 |
"""This module contains the data model for the project funded by NME |
2 |
through ICT. |
|
3 |
""" |
|
4 |
||
5 |
||
6 |
__authors__ = [ |
|
7 |
'"Madhusudan.C.S" <madhusudancs@gmail.com>', |
|
8 |
] |
|
9 |
||
10 |
||
11 |
from django.db import models |
|
12 |
from django.contrib.auth.models import User |
|
13 |
||
14 |
||
15 |
class Project(models.Model): |
|
16 |
"""Model class for NME funded projects. |
|
17 |
""" |
|
18 |
||
19 |
LINE_ITEM_CHOICES = [('ME', 'Mechanical'), |
|
20 |
('CE', 'Chemical'), |
|
21 |
('EE', 'Electrical'), |
|
22 |
('AE', 'Aero Space'), |
|
23 |
('CS', 'Computer Science'), |
|
24 |
('IT', 'Information Technology'), |
|
25 |
] |
|
26 |
||
27 |
STATE_CHOICES = [('MH', 'Maharashtra'), |
|
28 |
('KA', 'Karnataka'), |
|
29 |
('KL', 'Kerala'), |
|
30 |
('TN', 'Tamil Nadu'), |
|
31 |
('AP', 'Andra Pradesh'), |
|
32 |
] |
|
33 |
||
34 |
DISTRICT_CHOICES = [('AD', 'Adilabad'), |
|
35 |
('RT', 'Ratnagiri'), |
|
36 |
('MU', 'Mumbai suburban'), |
|
37 |
('PU', 'Pune'), |
|
38 |
('PL', 'Palakkad'), |
|
39 |
('BN', 'Bangalore Urban district'), |
|
40 |
('CK', 'Chikmagalur District'), |
|
41 |
] |
|
42 |
||
43 |
# Field containing the Line Item to which the project belongs to. |
|
44 |
line_item = models.CharField(max_length=256, |
|
45 |
choices=LINE_ITEM_CHOICES) |
|
46 |
||
47 |
# Field containing the name of the institution working on the |
|
48 |
# project. |
|
49 |
institution = models.CharField(max_length=256) |
|
50 |
||
51 |
# Field containing the state to which the institution belongs to. |
|
52 |
state = models.CharField(max_length=256, |
|
53 |
choices=STATE_CHOICES) |
|
54 |
||
18
05b9e60e6a10
Changed CSS and removed Withdraw proposal.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
16
diff
changeset
|
55 |
mobile_num = models.CharField(max_length=20) |
05b9e60e6a10
Changed CSS and removed Withdraw proposal.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
16
diff
changeset
|
56 |
|
05b9e60e6a10
Changed CSS and removed Withdraw proposal.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
16
diff
changeset
|
57 |
fax_num = models.CharField(max_length=20, null=True) |
05b9e60e6a10
Changed CSS and removed Withdraw proposal.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
16
diff
changeset
|
58 |
|
0 | 59 |
# Field containing the district to which the institution belongs |
60 |
# to in the state of India. |
|
61 |
district = models.CharField(max_length=256, |
|
62 |
choices=DISTRICT_CHOICES) |
|
63 |
||
64 |
# Field containing the autogenerated MICR code for the project. |
|
65 |
micr_code = models.CharField(max_length=15, unique=True) |
|
66 |
||
67 |
# Field containing the status of the project. |
|
68 |
# status of the project can be one among the following |
|
69 |
# New, Revised, Funded, Pilot, DPE |
|
70 |
status = models.CharField(max_length=256, |
|
4
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
71 |
choices=[('new', 'New'), ('pilot', 'Pilot'), |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
72 |
('invalid', 'Invalid')]) |
0 | 73 |
|
16
bed14c9685a5
Project model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
4
diff
changeset
|
74 |
last_updated_on = models.DateTimeField(auto_now=True) |
bed14c9685a5
Project model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
4
diff
changeset
|
75 |
|
0 | 76 |
@classmethod |
77 |
def getLineItem(cls, code): |
|
78 |
"""Get the State name from its code. |
|
79 |
""" |
|
80 |
||
81 |
line_item_dict = dict(cls.LINE_ITEM_CHOICES) |
|
82 |
return line_item_dict[code] |
|
83 |
||
84 |
@classmethod |
|
4
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
85 |
def getLineItemCode(cls, name): |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
86 |
"""Get the Line Item code from its name. |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
87 |
""" |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
88 |
|
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
89 |
for ln_code, ln_name in cls.LINE_ITEM_CHOICES: |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
90 |
if ln_name == name: |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
91 |
return ln_code |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
92 |
|
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
93 |
return None |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
94 |
|
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
95 |
@classmethod |
0 | 96 |
def getState(cls, code): |
4
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
97 |
"""Get the State code from its name. |
0 | 98 |
""" |
99 |
||
100 |
state_dict = dict(cls.STATE_CHOICES) |
|
101 |
return state_dict[code] |
|
102 |
||
103 |
@classmethod |
|
4
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
104 |
def getStateCode(cls, name): |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
105 |
"""Get the State code from its name. |
0 | 106 |
""" |
107 |
||
4
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
108 |
for st_code, st_name in cls.STATE_CHOICES: |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
109 |
if st_name == name: |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
110 |
return st_code |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
111 |
|
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
112 |
return None |
0 | 113 |
|
114 |
@classmethod |
|
115 |
def getDistrict(cls, code): |
|
4
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
116 |
"""Get the District name from its code. |
0 | 117 |
""" |
118 |
||
119 |
district_dict = dict(cls.DISTRICT_CHOICES) |
|
120 |
return district_dict[code] |
|
121 |
||
4
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
122 |
@classmethod |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
123 |
def getDistrictCode(cls, name): |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
124 |
"""Get the District code from its name. |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
125 |
""" |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
126 |
|
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
127 |
for dt_code, dt_name in cls.DISTRICT_CHOICES: |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
128 |
if dt_name == name: |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
129 |
return dt_code |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
130 |
|
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
131 |
return None |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
132 |
|
0 | 133 |
class Proposal(models.Model): |
134 |
"""Model class for the project's proposal. |
|
135 |
""" |
|
136 |
||
137 |
#: Field representing the relation to the corresponding project. |
|
138 |
project = models.ForeignKey(Project) |
|
139 |
||
140 |
#: Field containing the Line Item to which the project belongs to. |
|
141 |
document = models.FileField(upload_to='proposals/%Y/%m/%d') |
|
142 |
||
143 |
#: Field containing the date on which the document was submitted |
|
144 |
submitted_on = models.DateTimeField(auto_now_add=True) |
|
145 |
||
146 |
#: Field containing the reference to the user who submitted the proposal. |
|
147 |
submitted_by = models.ForeignKey(User, null=True) |
|
148 |
||
149 |
#: Field containing the revision number of the proposal belonging to |
|
150 |
#: the Project. |
|
151 |
rev_num = models.PositiveIntegerField() |
|
152 |
||
153 |
||
154 |
class Timeline(models.Model): |
|
155 |
"""Model class for the project's timeline. |
|
156 |
""" |
|
157 |
||
158 |
#: Field representing the relation to the corresponding project. |
|
159 |
project = models.ForeignKey(Project) |
|
160 |
||
161 |
#: Field containing the date and time of submission of proposal. |
|
162 |
submitted = models.DateTimeField() |
|
163 |
||
164 |
#: Field containing the last date and time of review of proposal. |
|
165 |
reviewed = models.DateTimeField() |
|
166 |
||
167 |
#: Field containing the date and time of amount paid for the project. |
|
168 |
amount_paid = models.DateTimeField() |
|
169 |
||
170 |
#: Field containing the date and time of presentation of the project. |
|
171 |
presentation = models.DateTimeField() |
|
172 |
||
173 |
#: Field containing the date and time of monitoring of the project. |
|
174 |
monitoring = models.DateTimeField() |
|
175 |
||
176 |
||
177 |
class Fund(models.Model): |
|
178 |
"""Model class for the project's funds. |
|
179 |
""" |
|
180 |
||
181 |
#: Field representing the relation to the corresponding project. |
|
182 |
project = models.ForeignKey(Project) |
|
183 |
||
184 |
#: Field containing the amount sanctioned as funds for the project. |
|
185 |
sanctioned = models.FloatField() |
|
186 |
||
187 |
#: Field containing the expenses for the sanctioned fund for |
|
188 |
#: the project. |
|
189 |
expenses = models.FloatField() |
|
190 |
||
191 |
#: Field containing the date and time on which the funds were |
|
192 |
#: sanctioned for the project. |
|
193 |
sanctioned_on = models.DateTimeField(auto_now_add=True) |
|
194 |
||
195 |
||
196 |
class Review(models.Model): |
|
197 |
"""Model class for the project's proposal's review. |
|
198 |
""" |
|
199 |
||
200 |
#: Field representing the relation to the corresponding project. |
|
201 |
project = models.ForeignKey(Project) |
|
202 |
||
203 |
#: Field containing the comment entered along with the review. |
|
204 |
comment = models.TextField() |
|
205 |
||
206 |
#: Field representing the reference to the person who |
|
207 |
#: did the review. |
|
208 |
reviewer = models.ForeignKey(User, null=True) |
|
209 |
||
210 |
#: Field containing the date and time of review of the proposal. |
|
211 |
reviewed_on = models.DateTimeField(auto_now_add=True) |
|
212 |
||
213 |
#: Field containing the review value for this attribute. |
|
214 |
attribute1 = models.PositiveSmallIntegerField( |
|
215 |
choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)]) |
|
216 |
||
217 |
attribute2 = models.PositiveSmallIntegerField( |
|
218 |
choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)]) |
|
219 |
||
220 |
attribute3 = models.PositiveSmallIntegerField( |
|
221 |
choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)]) |
|
222 |
||
223 |
attribute4 = models.PositiveSmallIntegerField( |
|
224 |
choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)]) |
|
225 |
||
226 |
attribute5 = models.PositiveSmallIntegerField( |
|
227 |
choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)]) |
|
228 |
||
229 |
attribute6 = models.PositiveSmallIntegerField( |
|
230 |
choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)]) |
|
231 |
||
232 |
attribute7 = models.PositiveSmallIntegerField( |
|
233 |
choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)]) |
|
234 |
||
235 |
attribute8 = models.PositiveSmallIntegerField( |
|
236 |
choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)]) |
|
237 |
||
238 |
attribute9 = models.PositiveSmallIntegerField( |
|
239 |
choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)]) |