Exemple #1
0
 def price(self):
     if self.on_sale_price:
         today = localnow()
         start_date = self.on_sale_start_date
         end_date = self.on_sale_end_date
         if is_date_in_interval(today, start_date, end_date):
             return self.on_sale_price
     return self.base_price
Exemple #2
0
 def price(self):
     if self.on_sale_price:
         today = localnow()
         start_date = self.on_sale_start_date
         end_date = self.on_sale_end_date
         if is_date_in_interval(today, start_date, end_date):
             return self.on_sale_price
     return self.base_price
Exemple #3
0
 def _get_price(self):
     if self.on_sale_price:
         today = datetime.datetime.today()
         start_date = self.on_sale_start_date
         end_date = self.on_sale_end_date
         if is_date_in_interval(today, start_date, end_date):
             return self.on_sale_price
     return self.base_price
Exemple #4
0
 def price(self):
     # See Sellable.price property
     if self.on_sale_price:
         today = datetime.datetime.today()
         start_date = self.on_sale_start_date
         end_date = self.on_sale_end_date
         if is_date_in_interval(today, start_date, end_date):
             return self.on_sale_price
     return self.base_price
Exemple #5
0
    def is_on_sale(self):
        """Check if the price is currently on sale.

        :return: ``True`` if it is on sale, ``False`` otherwise
        """
        if not self.on_sale_price:
            return False

        return is_date_in_interval(localnow(), self.on_sale_start_date,
                                   self.on_sale_end_date)
Exemple #6
0
    def is_on_sale(self):
        """Check if the price is currently on sale.

        :return: ``True`` if it is on sale, ``False`` otherwise
        """
        if not self.on_sale_price:
            return False

        return is_date_in_interval(
            localnow(), self.on_sale_start_date, self.on_sale_end_date)
Exemple #7
0
    def price(self, price):
        if price < 0:
            # Just a precaution for gui validation fails.
            price = 0

        if self.on_sale_price:
            today = localnow()
            start_date = self.on_sale_start_date
            end_date = self.on_sale_end_date
            if is_date_in_interval(today, start_date, end_date):
                self.on_sale_price = price
                return
        self.base_price = price
Exemple #8
0
    def price(self, price):
        if price < 0:
            # Just a precaution for gui validation fails.
            price = 0

        if self.on_sale_price:
            today = localnow()
            start_date = self.on_sale_start_date
            end_date = self.on_sale_end_date
            if is_date_in_interval(today, start_date, end_date):
                self.on_sale_price = price
                return
        self.base_price = price
 def test_is_date_in_empty_interval(self):
     assert is_date_in_interval(localtoday(), None, None) is False
Exemple #10
0
 def test_is_date_in_empty_interval(self):
     assert is_date_in_interval(localtoday(), None, None) is False