- Timestamp:
- 9 Jun 2011, 12:27:17 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py
r6254 r6303 31 31 from zope.traversing.browser import absoluteURL 32 32 33 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState 34 33 35 from waeup.sirp.browser import ( 34 36 WAeUPPage, WAeUPEditFormPage, WAeUPAddFormPage, … … 61 63 from waeup.sirp.browser.pages import add_local_role, del_local_roles 62 64 from waeup.sirp.permissions import get_users_with_local_roles, getRoles 65 from waeup.sirp.applicants.workflow import create_workflow, INITIALIZED, STARTED 63 66 64 67 results_widget = CustomWidgetFactory( … … 393 396 if SUBMIT is None: 394 397 return 395 396 398 if self.request.principal.id == 'zope.anybody': 397 399 self.flash('Entered credentials are invalid.') 398 400 return 399 400 401 if not IApplicantPrincipal.providedBy(self.request.principal): 401 402 # Don't care if user is already authenticated as non-applicant 402 403 return 403 404 404 pin = self.request.principal.access_code 405 405 if pin not in self.context.keys(): … … 408 408 applicant.access_code = pin 409 409 self.context[pin] = applicant 410 411 410 # Assign current principal the owner role on created applicant 412 411 # record … … 414 413 role_manager.assignRoleToPrincipal( 415 414 'waeup.local.ApplicationOwner', self.request.principal.id) 415 state = IWorkflowState(self.context[pin]).getState() 416 if state == INITIALIZED: 417 IWorkflowInfo(self.context[pin]).fireTransition('start') 416 418 self.redirect(self.url(self.context[pin], 'edit')) 417 419 return … … 464 466 return 'not yet admitted' 465 467 468 @property 469 def getApplicationState(self): 470 state = IWorkflowState(self.context).getState() 471 return state 472 466 473 class ApplicantsManageActionButton(ManageActionButton): 467 474 grok.context(IApplicant) … … 497 504 return '%s Application Form' % container_title 498 505 506 @property 507 def getTransitions(self): 508 allowed_transitions_ids = IWorkflowInfo(self.context).getManualTransitionIds() 509 transition_objects = create_workflow() 510 null_transition = [{'name': '', 'title':'No transition'}] 511 transitions = null_transition + [dict( 512 name=transition_object.transition_id, 513 title=transition_object.title) 514 for transition_object in transition_objects 515 if transition_object.transition_id in allowed_transitions_ids] 516 #import pdb; pdb.set_trace() 517 return transitions 518 519 @property 520 def getApplicationState(self): 521 state = IWorkflowState(self.context).getState() 522 return state 523 499 524 @grok.action('Save') 500 525 def save(self, **data): 501 526 self.applyData(self.context, **data) 502 527 self.context._p_changed = True 528 form = self.request.form 529 if form.has_key('transition') and form['transition']: 530 transition = form['transition'] 531 IWorkflowInfo(self.context).fireTransition(transition) 503 532 self.flash('Form has been saved.') 504 533 return … … 535 564 return False 536 565 566 @property 567 def getTransitions(self): 568 return None 569 537 570 @grok.action('Save') 538 571 def save(self, **data): … … 555 588 self.flash(self.dataNotComplete()) 556 589 return 590 state = IWorkflowState(self.context).getState() 591 # Cannot happen but anyway ... 592 if state != STARTED: 593 self.flash('This form cannot be submitted.') 594 return 595 IWorkflowInfo(self.context).fireTransition('submit') 557 596 self.context.locked = True 558 597 self.flash('Form has been submitted.')
Note: See TracChangeset for help on using the changeset viewer.