Changeset 6423


Ignore:
Timestamp:
20 Jun 2011, 15:19:43 (13 years ago)
Author:
uli
Message:

Support accessing the history for an access code via the access code itself.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/accesscodes.py

    r6420 r6423  
    99    IWorkflowInfo, InvalidTransitionError, IWorkflowState)
    1010from random import SystemRandom as random
    11 from waeup.sirp.interfaces import IWAeUPSIRPPluggable
     11from waeup.sirp.interfaces import IWAeUPSIRPPluggable, IObjectHistory
    1212from waeup.sirp.accesscodes.interfaces import (
    1313    IAccessCode, IAccessCodeBatch, IAccessCodeBatchContainer
     
    6060    def used(self):
    6161        return IWorkflowState(self).getState() == USED
     62
     63    @property
     64    def history(self):
     65        history = IObjectHistory(self)
     66        return '\n'.join(history.messages)
    6267
    6368class AccessCodeBatch(grok.Container):
  • main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/interfaces.py

    r6419 r6423  
    3737        title = u'Complete title of access code',
    3838        )
     39    history = schema.Text(
     40        title = u'The history of access code as lines',
     41        default = u'',
     42        readonly = True,
     43       )
    3944
    4045class IAccessCodeBatch(Interface):
  • main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/tests/test_accesscodes.py

    r6422 r6423  
    211211        self.app = self.getRootFolder()['app']
    212212
     213        # Create batch
     214        batch = AccessCodeBatch('now', 'manfred', 'APP', 6.6, 0)
     215        self.app['accesscodes'].addBatch(batch)
     216
     217        # Fill batch with accesscodes
     218        batch.addAccessCode(0, '11111111')
     219
     220        self.ac1 = batch.getAccessCode('APP-1-11111111')
    213221        setSite(self.app)
    214222        return
     
    220228
    221229    def test_iface(self):
     230        # AccessCodes fullfill their iface promises.
    222231        ac = AccessCode('1', '12345678')
    223232        assert verifyObject(IAccessCode, ac)
    224233        assert verifyClass(IAccessCode, AccessCode)
     234
     235    def test_history(self):
     236        # Access codes have a history.
     237        match = re.match(
     238            '^../../.... ..:..:.. - Initialized \(new state: initialized\)',
     239            self.ac1.history)
     240        assert match is not None
    225241
    226242class AccessCodeBatchTests(FunctionalTestCase):
Note: See TracChangeset for help on using the changeset viewer.