Ignore:
Timestamp:
1 Oct 2012, 06:55:04 (12 years ago)
Author:
Henrik Bettermann
Message:

Add batch processor for ac batches.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/accesscodes
Files:
3 added
2 edited

Legend:

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

    r9260 r9263  
    3232from random import SystemRandom as random
    3333from zope.component import getUtility
     34from zope.component.interfaces import IFactory
    3435from waeup.kofa.interfaces import IKofaUtils, IKofaPluggable, IObjectHistory
    3536from waeup.kofa.utils.helpers import now
     
    152153    grok.implements(IAccessCodeBatch)
    153154
    154     def __init__(self, creation_date, creator, batch_prefix, cost,
    155                  entry_num, num=None):
     155    def __init__(self, creation_date=None, creator=None, batch_prefix=None,
     156                 cost=None, entry_num=None, num=None):
    156157        super(AccessCodeBatch, self).__init__()
    157158        self.creation_date = creation_date
    158159        self.creator = creator
    159         self.prefix = batch_prefix.upper()
     160        try:
     161            self.prefix = batch_prefix.upper()
     162        except AttributeError:
     163            self.prefix = None
    160164        self.cost = cost
    161165        self.entry_num = entry_num
     
    310314        self[key] = batch
    311315        self._p_changed = True
     316        return
     317
     318    def addBatchByImport(self, batch, batch_id):
     319        """Add an already created `batch` by import
     320        with defined id.
     321        """
     322        self[batch_id] = batch
     323        return
    312324
    313325    def createBatch(self, creation_date, creator, prefix, cost,
     
    457469        return
    458470
     471class AccessCodeBatchFactory(grok.GlobalUtility):
     472    """A factory for accesscodebatches.
     473
     474    We need this factory for the accesscodebatchprocessor.
     475    """
     476    grok.implements(IFactory)
     477    grok.name(u'waeup.AccessCodeBatch')
     478    title = u"Create a new accesscode batch.",
     479    description = u"This factory instantiates new accesscode batch instances."
     480
     481    def __call__(self, *args, **kw):
     482        return AccessCodeBatch(*args, **kw)
     483
     484    def getInterfaces(self):
     485        return implementedBy(AccessCodeBatch)
     486
    459487def get_access_code(access_code):
    460488    """Get an access code instance.
  • main/waeup.kofa/trunk/src/waeup/kofa/accesscodes/interfaces.py

    r8321 r9263  
    5959    """A factory for batches of access codes.
    6060    """
    61     creation_date = schema.Date(
     61    creation_date = schema.Datetime(
    6262        title = _(u'Creation date'),
    6363        )
Note: See TracChangeset for help on using the changeset viewer.