Commits

sirex  committed 6352c3b

Used default exchange rates source and allow to provide other source.

  • Participants
  • Parent commits de5208e

Comments (0)

Files changed (1)

File money/contrib/django/currencies/models.py

 from django.utils.translation import gettext_lazy as _
 
 from money.Money import CURRENCIES
-from money.sync.yahoo import YahooExRatesSource
+from money.sync import get_default_exrates_source
 
 
 class CurrencyManager(models.Manager):
     def get_by_code(self, code):
         return self.get(code=code)
 
-    def synchronize_exchange_rates(self, default_currency, currencies):
-        # FIXME:sirex: do not use YahooExRatesSource, use
-        # DEFAULT_EXCHANGE_RATES_SOURCE
-        ex_rates = (YahooExRatesSource().
-                    get_exchange_rates(default_currency, currencies,
-                                       ignore_missing=True))
+    def synchronize_exchange_rates(self, default_currency, currencies,
+                                   source=None):
+        if source is None:
+            source = get_default_exrates_source()
+
+        ex_rates = source.get_exchange_rates(default_currency, currencies,
+                                             ignore_missing=True)
         for currency in currencies:
             # FIXME: andrejus: what if `ex_rates[currency.code]` is not set?
             ex_rate = ex_rates.get(currency.code)