Ignore:
Timestamp:
7 Dec 2014, 22:24:03 (10 years ago)
Author:
Henrik Bettermann
Message:

We need to protect also the manage form page of documents. Officers are only allowed to edit documents in state created.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba/customers
Files:
6 edited

Legend:

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

    r12151 r12166  
    843843    pnav = 4
    844844
    845     #@property
    846     #def label(self):
    847     #    return _('${a}: Document ${b}', mapping = {
    848     #        'a':self.context.customer.display_fullname,
    849     #        'b':self.context.document_id})
    850 
    851845    @property
    852846    def label(self):
     
    865859    deletion_warning = _('Are you sure?')
    866860
    867     #@property
    868     #def label(self):
    869     #    return _('${a}: Document ${b}', mapping = {
    870     #        'a':self.context.customer.display_fullname,
    871     #        'b':self.context.document_id})
     861    def update(self):
     862        if not self.context.is_editable_by_manager:
     863            emit_lock_message(self)
     864            return
     865        return super(DocumentManageFormPage, self).update()
    872866
    873867    @property
     
    888882
    889883    def update(self):
    890         if not self.context.is_editable:
     884        if not self.context.is_editable_by_customer:
    891885            emit_lock_message(self)
    892886            return
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/documents.py

    r12165 r12166  
    9090
    9191    @property
    92     def is_editable(self):
     92    def is_editable_by_customer(self):
    9393        try:
    9494            # Customer must be approved
     
    105105
    106106    @property
     107    def is_editable_by_manager(self):
     108        try:
     109            # Document must be in state created
     110            cond = self.state in getUtility(
     111                ICustomersUtils).DOCMANAGE_DOCUMENT_STATES
     112            if not cond:
     113                return False
     114        except AttributeError:
     115            pass
     116        return True
     117
     118    @property
    107119    def translated_class_name(self):
    108120        try:
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/export.py

    r12161 r12166  
    157157            ICustomerDocument,
    158158            exclude_attribs=False,
    159             omit=['is_editable',
     159            omit=['is_editable_by_customer',
     160                  'is_editable_by_manager',
    160161                  'translated_state',
    161162                  'formatted_transition_date',
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/interfaces.py

    r12144 r12166  
    240240    """
    241241
    242     is_editable = Attribute('Document editable by customer')
     242    is_editable_by_customer = Attribute('Document editable by customer')
     243    is_editable_by_manager = Attribute('Document editable by manager')
    243244    translated_class_name = Attribute('Translatable class name')
    244245
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py

    r12162 r12166  
    853853        self.assertEqual(document.state, 'verified')
    854854
     855        # Manage button and form is no longer available
     856        self.browser.open(self.documents_path + '/d102/index')
     857        self.assertFalse(
     858            'href="http://localhost/app/customers/K1000000/documents/d102/manage"'
     859            in self.browser.contents)
     860        self.browser.open(self.documents_path + '/d102/manage')
     861        self.assertTrue(
     862            'The requested form is locked (read-only)'
     863            in self.browser.contents)
     864
    855865        # Documents can be removed
    856866        self.browser.getLink("Documents").click()
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/viewlets.py

    r12097 r12166  
    327327    target = 'manage'
    328328
     329    @property
     330    def target_url(self):
     331        if not self.context.is_editable_by_manager:
     332            return ''
     333        return self.view.url(self.view.context, self.target)
     334
    329335
    330336class DocumentEditActionButton(ManageActionButton):
     
    338344    @property
    339345    def target_url(self):
    340         if not self.context.is_editable:
     346        if not self.context.is_editable_by_customer:
    341347            return ''
    342348        return self.view.url(self.view.context, self.target)
Note: See TracChangeset for help on using the changeset viewer.