Ignore:
Timestamp:
11 Sep 2006, 10:39:59 (18 years ago)
Author:
joachim
Message:

Scratchcard Pin Generation
basic login in apply_admission

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/ScratchCards.py

    r490 r502  
    1111#from Products.CPSCore.CPSBase import CPSBaseDocument as BaseDocument
    1212from Products.CPSDocument.CPSDocument import CPSDocument
     13import DateTime
     14import Globals
     15p_home = Globals.package_home(globals())
     16i_home = Globals.INSTANCE_HOME
    1317
    1418class ScratchCardBatchesFolder(CPSDocument): ###(
     
    4549    security = ClassSecurityInfo()
    4650
    47     def __init__(self,id,**kw):
    48         CPSDocument.__init__(self,id,**kw)
    49         self.table = PinTable()
    50        
    5151    security.declareProtected(View,"Title")
    5252    def Title(self):
     
    6060        batch = self.getContent()
    6161        nr = batch.no_of_pins
     62        prefix = batch.prefix
     63        sold = batch.sold_by
     64        cost = batch.cost
    6265        import random
    6366        r = random
    6467        b_no = batch.batch_no
     68        #import pdb;pdb.set_trace()
     69        generated = []
     70        generated.append('"Serial","Pin","Sold","Cost"' % vars())
     71        generated.append('"%(prefix)s","%(b_no)d","%(sold)s","%(cost)f"' % vars())
     72        pins = self.portal_pins
    6573        for i in range(nr):
    66             pin = "%d%d" % (b_no,r.randint(999999999,1000000000))
    67             import pdp;pdb.set_trace()
    68             while len(res) > 0:
    69                 pin = "%d%d" % (b_no,r.randint(9999,1000000000))
    70                 res = self.table.searchResults(uid=pin)
    71             self.table.addRecord(pin=pin,serial=i,student="")
    72             print i,pin
     74            ri = r.randint(1000000000,9999999999)
     75            pin = "%s%d%d" % (prefix,b_no,ri)
     76            while len(pins.searchResults({'pin': pin})) > 0:
     77                ri = r.randint(1000000000,9999999999)
     78                pin = "%s%d%d" % (prefix,b_no,ri)
     79            pins.addRecord(pin=pin,serial=i,student="")
     80            generated.append('"%(i)d","%(prefix)s-%(b_no)d-%(ri)d"' % vars())
     81        print '\n'.join(generated)
     82        current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S")
     83        open("%s/import/%s-%s-%s" % (i_home,prefix,b_no,current),"w+").write('\n'.join(generated))
    7384
    7485
Note: See TracChangeset for help on using the changeset viewer.