def get_default_currency(request): if 'default_currency' in request.session: try: return Currency.objects.get(code=request.session['default_currency']) except Currency.DoesNotExist: return Currency.get_primary() return Currency.get_primary()
def get_default_currency(request): if 'default_currency' in request.session: try: return Currency.objects.get( code=request.session['default_currency']) except Currency.DoesNotExist: return Currency.get_primary() return Currency.get_primary()
def __init__(self, *args, **kwargs): super(CatalogBaseView, self).__init__(*args, **kwargs) # Loading categories self.categories = Category.get_categories() self.manufacturers = Manufacturer.get_manufacturers() self.currencies = Currency.get_currencies() self.primary_currency = next((currency for currency in self.currencies if currency.is_primary), None) if self.primary_currency is None: raise ImproperlyConfigured('No primary currency is defined for Doorsale.' ' You should defined primary currency for the system with exchange rate of 1.' ' All prices & costs should be defined in primary currency value.') if self.primary_currency.exchange_rate != 1: raise ImproperlyConfigured('Primary currency should have exchange rate of 1.' ' All prices & costs should be defined in primary currency value.')
def __init__(self, *args, **kwargs): super(CatalogBaseView, self).__init__(*args, **kwargs) # Loading categories self.categories = Category.get_categories() self.manufacturers = Manufacturer.get_manufacturers() self.currencies = Currency.get_currencies() self.primary_currency = next( (currency for currency in self.currencies if currency.is_primary), None) if self.primary_currency is None: raise ImproperlyConfigured( 'No primary currency is defined for Doorsale.' ' You should defined primary currency for the system with exchange rate of 1.' ' All prices & costs should be defined in primary currency value.' ) if self.primary_currency.exchange_rate != 1: raise ImproperlyConfigured( 'Primary currency should have exchange rate of 1.' ' All prices & costs should be defined in primary currency value.' )