app/projrev/models.py
changeset 21 153db75bb515
parent 19 0c9bdcfac9f7
child 22 0321f984fb16
equal deleted inserted replaced
20:327b3f0b73bb 21:153db75bb515
   702   @classmethod
   702   @classmethod
   703   def getLineItem(cls, code):
   703   def getLineItem(cls, code):
   704     """Get the State name from its code.
   704     """Get the State name from its code.
   705     """
   705     """
   706 
   706 
   707     line_item_dict = dict(cls.LINE_ITEM_CHOICES)
   707     return cls.LINE_ITEM_CHOICES[code]
   708     return line_item_dict[code]
       
   709 
   708 
   710   @classmethod
   709   @classmethod
   711   def getLineItemCode(cls, name):
   710   def getLineItemCode(cls, name):
   712     """Get the Line Item code from its name.
   711     """Get the Line Item code from its name.
   713     """
   712     """
   714 
   713 
   715     for ln_code, ln_name in cls.LINE_ITEM_CHOICES:
   714     for ln_code in cls.LINE_ITEM_CHOICES:
   716       if ln_name == name:
   715       if cls.LINE_ITEM_CHOICES[ln_code] == name:
   717         return ln_code
   716         return ln_code
   718 
   717 
   719     return None
   718     return None
   720 
   719 
   721   @classmethod
   720   @classmethod
   722   def getState(cls, code):
   721   def getState(cls, code):
   723     """Get the State code from its name.
   722     """Get the State code from its name.
   724     """
   723     """
   725 
   724 
   726     state_dict = dict(cls.STATE_CHOICES)
   725     return cls.STATE_CHOICES[code]
   727     return state_dict[code]
       
   728 
   726 
   729   @classmethod
   727   @classmethod
   730   def getStateCode(cls, name):
   728   def getStateCode(cls, name):
   731     """Get the State code from its name.
   729     """Get the State code from its name.
   732     """
   730     """
   733 
   731 
   734     for st_code, st_name in cls.STATE_CHOICES:
   732     for st_code in cls.STATE_CHOICES:
   735       if st_name == name:
   733       if cls.STATE_CHOICES[st_code] == name:
   736         return st_code
   734         return st_code
   737 
   735 
   738     return None
   736     return None
   739 
   737 
   740   @classmethod
   738   @classmethod
   741   def getDistrict(cls, code):
   739   def getDistrict(cls, code):
   742     """Get the District name from its code.
   740     """Get the District name from its code.
   743     """
   741     """
   744 
   742 
   745     district_dict = dict(cls.DISTRICT_CHOICES)
   743     return cls.DISTRICT_CHOICES[code]
   746     return district_dict[code]
       
   747 
   744 
   748   @classmethod
   745   @classmethod
   749   def getDistrictCode(cls, name):
   746   def getDistrictCode(cls, name):
   750     """Get the District code from its name.
   747     """Get the District code from its name.
   751     """
   748     """
   752 
   749 
   753     for dt_code, dt_name in cls.DISTRICT_CHOICES:
   750     for dt_code in cls.DISTRICT_CHOICES:
   754       if dt_name == name:
   751       if cls.DISTRICT_CHOICES[dt_code] == name:
   755         return dt_code
   752         return dt_code
   756 
   753 
   757     return None
   754     return None
   758 
   755 
   759 class Proposal(models.Model):
   756 class Proposal(models.Model):