Changeset 6936 for main/waeup.sirp/trunk/src/waeup/sirp/accesscodes
- Timestamp:
- 24 Oct 2011, 10:23:11 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/accesscodes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/__init__.py
r6632 r6936 18 18 from waeup.sirp.accesscodes.accesscode import ( 19 19 get_access_code, invalidate_accesscode, disable_accesscode, 20 reenable_accesscode, AccessCode, AccessCodeBatch, AccessCodeBatchContainer) 20 reenable_accesscode, purchase_accesscode, 21 AccessCode, AccessCodeBatch, AccessCodeBatchContainer) 21 22 22 23 # Public API of this submodule … … 29 30 'disable_accesscode', 30 31 'reenable_accesscode', 32 'purchase_accesscode', 31 33 ] -
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/accesscode.py
r6933 r6936 143 143 """Create the entries for this batch. 144 144 """ 145 for num, pin in enumerate(self. _getNewRandomNum(num=self.entry_num)):145 for num, pin in enumerate(self.getNewRandomNum(num=self.entry_num)): 146 146 self.addAccessCode(num, pin) 147 147 return 148 148 149 def _getNewRandomNum(self, num=1):149 def getNewRandomNum(self, num=1): 150 150 """Create a set of ``num`` random numbers of 10 digits each. 151 151 … … 177 177 return self[ac_id] 178 178 179 def addAccessCode(self, num, pin ):179 def addAccessCode(self, num, pin, owner=None): 180 180 """Add an access-code. 181 181 """ 182 182 ac = AccessCode(num, pin) 183 if owner: 184 ac.owner = owner 183 185 ac.__parent__ = self 184 186 self[ac.representation] = ac … … 546 548 """ 547 549 return fire_transition(access_code, 'reenable', comment=comment) 550 551 def purchase_accesscode(batch_prefix, batch_num, owner): 552 """ 553 """ 554 batch_id = '%s-%s' % (batch_prefix, batch_num) 555 try: 556 batch = grok.getSite()['accesscodes'][batch_id] 557 except KeyError: 558 return None, u'No activation code available.' 559 rand_num = list(batch.getNewRandomNum())[0] 560 #import pdb; pdb.set_trace() 561 num = len(batch) + 1 562 batch.addAccessCode(num, rand_num, owner) 563 pin = u'%s-%s-%s' % (batch_prefix,batch_num,rand_num) 564 return pin, None
Note: See TracChangeset for help on using the changeset viewer.