Changeset 502 for WAeUP_SRP/trunk/ScratchCards.py
- Timestamp:
- 11 Sep 2006, 10:39:59 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/ScratchCards.py
r490 r502 11 11 #from Products.CPSCore.CPSBase import CPSBaseDocument as BaseDocument 12 12 from Products.CPSDocument.CPSDocument import CPSDocument 13 import DateTime 14 import Globals 15 p_home = Globals.package_home(globals()) 16 i_home = Globals.INSTANCE_HOME 13 17 14 18 class ScratchCardBatchesFolder(CPSDocument): ###( … … 45 49 security = ClassSecurityInfo() 46 50 47 def __init__(self,id,**kw):48 CPSDocument.__init__(self,id,**kw)49 self.table = PinTable()50 51 51 security.declareProtected(View,"Title") 52 52 def Title(self): … … 60 60 batch = self.getContent() 61 61 nr = batch.no_of_pins 62 prefix = batch.prefix 63 sold = batch.sold_by 64 cost = batch.cost 62 65 import random 63 66 r = random 64 67 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 65 73 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)) 73 84 74 85
Note: See TracChangeset for help on using the changeset viewer.