Merge pull request #3 from matmair/pr1600

proposed changes for translation and safer backend loading
This commit is contained in:
Francois 2021-05-25 08:56:59 -05:00 committed by GitHub
commit 949920865b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 4 deletions

View File

@ -13,8 +13,10 @@ def get_exchange_rate_backend():
if 'InvenTreeManualExchangeBackend' in inventree_settings.EXCHANGE_BACKEND:
return InvenTreeManualExchangeBackend()
else:
elif 'InvenTreeFixerExchangeBackend' in inventree_settings.EXCHANGE_BACKEND:
return InvenTreeFixerExchangeBackend()
else:
raise ImproperlyConfigured('Exchange Backend wrongly configured')
class InvenTreeManualExchangeBackend(BaseExchangeBackend):

View File

@ -959,7 +959,7 @@ class CurrencySettingsView(FormView):
stored_rates = exchange_rate_backend.get_stored_rates()
for field in form.fields:
if 'fixer' in exchange_rate_backend.name:
if exchange_rate_backend.name.startswith('fixer-'):
# Disable all the fields
form.fields[field].disabled = True
form.fields[field].initial = clean_decimal(stored_rates.get(field, 0))
@ -973,7 +973,7 @@ class CurrencySettingsView(FormView):
# Get exchange rate backend
exchange_rate_backend = self.get_exchange_rate_backend()
if 'fixer' in exchange_rate_backend.name:
if exchange_rate_backend.name.startswith('fixer-'):
# Refresh rate from Fixer.IO API
exchange_rate_backend.update_rates(base_currency=exchange_rate_backend.base_currency)
# Check if rates have been updated

View File

@ -24,7 +24,7 @@
<div class='row'>
<div class='col-sm-6'>
<h4>{% trans "Exchange Rates - Convert to " %}{{ default_currency }}</h4>
<h4>{% blocktrans with cur=default_currency %}Exchange Rates - Convert to {{cur}}{% endblocktrans %}</h4>
</div>
</div>