--- a/app/projrev/models.py Thu Aug 06 12:17:29 2009 +0530
+++ b/app/projrev/models.py Thu Aug 06 18:15:57 2009 +0530
@@ -64,15 +64,8 @@
# status of the project can be one among the following
# New, Revised, Funded, Pilot, DPE
status = models.CharField(max_length=256,
- choices=[('new', 'New'), ('pilot', 'Pilot')])
-
- @classmethod
- def getLineItem(cls, code):
- """Get the State name from its code.
- """
-
- line_item_dict = dict(cls.LINE_ITEM_CHOICES)
- return line_item_dict[code]
+ choices=[('new', 'New'), ('pilot', 'Pilot'),
+ ('invalid', 'Invalid')])
@classmethod
def getLineItem(cls, code):
@@ -83,29 +76,54 @@
return line_item_dict[code]
@classmethod
+ def getLineItemCode(cls, name):
+ """Get the Line Item code from its name.
+ """
+
+ for ln_code, ln_name in cls.LINE_ITEM_CHOICES:
+ if ln_name == name:
+ return ln_code
+
+ return None
+
+ @classmethod
def getState(cls, code):
- """Get the State name from its code.
+ """Get the State code from its name.
"""
state_dict = dict(cls.STATE_CHOICES)
return state_dict[code]
@classmethod
- def getState(cls, code):
- """Get the State name from its code.
+ def getStateCode(cls, name):
+ """Get the State code from its name.
"""
- state_dict = dict(cls.STATE_CHOICES)
- return state_dict[code]
+ for st_code, st_name in cls.STATE_CHOICES:
+ if st_name == name:
+ return st_code
+
+ return None
@classmethod
def getDistrict(cls, code):
- """Get the State name from its code.
+ """Get the District name from its code.
"""
district_dict = dict(cls.DISTRICT_CHOICES)
return district_dict[code]
+ @classmethod
+ def getDistrictCode(cls, name):
+ """Get the District code from its name.
+ """
+
+ for dt_code, dt_name in cls.DISTRICT_CHOICES:
+ if dt_name == name:
+ return dt_code
+
+ return None
+
class Proposal(models.Model):
"""Model class for the project's proposal.
"""