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
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/vocabularies.py

    r12585 r12592  
    1919"""
    2020import grok
    21 from datetime import date
    2221from zope.component import getUtility, queryUtility
    2322from zope.catalog.interfaces import ICatalog
     
    168167        if not concat:
    169168            return products
    170         now = date.today()
     169       
    171170        resultlist = [
    172171            value for value in products
    173             if value.contract_category == concat
    174                 and (not value.valid_from or value.valid_from <= now)
    175                 and (not value.valid_to or value.valid_to >= now)
     172            if value.contract_category == concat and value.active
    176173            ]
    177174        return resultlist
  • 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.