Changeset 12168


Ignore:
Timestamp:
8 Dec 2014, 06:17:30 (10 years ago)
Author:
Henrik Bettermann
Message:

Documents can't be verified without file(s) attached.

Let is_approvable and is_verifiable be more verbose.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba
Files:
7 edited

Legend:

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

    r12167 r12168  
    143143                state = getattr(obj, 'state', None)
    144144                if state and state != VERIFIED:
    145                     return False
    146         return True
     145                    return False, _("Attached documents must be verified first.")
     146        return True, None
    147147
    148148    @property
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/documents.py

    r12166 r12168  
    141141        return files
    142142
     143    @property
     144    def is_verifiable(self):
     145        return True, None
     146
    143147    def setMD5(self):
    144148        """Set md5 checksum attribute for files connected to this document.
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/export.py

    r12167 r12168  
    159159            omit=['is_editable_by_customer',
    160160                  'is_editable_by_manager',
     161                  'is_verifiable',
    161162                  'translated_state',
    162163                  'formatted_transition_date',
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/workflow.py

    r12151 r12168  
    248248    """
    249249    if event.transition.destination == APPROVED:
    250         if not obj.is_approvable:
     250        approvable, error = obj.is_approvable
     251        if not approvable:
    251252            # Undo transition and raise an exception.
    252253            IWorkflowState(obj).setState(event.transition.source)
    253             raise InvalidTransitionError(
    254                 _("Attached documents must be verified first."))
     254            raise InvalidTransitionError(error)
    255255    msg = event.transition.user_data['msg']
    256256    history = IObjectHistory(obj)
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/document.py

    r12161 r12168  
    8787        return
    8888
     89    @property
     90    def is_verifiable(self):
     91        return True, None
     92
    8993    def setMD5(self):
    9094        """Determine md5 checksum of all files and store checksums as
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/interfaces.py

    r12161 r12168  
    5353    user_id = Attribute('Id of a user')
    5454    connected_files = Attribute('Names of files connected to a document')
     55    is_verifiable = Attribute('Contract verifiable by officer')
    5556
    5657    title = schema.TextLine(
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/workflow.py

    r12162 r12168  
    2222from zope.component import getUtility
    2323from hurry.workflow.workflow import Transition, WorkflowState, NullCondition
    24 from hurry.workflow.interfaces import IWorkflowState, IWorkflowTransitionEvent
     24from hurry.workflow.interfaces import (
     25    IWorkflowState, IWorkflowTransitionEvent, InvalidTransitionError)
    2526from waeup.ikoba.interfaces import (
    2627    IObjectHistory, IIkobaWorkflowInfo,
     
    128129    """Append message to document history and log file and update
    129130    last_transition_date when transition happened.
     131
     132    Undo the verification of document and raise an exception if document
     133    does not meet the requirements for verification.
    130134    """
     135    if event.transition.destination == VERIFIED:
     136        verifiable, error = obj.is_verifiable
     137        if not verifiable:
     138            # Undo transition and raise an exception.
     139            IWorkflowState(obj).setState(event.transition.source)
     140            raise InvalidTransitionError(error)
    131141    if event.transition.transition_id == 'verify':
    132142        obj.setMD5()
Note: See TracChangeset for help on using the changeset viewer.