Ignore:
Timestamp:
4 Dec 2014, 18:10:11 (10 years ago)
Author:
Henrik Bettermann
Message:

Add property attribute is_approvable.

File:
1 edited

Legend:

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

    r12103 r12144  
    2424from zope.component.interfaces import IFactory
    2525from zope.interface import implementedBy
     26from zope.schema import getFields
    2627from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
    2728from waeup.ikoba.interfaces import MessageFactory as _
    28 from waeup.ikoba.interfaces import IIkobaUtils, IObjectHistory
     29from waeup.ikoba.interfaces import IIkobaUtils, IObjectHistory, VERIFIED
    2930from waeup.ikoba.customers.interfaces import (
    3031    IContractsContainer, ICustomerNavigation,
     
    6263    grok.provides(IContract)
    6364    grok.baseclass()
     65
     66    check_docs_interface = None
    6467
    6568    contract_category = None
     
    134137
    135138    @property
     139    def is_approvable(self):
     140        for key, field in getFields(self.check_docs_interface).items():
     141            if key.endswith('_object'):
     142                obj = getattr(self, key, None)
     143                state = getattr(obj, 'state', None)
     144                if state and state != VERIFIED:
     145                    return False
     146        return True
     147
     148    @property
    136149    def translated_class_name(self):
    137150        try:
     
    153166
    154167    edit_form_fields_interface = ISampleContractEdit
     168
     169    check_docs_interface = ISampleContract
    155170
    156171SampleContract = attrs_to_fields(SampleContract)
Note: See TracChangeset for help on using the changeset viewer.