app/projrev/models.py
changeset 21 153db75bb515
parent 19 0c9bdcfac9f7
child 22 0321f984fb16
--- a/app/projrev/models.py	Sun Aug 09 12:40:14 2009 +0530
+++ b/app/projrev/models.py	Sun Aug 09 13:04:03 2009 +0530
@@ -704,16 +704,15 @@
     """Get the State name from its code.
     """
 
-    line_item_dict = dict(cls.LINE_ITEM_CHOICES)
-    return line_item_dict[code]
+    return cls.LINE_ITEM_CHOICES[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:
+    for ln_code in cls.LINE_ITEM_CHOICES:
+      if cls.LINE_ITEM_CHOICES[ln_code] == name:
         return ln_code
 
     return None
@@ -723,16 +722,15 @@
     """Get the State code from its name.
     """
 
-    state_dict = dict(cls.STATE_CHOICES)
-    return state_dict[code]
+    return cls.STATE_CHOICES[code]
 
   @classmethod
   def getStateCode(cls, name):
     """Get the State code from its name.
     """
 
-    for st_code, st_name in cls.STATE_CHOICES:
-      if st_name == name:
+    for st_code in cls.STATE_CHOICES:
+      if cls.STATE_CHOICES[st_code] == name:
         return st_code
 
     return None
@@ -742,16 +740,15 @@
     """Get the District name from its code.
     """
 
-    district_dict = dict(cls.DISTRICT_CHOICES)
-    return district_dict[code]
+    return cls.DISTRICT_CHOICES[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:
+    for dt_code in cls.DISTRICT_CHOICES:
+      if cls.DISTRICT_CHOICES[dt_code] == name:
         return dt_code
 
     return None