Changeset 6303 for main/waeup.sirp/trunk/src/waeup/sirp
- Timestamp:
- 9 Jun 2011, 12:27:17 (14 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/applicants
- Files:
-
- 3 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.') -
main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser_templates/form_display.pt
r6254 r6303 2 2 tal:condition="view/label" 3 3 tal:content="view/label">Label</h2> 4 5 <h3>Application Status: 6 <span tal:replace="view/getApplicationState">Application State</span></h3> 4 7 5 8 <table class="zebra"> … … 11 14 </td> 12 15 <td> 13 < inputtal:replace="structure widget" />16 <span tal:replace="structure widget" /> 14 17 </td> 15 18 </tr> … … 20 23 </td> 21 24 <td> 22 < inputtal:replace="structure view/getCourseAdmitted" />25 <span tal:replace="structure view/getCourseAdmitted" /> 23 26 </td> 24 27 </tr> -
main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser_templates/form_edit.pt
r6204 r6303 5 5 tal:condition="view/label" 6 6 tal:content="view/label">Label</h2> 7 8 <h3>Application Status: 9 <span tal:replace="view/getApplicationState">Application State</span></h3> 7 10 8 11 <div class="form-status" … … 49 52 </tr> 50 53 </tal:block> 54 <tr tal:condition="view/getTransitions"> 55 <td class="label"><label>Application Transition:</label></td> 56 <td> 57 <select id="transition" name="transition"> 58 <option tal:repeat="transition view/getTransitions" tal:attributes="value transition/name"> 59 <span tal:replace="transition/title">TRANSITIONTITLE 60 </span> 61 </option> 62 </select> 63 </td> 64 </tr> 51 65 </tbody> 52 66 </table>
Note: See TracChangeset for help on using the changeset viewer.