Changeset 6359
- Timestamp:
- 12 Jun 2011, 12:00:19 (14 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp
- Files:
-
- 4 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/__init__.py
r5447 r6359 1 1 # Make this a package. 2 from waeup.sirp.accesscodes.accesscodes import get_access_code 2 from waeup.sirp.accesscodes.accesscodes import ( 3 get_access_code, invalidate_accesscode) 3 4 4 5 # Public API of this submodule 5 6 __all__ = [ 6 get_access_code 7 get_access_code, 8 invalidate_accesscode, 7 9 ] 8 10 -
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 -
main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py
r6358 r6359 32 32 33 33 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState 34 35 34 from reportlab.pdfgen import canvas 36 35 36 from waeup.sirp.accesscodes import invalidate_accesscode 37 37 from waeup.sirp.browser import ( 38 38 WAeUPPage, WAeUPEditFormPage, WAeUPAddFormPage, WAeUPDisplayFormPage) … … 415 415 return 416 416 pin = self.request.principal.access_code 417 if pin not in self.context.keys(): 418 # Create applicant record 419 applicant = Applicant() 420 applicant.access_code = pin 421 self.context[pin] = applicant 417 if pin in self.context.keys(): 418 self.redirect(self.url(self.context[pin], 'edit')) 419 return 420 421 # Mark pin as used 422 invalidate_accesscode(pin) 423 424 # Create applicant record 425 applicant = Applicant() 426 applicant.access_code = pin 427 self.context[pin] = applicant 428 422 429 # Assign current principal the owner role on created applicant 423 430 # record
Note: See TracChangeset for help on using the changeset viewer.