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.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba/products
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/browser_templates/containerpage.pt

    r12334 r12592  
    1212  </thead>
    1313  <tbody>
    14     <tr tal:repeat="value context/values">
    15       <td> <a tal:attributes="href python: view.url(value)">
    16           <span tal:content="value/product_id">ID</span></a></td>
    17       <td tal:content="value/title">TITLE</td>
    18       <td tal:content="value/contract_category_title">CATEGORY</td>
    19     </tr>
     14    <tal:repeat repeat="value context/values">
     15      <tr tal:condition="python:layout.isAuthenticated() or value.active">
     16        <td> <a tal:attributes="href python: view.url(value)">
     17            <span tal:content="value/product_id">ID</span></a></td>
     18        <td tal:content="value/title">TITLE</td>
     19        <td tal:content="value/contract_category_title">CATEGORY</td>
     20      </tr>
     21    </tal:repeat>
    2022  </tbody>
    2123</table>
  • 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.