Esempio n. 1
0
def update_currency_conversion():
    rate_classes = [MachSMSRate, TropoSMSRate, UnicelSMSRate]
    rate_codes = [klass._admin_crud_class.currency_code for klass in rate_classes]
    currencies = BillableCurrency.view(BillableCurrency._currency_view,
        group=True
    ).all()
    relevant_codes = [cur.get('key')[0] for cur in currencies]
    relevant_codes.extend(rate_codes)
    relevant_codes = list(set(relevant_codes))
    for code in relevant_codes:
        currency = BillableCurrency.get_existing_or_new_by_code(code)
        currency.set_live_conversion_rate(currency.currency_code, settings.DEFAULT_CURRENCY.upper())
        currency.save()
Esempio n. 2
0
 def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None,
            initial=None, error_class=ErrorList, label_suffix=':',
            empty_permitted=False):
     super(DomainBillingInfoForm, self).__init__(data, files, auto_id, prefix, initial,
         error_class, label_suffix, empty_permitted)
     all_currencies = BillableCurrency.get_all()
     if all_currencies:
         self.fields['currency_code'].choices = [(cur.currency_code, mark_safe("%s %s" %
                                                                               (cur.symbol, cur.currency_code)))
                                                                     for cur in all_currencies]