Esempio n. 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
Esempio n. 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")
         }
Esempio n. 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")
Esempio n. 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]
Esempio n. 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
         ]
Esempio n. 6
0
 def country_name(self):
     if self.country:
         country = get_country(str(self.country))
         return country.get("name")