Ignore:
Timestamp:
11 Feb 2015, 11:59:34 (10 years ago)
Author:
Henrik Bettermann
Message:

Add 'active' property attribute. Use this attribute to show only active (valid) products to anonymous users.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/product.py

    r12397 r12592  
    2222from time import time
    2323from grok import index
     24from datetime import date
    2425from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
    2526from zope.event import notify
     
    6263            return self.contract_title
    6364        return self.title
     65
     66    @property
     67    def active(self):
     68        now = date.today()
     69        return (not self.valid_from or self.valid_from <= now) and \
     70               (not self.valid_to or self.valid_to >= now)
    6471
    6572Product = attrs_to_fields(Product)
Note: See TracChangeset for help on using the changeset viewer.