author | Madhusudan.C.S <madhusudancs@gmail.com> |
Fri, 07 Aug 2009 01:03:56 +0530 | |
changeset 12 | aac4944aca52 |
parent 4 | 8d9da911ed7d |
child 16 | bed14c9685a5 |
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 |
||
55 |
# Field containing the district to which the institution belongs |
|
56 |
# to in the state of India. |
|
57 |
district = models.CharField(max_length=256, |
|
58 |
choices=DISTRICT_CHOICES) |
|
59 |
||
60 |
# Field containing the autogenerated MICR code for the project. |
|
61 |
micr_code = models.CharField(max_length=15, unique=True) |
|
62 |
||
63 |
# Field containing the status of the project. |
|
64 |
# status of the project can be one among the following |
|
65 |
# New, Revised, Funded, Pilot, DPE |
|
66 |
status = models.CharField(max_length=256, |
|
4
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
67 |
choices=[('new', 'New'), ('pilot', 'Pilot'), |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
68 |
('invalid', 'Invalid')]) |
0 | 69 |
|
70 |
@classmethod |
|
71 |
def getLineItem(cls, code): |
|
72 |
"""Get the State name from its code. |
|
73 |
""" |
|
74 |
||
75 |
line_item_dict = dict(cls.LINE_ITEM_CHOICES) |
|
76 |
return line_item_dict[code] |
|
77 |
||
78 |
@classmethod |
|
4
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
79 |
def getLineItemCode(cls, name): |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
80 |
"""Get the Line Item code from its name. |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
81 |
""" |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
82 |
|
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
83 |
for ln_code, ln_name in cls.LINE_ITEM_CHOICES: |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
84 |
if ln_name == name: |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
85 |
return ln_code |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
86 |
|
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
87 |
return None |
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 |
@classmethod |
0 | 90 |
def getState(cls, code): |
4
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
91 |
"""Get the State code from its name. |
0 | 92 |
""" |
93 |
||
94 |
state_dict = dict(cls.STATE_CHOICES) |
|
95 |
return state_dict[code] |
|
96 |
||
97 |
@classmethod |
|
4
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
98 |
def getStateCode(cls, name): |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
99 |
"""Get the State code from its name. |
0 | 100 |
""" |
101 |
||
4
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
102 |
for st_code, st_name in cls.STATE_CHOICES: |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
103 |
if st_name == name: |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
104 |
return st_code |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
105 |
|
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
106 |
return None |
0 | 107 |
|
108 |
@classmethod |
|
109 |
def getDistrict(cls, code): |
|
4
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
110 |
"""Get the District name from its code. |
0 | 111 |
""" |
112 |
||
113 |
district_dict = dict(cls.DISTRICT_CHOICES) |
|
114 |
return district_dict[code] |
|
115 |
||
4
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
116 |
@classmethod |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
117 |
def getDistrictCode(cls, name): |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
118 |
"""Get the District code from its name. |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
119 |
""" |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
120 |
|
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
121 |
for dt_code, dt_name in cls.DISTRICT_CHOICES: |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
122 |
if dt_name == name: |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
123 |
return dt_code |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
124 |
|
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
125 |
return None |
8d9da911ed7d
Withdraw of proposals.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
0
diff
changeset
|
126 |
|
0 | 127 |
class Proposal(models.Model): |
128 |
"""Model class for the project's proposal. |
|
129 |
""" |
|
130 |
||
131 |
#: Field representing the relation to the corresponding project. |
|
132 |
project = models.ForeignKey(Project) |
|
133 |
||
134 |
#: Field containing the Line Item to which the project belongs to. |
|
135 |
document = models.FileField(upload_to='proposals/%Y/%m/%d') |
|
136 |
||
137 |
#: Field containing the date on which the document was submitted |
|
138 |
submitted_on = models.DateTimeField(auto_now_add=True) |
|
139 |
||
140 |
#: Field containing the reference to the user who submitted the proposal. |
|
141 |
submitted_by = models.ForeignKey(User, null=True) |
|
142 |
||
143 |
#: Field containing the revision number of the proposal belonging to |
|
144 |
#: the Project. |
|
145 |
rev_num = models.PositiveIntegerField() |
|
146 |
||
147 |
||
148 |
class Timeline(models.Model): |
|
149 |
"""Model class for the project's timeline. |
|
150 |
""" |
|
151 |
||
152 |
#: Field representing the relation to the corresponding project. |
|
153 |
project = models.ForeignKey(Project) |
|
154 |
||
155 |
#: Field containing the date and time of submission of proposal. |
|
156 |
submitted = models.DateTimeField() |
|
157 |
||
158 |
#: Field containing the last date and time of review of proposal. |
|
159 |
reviewed = models.DateTimeField() |
|
160 |
||
161 |
#: Field containing the date and time of amount paid for the project. |
|
162 |
amount_paid = models.DateTimeField() |
|
163 |
||
164 |
#: Field containing the date and time of presentation of the project. |
|
165 |
presentation = models.DateTimeField() |
|
166 |
||
167 |
#: Field containing the date and time of monitoring of the project. |
|
168 |
monitoring = models.DateTimeField() |
|
169 |
||
170 |
||
171 |
class Fund(models.Model): |
|
172 |
"""Model class for the project's funds. |
|
173 |
""" |
|
174 |
||
175 |
#: Field representing the relation to the corresponding project. |
|
176 |
project = models.ForeignKey(Project) |
|
177 |
||
178 |
#: Field containing the amount sanctioned as funds for the project. |
|
179 |
sanctioned = models.FloatField() |
|
180 |
||
181 |
#: Field containing the expenses for the sanctioned fund for |
|
182 |
#: the project. |
|
183 |
expenses = models.FloatField() |
|
184 |
||
185 |
#: Field containing the date and time on which the funds were |
|
186 |
#: sanctioned for the project. |
|
187 |
sanctioned_on = models.DateTimeField(auto_now_add=True) |
|
188 |
||
189 |
||
190 |
class Review(models.Model): |
|
191 |
"""Model class for the project's proposal's review. |
|
192 |
""" |
|
193 |
||
194 |
#: Field representing the relation to the corresponding project. |
|
195 |
project = models.ForeignKey(Project) |
|
196 |
||
197 |
#: Field containing the comment entered along with the review. |
|
198 |
comment = models.TextField() |
|
199 |
||
200 |
#: Field representing the reference to the person who |
|
201 |
#: did the review. |
|
202 |
reviewer = models.ForeignKey(User, null=True) |
|
203 |
||
204 |
#: Field containing the date and time of review of the proposal. |
|
205 |
reviewed_on = models.DateTimeField(auto_now_add=True) |
|
206 |
||
207 |
#: Field containing the review value for this attribute. |
|
208 |
attribute1 = models.PositiveSmallIntegerField( |
|
209 |
choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)]) |
|
210 |
||
211 |
attribute2 = models.PositiveSmallIntegerField( |
|
212 |
choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)]) |
|
213 |
||
214 |
attribute3 = models.PositiveSmallIntegerField( |
|
215 |
choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)]) |
|
216 |
||
217 |
attribute4 = models.PositiveSmallIntegerField( |
|
218 |
choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)]) |
|
219 |
||
220 |
attribute5 = models.PositiveSmallIntegerField( |
|
221 |
choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)]) |
|
222 |
||
223 |
attribute6 = models.PositiveSmallIntegerField( |
|
224 |
choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)]) |
|
225 |
||
226 |
attribute7 = models.PositiveSmallIntegerField( |
|
227 |
choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)]) |
|
228 |
||
229 |
attribute8 = models.PositiveSmallIntegerField( |
|
230 |
choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)]) |
|
231 |
||
232 |
attribute9 = models.PositiveSmallIntegerField( |
|
233 |
choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)]) |