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
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
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
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)
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)
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