示例#1
0
 def get_value(self, record):
     for commodity in record.commodities_cache or []:
         if commodity.get("country"):
             commodity["country"] = get_country(commodity["country"].get("id"))
         elif commodity.get("trading_bloc"):
             commodity["trading_bloc"] = get_trading_bloc(commodity["trading_bloc"].get("code"))
     return record.commodities_cache
示例#2
0
 def get_data(self, value):
     if value:
         value = str(value)
         country = get_country(value) or {}
         return {
             "id": value,
             "name": country.get("name"),
             "trading_bloc": country.get("trading_bloc")
         }
示例#3
0
 def get_location(self, obj):
     if obj.country:
         country = get_country(str(obj.country))
         if country:
             return country.get("name")
     elif obj.trading_bloc:
         trading_bloc = get_trading_bloc(obj.trading_bloc)
         if trading_bloc:
             return trading_bloc.get("name")
示例#4
0
 def get_overseas_region(self, obj):
     if obj.country:
         country = get_country(str(obj.country))
         if country:
             overseas_region = country.get("overseas_region")
             if overseas_region:
                 return overseas_region.get("name")
     elif obj.trading_bloc:
         overseas_regions = get_trading_bloc_overseas_regions(
             obj.trading_bloc)
         return [region["name"] for region in overseas_regions]
示例#5
0
 def get_wto_member_states(self, obj):
     if obj.has_wto_profile:
         return [
             get_country(str(country_id)).get("name")
             for country_id in obj.wto_profile.member_states
         ]
示例#6
0
 def country_name(self):
     if self.country:
         country = get_country(str(self.country))
         return country.get("name")