Changeset 5088


Ignore:
Timestamp:
26 Mar 2010, 11:50:36 (15 years ago)
Author:
uli
Message:

Fix creation of batches.

File:
1 edited

Legend:

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

    r5084 r5088  
    22"""
    33import grok
     4from datetime import datetime
    45from waeup.sirp.browser import WAeUPPage, WAeUPAddFormPage
    56from waeup.sirp.browser.breadcrumbs import Breadcrumb
     
    78from waeup.sirp.interfaces import IWAeUPObject
    89
    9 from waeup.sirp.accesscodes.interfaces import IAccessCodeBatchContainer
     10from waeup.sirp.accesscodes.accesscodes import AccessCodeBatch
     11from waeup.sirp.accesscodes.interfaces import (
     12    IAccessCodeBatchContainer, IAccessCodeBatch,
     13    )
    1014
    1115grok.context(IWAeUPObject)
     
    2630    pnav = 0
    2731
     32    form_fields = grok.AutoFields(IAccessCodeBatch).select(
     33        'batch_prefix', 'entry_num', 'cost')
     34
     35    @grok.action('Cancel')
     36    def cancel(self):
     37        self.flash('Batch creation cancelled.')
     38        self.redirect(self.url(self.context))
     39
    2840    @grok.action('Create batch')
    2941    def createBatch(self, **data):
    30         self.flash('Batch created')
     42        creator = self.request.principal.id
     43        creation_date = datetime.now()
     44        data.update(creation_date=creation_date, creator=creator)
     45        batch = AccessCodeBatch(**data)
     46        self.context.addBatch(batch)
     47        self.context._p_changed = True
     48        self.flash('Batch created (%s entries)' % data['entry_num'])
    3149        self.redirect(self.url(self.context))
    3250
Note: See TracChangeset for help on using the changeset viewer.