- Timestamp:
- 12 Jun 2011, 12:00:19 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/accesscodes.py
r6124 r6359 6 6 from BTrees.OIBTree import OIBTree 7 7 from datetime import datetime 8 from hurry.workflow.interfaces import IWorkflowInfo 8 9 from random import SystemRandom as random 9 10 from waeup.sirp.interfaces import IWAeUPSIRPPluggable … … 11 12 IAccessCode, IAccessCodeBatch, IAccessCodeBatchContainer 12 13 ) 14 from waeup.sirp.accesscodes.workflow import DISABLED 13 15 14 16 class ManageACBatches(grok.Permission): 15 17 grok.name('waeup.manageACBatches') 16 18 17 class AccessCode(grok. Context):19 class AccessCode(grok.Model): 18 20 grok.implements(IAccessCode) 19 21 … … 25 27 self.student_id = student_id 26 28 self._disabled = disabled 29 IWorkflowInfo(self).fireTransition('init') 27 30 28 31 @property … … 155 158 self.invalidated_num += 1 156 159 157 def disable(self, ac_id, user_id ):160 def disable(self, ac_id, user_id=None): 158 161 """Disable the AC with ID ``ac_id``. 159 162 … … 389 392 return 390 393 394 def invalidate(self, ac_id): 395 """Invalidate the AC with ID ``ac_id``. 396 """ 397 ac = self.getAccessCode(ac_id) 398 if ac is None: 399 return 400 ac.__parent__.invalidate(ac_id) 401 return 402 391 403 392 404 class AccessCodePlugin(grok.GlobalUtility): … … 430 442 if batch is None: 431 443 return None 432 433 444 try: 434 445 code = batch.getAccessCode(access_code) … … 436 447 return None 437 448 return code 449 450 def invalidate_accesscode(access_code): 451 ac = get_access_code(access_code) 452 info = IWorkflowInfo(ac) 453 info.fireTransition('use') 454 return 455 456 def disable_accesscode(access_code): 457 ac = get_access_code(access_code) 458 info = IWorkflowInfo(ac) 459 info.fireTransitionToward(DISABLED) 460 return 461 462 def reenable_accesscode(access_code): 463 ac = get_access_code(access_code) 464 info = IWorkflowInfo(ac) 465 info.fireTransition('reenable') 466 return
Note: See TracChangeset for help on using the changeset viewer.