Ignore:
Timestamp:
21 Nov 2014, 08:07:15 (10 years ago)
Author:
Henrik Bettermann
Message:

Add more browser components for document editing. Editing is allowed only under certain conditions.

  • work in progress -
File:
1 edited

Legend:

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

    r12015 r12018  
    2020"""
    2121import grok
     22from zope.component import queryUtility, getUtility
    2223from zope.component.interfaces import IFactory
    2324from zope.interface import implementedBy
    2425from waeup.ikoba.interfaces import MessageFactory as _
    2526from waeup.ikoba.customers.interfaces import (
    26     ICustomerDocumentsContainer, ICustomerNavigation, ICustomerDocument)
     27    ICustomerDocumentsContainer, ICustomerNavigation, ICustomerDocument,
     28    ICustomersUtils)
    2729from waeup.ikoba.documents import DocumentsContainer, Document
     30from waeup.ikoba.documents.interfaces import IDocumentsUtils
    2831from waeup.ikoba.utils.helpers import attrs_to_fields
    2932
     
    6770        return self.__parent__.__parent__.writeLogMessage(view, message)
    6871
     72    @property
     73    def is_editable(self):
     74        try:
     75            # Customer must be approved
     76            cond1 = self.customer.state in getUtility(
     77                ICustomersUtils).DOCMANAGE_STATES
     78            # Document must be in state created
     79            cond2 = self.state in getUtility(
     80                IDocumentsUtils).DOCMANAGE_STATES
     81            if not (cond1 and cond2):
     82                return False
     83        except AttributeError:
     84            pass
     85        return True
     86
    6987CustomerDocument = attrs_to_fields(CustomerDocument)
    7088
Note: See TracChangeset for help on using the changeset viewer.