Ignore:
Timestamp:
13 Dec 2014, 08:58:43 (10 years ago)
Author:
Henrik Bettermann
Message:

Let's take the 'last transition date' from the history. Saving the date is redundant.

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

Legend:

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

    r12196 r12210  
    841841    grok.require('waeup.viewCustomer')
    842842    grok.template('documentpage')
    843     form_fields = grok.AutoFields(ICustomerDocument).omit('last_transition_date')
     843    form_fields = grok.AutoFields(ICustomerDocument)
    844844    pnav = 4
    845845
     
    856856    grok.require('waeup.manageCustomer')
    857857    grok.template('documenteditpage')
    858     form_fields = grok.AutoFields(ICustomerDocument).omit('last_transition_date')
     858    form_fields = grok.AutoFields(ICustomerDocument)
    859859    pnav = 4
    860860    deletion_warning = _('Are you sure?')
     
    10081008                   'suspended_comment',)
    10091009
    1010     #form_fields = grok.AutoFields(ICustomerPDFDocument).omit(
    1011     #    'last_transition_date')
    10121010    form_fields =()
    10131011
     
    11801178    @property
    11811179    def form_fields(self):
    1182         form_fields = grok.AutoFields(self.context.form_fields_interface).omit(
    1183             'last_transition_date')
     1180        form_fields = grok.AutoFields(self.context.form_fields_interface)
    11841181        for field in form_fields:
    11851182            if field.__name__.endswith('_object'):
     
    12041201    @property
    12051202    def form_fields(self):
    1206         return grok.AutoFields(self.context.form_fields_interface).omit(
    1207             'last_transition_date')
     1203        return grok.AutoFields(self.context.form_fields_interface)
    12081204
    12091205    @property
     
    12251221    @property
    12261222    def form_fields(self):
    1227         return grok.AutoFields(self.context.edit_form_fields_interface).omit(
    1228             'last_transition_date')
     1223        return grok.AutoFields(self.context.edit_form_fields_interface)
    12291224
    12301225    def update(self):
     
    13541349                   'suspended_comment',)
    13551350
    1356     form_fields = grok.AutoFields(ISampleContract).omit(
    1357         'last_transition_date')
     1351    form_fields = grok.AutoFields(ISampleContract)
    13581352
    13591353    @property
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/contracts.py

    r12196 r12210  
    107107    def formatted_transition_date(self):
    108108        try:
    109             return self.last_transition_date.strftime('%Y-%m-%d %H:%M:%S')
    110         except AttributeError:
     109            return self.history.messages[-1].split(' - ')[0]
     110        except IndexError:
    111111            return
    112112
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/interfaces.py

    r12167 r12210  
    286286        )
    287287
    288     last_transition_date = schema.Datetime(
    289         title = _(u'Last Transition Date'),
    290         required = False,
    291         readonly = False,
    292         )
    293 
    294288    product_object = schema.Choice(
    295289        title = _(u'Product'),
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_export.py

    r12146 r12210  
    161161        self.assertEqual(
    162162            result,
    163             'class_name,document_id,history,last_transition_date,state,title,user_id\r\n'
    164             'CustomerSampleDocument,d101,[],,,,\r\n'
     163            'class_name,document_id,history,state,title,user_id\r\n'
     164            'CustomerSampleDocument,d101,[],,,\r\n'
    165165            )
    166166        return
     
    175175        result = open(self.outfile, 'rb').read()
    176176        self.assertTrue(
    177             'class_name,document_id,history,last_transition_date,state,title,user_id\r\n'
     177            'class_name,document_id,history,state,title,user_id\r\n'
    178178            in result
    179179            )
    180180        self.assertMatches(
    181181            '...CustomerSampleDocument,d101,[u\'2014-11-25 06:57:24 UTC - '
    182             'Document created by system\'],2014-11-25 06:57:24.990308#,'
     182            'Document created by system\'],'
    183183            'verified,My Document,A111111...',
    184184            result
     
    194194        result = open(self.outfile, 'rb').read()
    195195        self.assertTrue(
    196             'class_name,document_id,history,last_transition_date,state,title,user_id\r\n'
     196            'class_name,document_id,history,state,title,user_id\r\n'
    197197            in result)
    198198        self.assertMatches(
    199199            '...CustomerSampleDocument,d101,[u\'2014-11-25 06:57:24 UTC - '
    200             'Document created by system\'],2014-11-25 06:57:24.990308#,'
     200            'Document created by system\'],'
    201201            'verified,My Document,A111111...',
    202202            result
     
    212212        result = open(self.outfile, 'rb').read()
    213213        self.assertTrue(
    214             'class_name,document_id,history,last_transition_date,state,title,user_id\r\n'
     214            'class_name,document_id,history,state,title,user_id\r\n'
    215215            in result)
    216216        self.assertMatches(
    217217            '...CustomerSampleDocument,d101,[u\'2014-11-25 06:57:24 UTC - '
    218             'Document created by system\'],2014-11-25 06:57:24.990308#,'
     218            'Document created by system\'],'
    219219            'verified,My Document,A111111...',
    220220            result
     
    254254            result,
    255255            'class_name,contract_category,contract_id,document_object,'
    256             'history,last_product_id,last_transition_date,'
     256            'history,last_product_id,'
    257257            'product_object,state,title\r\n'
    258258
    259             'SampleContract,sample,c101,,[],,,,,\r\n'
     259            'SampleContract,sample,c101,,[],,,,\r\n'
    260260            )
    261261        return
     
    270270        self.assertMatches(
    271271            'class_name,contract_category,contract_id,document_object,'
    272             'history,last_product_id,last_transition_date,'
     272            'history,last_product_id,'
    273273            'product_object,state,title\r\n'
    274274
    275275            'SampleContract,sample,c101,d101,[u\'2014-12-04 12:10:46 UTC - '
    276276            'Contract record created by system\'],,'
    277             '2014-12-04 12:10:46.333445#,SAM,created,My Contract\r\n',
     277            'SAM,created,My Contract\r\n',
    278278            result
    279279            )
     
    289289        self.assertMatches(
    290290            'class_name,contract_category,contract_id,document_object,'
    291             'history,last_product_id,last_transition_date,'
     291            'history,last_product_id,'
    292292            'product_object,state,title\r\n'
    293293
    294294            'SampleContract,sample,c101,d101,[u\'2014-12-04 12:10:46 UTC - '
    295295            'Contract record created by system\'],,'
    296             '2014-12-04 12:10:46.333445#,SAM,created,My Contract\r\n',
     296            'SAM,created,My Contract\r\n',
    297297            result
    298298            )
     
    308308        self.assertMatches(
    309309            'class_name,contract_category,contract_id,document_object,'
    310             'history,last_product_id,last_transition_date,'
     310            'history,last_product_id,'
    311311            'product_object,state,title\r\n'
    312312
    313313            'SampleContract,sample,c101,d101,[u\'2014-12-04 12:10:46 UTC - '
    314314            'Contract record created by system\'],,'
    315             '2014-12-04 12:10:46.333445#,SAM,created,My Contract\r\n',
    316             result
    317             )
    318         return
    319 
     315            'SAM,created,My Contract\r\n',
     316            result
     317            )
     318        return
     319
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/workflow.py

    r12168 r12210  
    241241@grok.subscribe(IContract, IWorkflowTransitionEvent)
    242242def handle_contract_transition_event(obj, event):
    243     """Append message to contract history and log file, also update
    244     last_transition_date when transition happened.
     243    """Append message to contract history and log file.
    245244
    246245    Undo the approval of contract and raise an exception if contract
     
    256255    history = IObjectHistory(obj)
    257256    history.addMessage(msg)
    258     obj.last_transition_date = datetime.utcnow()
    259257    try:
    260258        customers_container = grok.getSite()['customers']
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/document.py

    r12204 r12210  
    8686    def formatted_transition_date(self):
    8787        try:
    88             return self.last_transition_date.strftime('%Y-%m-%d %H:%M:%S')
    89         except AttributeError:
     88            return self.history.messages[-1].split(' - ')[0]
     89        except IndexError:
    9090            return
    9191
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/interfaces.py

    r12200 r12210  
    5454        )
    5555
    56     last_transition_date = schema.Datetime(
    57         title = _(u'Last Transition Date'),
    58         required = False,
    59         readonly = False,
    60         )
    61 
    6256    def setMD5():
    6357        """Determine md5 checksum of selected files and store checksums as
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/workflow.py

    r12200 r12210  
    134134@grok.subscribe(IDocument, IWorkflowTransitionEvent)
    135135def handle_document_transition_event(obj, event):
    136     """Append message to document history and log file and update
    137     last_transition_date when transition happened.
     136    """Append message to document history and log file.
    138137
    139138    Undo the verification of document and raise an exception if document
     
    151150    history = IObjectHistory(obj)
    152151    history.addMessage(msg)
    153     obj.last_transition_date = datetime.utcnow()
    154152    try:
    155153        customers_container = grok.getSite()['customers']
Note: See TracChangeset for help on using the changeset viewer.