def get(self): context = dict() if app.config.get('OFFLINE'): currencies = flask.json.load(open('offline/currencies.json')) else: currencies = splitwise.get_currencies() user = splitwise.get_current_user() target_currency = user.get('default_currency') or 'EUR' exchange_rates = flask.json.loads(http.request( app.config.get('OPEN_EXCHANGE_RATES_URL'))[1]) rates = exchange_rates['rates'] for currency in currencies: currency['new_currency_code'] = target_currency code = currency['currency_code'] rate = 1. if code in rates: rate = rates[code] / rates[target_currency] currency['exchange'] = rate currency['convert'] = False context['currencies'] = currencies context['target_currency'] = target_currency return context
def get(self): context = dict() if app.config.get('OFFLINE'): currencies = flask.json.load(open('offline/currencies.json')) else: currencies = splitwise.get_currencies() user = splitwise.get_current_user() target_currency = user.get('default_currency') or 'EUR' exchange_rates = flask.json.loads( http.request(app.config.get('OPEN_EXCHANGE_RATES_URL'))[1]) rates = exchange_rates['rates'] for currency in currencies: currency['new_currency_code'] = target_currency code = currency['currency_code'] rate = 1. if code in rates: rate = rates[code] / rates[target_currency] currency['exchange'] = rate currency['convert'] = False context['currencies'] = currencies context['target_currency'] = target_currency return context
def get(self, user_id=None): if user_id: return splitwise.get_user(user_id) else: return splitwise.get_current_user()
def get(self, user_id=None): if user_id: return splitwise.get_user(user_id) else: return splitwise.get_current_user()