62 |
62 |
63 # Field containing the status of the project. |
63 # Field containing the status of the project. |
64 # status of the project can be one among the following |
64 # status of the project can be one among the following |
65 # New, Revised, Funded, Pilot, DPE |
65 # New, Revised, Funded, Pilot, DPE |
66 status = models.CharField(max_length=256, |
66 status = models.CharField(max_length=256, |
67 choices=[('new', 'New'), ('pilot', 'Pilot')]) |
67 choices=[('new', 'New'), ('pilot', 'Pilot'), |
|
68 ('invalid', 'Invalid')]) |
68 |
69 |
69 @classmethod |
70 @classmethod |
70 def getLineItem(cls, code): |
71 def getLineItem(cls, code): |
71 """Get the State name from its code. |
72 """Get the State name from its code. |
72 """ |
73 """ |
73 |
74 |
74 line_item_dict = dict(cls.LINE_ITEM_CHOICES) |
75 line_item_dict = dict(cls.LINE_ITEM_CHOICES) |
75 return line_item_dict[code] |
76 return line_item_dict[code] |
76 |
77 |
77 @classmethod |
78 @classmethod |
78 def getLineItem(cls, code): |
79 def getLineItemCode(cls, name): |
79 """Get the State name from its code. |
80 """Get the Line Item code from its name. |
80 """ |
81 """ |
81 |
82 |
82 line_item_dict = dict(cls.LINE_ITEM_CHOICES) |
83 for ln_code, ln_name in cls.LINE_ITEM_CHOICES: |
83 return line_item_dict[code] |
84 if ln_name == name: |
|
85 return ln_code |
|
86 |
|
87 return None |
84 |
88 |
85 @classmethod |
89 @classmethod |
86 def getState(cls, code): |
90 def getState(cls, code): |
87 """Get the State name from its code. |
91 """Get the State code from its name. |
88 """ |
92 """ |
89 |
93 |
90 state_dict = dict(cls.STATE_CHOICES) |
94 state_dict = dict(cls.STATE_CHOICES) |
91 return state_dict[code] |
95 return state_dict[code] |
92 |
96 |
93 @classmethod |
97 @classmethod |
94 def getState(cls, code): |
98 def getStateCode(cls, name): |
95 """Get the State name from its code. |
99 """Get the State code from its name. |
96 """ |
100 """ |
97 |
101 |
98 state_dict = dict(cls.STATE_CHOICES) |
102 for st_code, st_name in cls.STATE_CHOICES: |
99 return state_dict[code] |
103 if st_name == name: |
|
104 return st_code |
|
105 |
|
106 return None |
100 |
107 |
101 @classmethod |
108 @classmethod |
102 def getDistrict(cls, code): |
109 def getDistrict(cls, code): |
103 """Get the State name from its code. |
110 """Get the District name from its code. |
104 """ |
111 """ |
105 |
112 |
106 district_dict = dict(cls.DISTRICT_CHOICES) |
113 district_dict = dict(cls.DISTRICT_CHOICES) |
107 return district_dict[code] |
114 return district_dict[code] |
|
115 |
|
116 @classmethod |
|
117 def getDistrictCode(cls, name): |
|
118 """Get the District code from its name. |
|
119 """ |
|
120 |
|
121 for dt_code, dt_name in cls.DISTRICT_CHOICES: |
|
122 if dt_name == name: |
|
123 return dt_code |
|
124 |
|
125 return None |
108 |
126 |
109 class Proposal(models.Model): |
127 class Proposal(models.Model): |
110 """Model class for the project's proposal. |
128 """Model class for the project's proposal. |
111 """ |
129 """ |
112 |
130 |