예제 #1
0
파일: views.py 프로젝트: sanjivj/doorsale
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()
예제 #2
0
파일: views.py 프로젝트: yvesc/doorsale
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()
예제 #3
0
 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.')            
예제 #4
0
파일: views.py 프로젝트: yvesc/doorsale
    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.'
            )