# -*- coding: utf-8 -*- import operator from django.conf import settings from moneyed import CURRENCIES, DEFAULT_CURRENCY, DEFAULT_CURRENCY_CODE # The default currency, you can define this in your project's settings module # This has to be a currency object imported from moneyed DEFAULT_CURRENCY = getattr(settings, 'DEFAULT_CURRENCY', DEFAULT_CURRENCY) # The default currency choices, you can define this in your project's # settings module PROJECT_CURRENCIES = getattr(settings, 'CURRENCIES', None) CURRENCY_CHOICES = getattr(settings, 'CURRENCY_CHOICES', None) if CURRENCY_CHOICES is None: if PROJECT_CURRENCIES: CURRENCY_CHOICES = [(code, CURRENCIES[code].name) for code in PROJECT_CURRENCIES] else: CURRENCY_CHOICES = [(c.code, c.name) for i, c in CURRENCIES.items() if c.code != DEFAULT_CURRENCY_CODE] CURRENCY_CHOICES.sort(key=operator.itemgetter(1, 0)) DECIMAL_PLACES = getattr(settings, 'CURRENCY_DECIMAL_PLACES', 2)
from moneyed import Money, CURRENCIES, DEFAULT_CURRENCY_CODE from decimal import Decimal import operator __all__ = ( 'InputMoneyWidget', 'CurrencySelectWidget', ) PROJECT_CURRENCIES = getattr(settings, 'CURRENCIES', None) if PROJECT_CURRENCIES: CURRENCY_CHOICES = [(code, CURRENCIES[code].name) for code in PROJECT_CURRENCIES] else: CURRENCY_CHOICES = [(c.code, c.name) for i, c in CURRENCIES.items() if c.code != DEFAULT_CURRENCY_CODE] CURRENCY_CHOICES.sort(key=operator.itemgetter(1)) class CurrencySelectWidget(forms.Select): def __init__(self, attrs=None, choices=CURRENCY_CHOICES): super(CurrencySelectWidget, self).__init__(attrs, choices) class InputMoneyWidget(forms.TextInput): def __init__(self, attrs=None, currency_widget=None): self.currency_widget = currency_widget or CurrencySelectWidget() super(InputMoneyWidget, self).__init__(attrs)
# The default currency, you can define this in your project's settings module # This has to be a currency object imported from moneyed DEFAULT_CURRENCY = getattr(settings, "DEFAULT_CURRENCY", DEFAULT_CURRENCY) # The default currency choices, you can define this in your project's # settings module PROJECT_CURRENCIES = getattr(settings, "CURRENCIES", None) CURRENCY_CHOICES = getattr(settings, "CURRENCY_CHOICES", None) if CURRENCY_CHOICES is None: if PROJECT_CURRENCIES: CURRENCY_CHOICES = [(code, CURRENCIES[code].name) for code in PROJECT_CURRENCIES] else: CURRENCY_CHOICES = [(c.code, c.name) for i, c in CURRENCIES.items() if c.code != DEFAULT_CURRENCY_CODE] CURRENCY_CHOICES.sort(key=operator.itemgetter(1, 0)) DECIMAL_PLACES = getattr(settings, "CURRENCY_DECIMAL_PLACES", 2) DECIMAL_PLACES_DISPLAY = getattr( settings, "CURRENCY_DECIMAL_PLACES_DISPLAY", {currency[0]: DECIMAL_PLACES for currency in CURRENCY_CHOICES} ) OPEN_EXCHANGE_RATES_URL = getattr(settings, "OPEN_EXCHANGE_RATES_URL", "https://openexchangerates.org/api/latest.json") OPEN_EXCHANGE_RATES_APP_ID = getattr(settings, "OPEN_EXCHANGE_RATES_APP_ID", None) FIXER_URL = getattr(settings, "FIXER_URL", "http://data.fixer.io/api/latest") FIXER_ACCESS_KEY = getattr(settings, "FIXER_ACCESS_KEY", None) BASE_CURRENCY = getattr(settings, "BASE_CURRENCY", "USD") EXCHANGE_BACKEND = getattr(settings, "EXCHANGE_BACKEND", "djmoney.contrib.exchange.backends.OpenExchangeRatesBackend") RATES_CACHE_TIMEOUT = getattr(settings, "RATES_CACHE_TIMEOUT", 600)
from django import forms from django.conf import settings from moneyed import Money, CURRENCIES, DEFAULT_CURRENCY_CODE from decimal import Decimal import operator __all__ = ('InputMoneyWidget', 'CurrencySelectWidget',) PROJECT_CURRENCIES = getattr(settings, 'CURRENCIES', None) if PROJECT_CURRENCIES: CURRENCY_CHOICES = [(code, CURRENCIES[code].name) for code in PROJECT_CURRENCIES] else: CURRENCY_CHOICES = [(c.code, c.name) for i, c in CURRENCIES.items() if c.code != DEFAULT_CURRENCY_CODE] CURRENCY_CHOICES.sort(key=operator.itemgetter(1)) class CurrencySelectWidget(forms.Select): def __init__(self, attrs=None, choices=CURRENCY_CHOICES): super(CurrencySelectWidget, self).__init__(attrs, choices) class InputMoneyWidget(forms.TextInput): def __init__(self, attrs=None, currency_widget=None): self.currency_widget = currency_widget or CurrencySelectWidget() super(InputMoneyWidget, self).__init__(attrs) def render(self, name, value, attrs=None): amount = '' currency = ''
EMAIL_MESSAGE_CONTACT_NAME = os.environ.get('EMAIL_MESSAGE_CONTACT_NAME', None) EMAIL_MESSAGE_CONTACT_EMAIL = os.environ.get( 'EMAIL_MESSAGE_CONTACT_EMAIL', None ) SCM_TOOL_URL = os.getenv('SCM_TOOL_URL', '') RALPH_HOST_URL = os.environ.get('RALPH_HOST_URL', None) # METRICS COLLECT_METRICS = False ALLOW_PUSH_GRAPHS_DATA_TO_STATSD = False STATSD_GRAPHS_PREFIX = 'ralph.graphs' TRANSITION_TEMPLATES = None CONVERT_TO_DATACENTER_ASSET_DEFAULT_STATUS_ID = 1 CONVERT_TO_BACKOFFICE_ASSET_DEFAULT_STATUS_ID = 1 # Currency choices for django-money DEFAULT_CURRENCY_CODE = 'XXX' CURRENCY_CHOICES = [ (c.code, c.code) for i, c in CURRENCIES.items() if c.code != DEFAULT_CURRENCY_CODE ] CURRENCY_CHOICES.append(('XXX', '---')) OAUTH_CLIENT_ID = "" OAUTH_SECRET = "" OAUTH_TOKEN_URL = "https://localhost/"