Ignore:
Timestamp:
12 Sep 2011, 13:31:51 (13 years ago)
Author:
Henrik Bettermann
Message:

Add requestclearance action.

Let transition event handler also handle the locking and unlocking of the clearance form.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/students
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py

    r6720 r6722  
    7272from waeup.sirp.accesscodes import invalidate_accesscode, get_access_code
    7373from waeup.sirp.accesscodes.workflow import USED
     74from waeup.sirp.students.workflow import CLEARANCE
    7475
    7576class StudentsTab(PrimaryNavTab):
     
    598599    grok.view(StudentClearanceDisplayFormPage)
    599600    grok.require('waeup.handleStudent')
    600     text = 'Edit and submit'
     601    text = 'Edit'
    601602    target = 'cedit'
    602603
     
    615616    form_fields = grok.AutoFields(IStudentClearanceEdit).omit('clearance_locked')
    616617    #grok.template('clearanceeditpage')
    617     label = 'Edit clerance data'
     618    label = 'Edit clearance data'
    618619    title = 'Clearance Data'
    619620    pnav = 4
     
    631632        datepicker.need()
    632633        return super(StudentClearanceEditFormPage, self).update()
     634
     635    @grok.action('Save')
     636    def save(self, **data):
     637        self.applyData(self.context, **data)
     638        self.flash('Form has been saved.')
     639        return
     640
     641    @grok.action('Save and request clearance')
     642    def requestclearance(self, **data):
     643        self.applyData(self.context, **data)
     644        self.context._p_changed = True
     645        #if self.dataNotComplete():
     646        #    self.flash(self.dataNotComplete())
     647        #    return
     648        state = IWorkflowState(self.context).getState()
     649        # This shouldn't happen, but the application officer
     650        # might have forgotten to lock the form after changing the state
     651        if state != CLEARANCE:
     652            self.flash('This form cannot be submitted. Wrong state!')
     653            return
     654        IWorkflowInfo(self.context).fireTransition('request_clearance')
     655        self.flash('Clearance has been requested.')
     656        self.redirect(self.url(self.context))
     657        return
    633658
    634659class StartClearance(WAeUPPage):
     
    668693            invalidate_accesscode(pin,comment)
    669694        IWorkflowInfo(self.context).fireTransition('start_clearance')
    670         self.context.application_date = datetime.now()
    671         self.context.clearance_locked = False
    672695        self.flash('Clearance process is started.')
    673696        self.redirect(self.url(self.context))
  • main/waeup.sirp/trunk/src/waeup/sirp/students/workflow.py

    r6720 r6722  
    8282    )
    8383
     84LOCK_CLEARANCE_TRANS = ('reset2', 'request_clearance')
     85UNLOCK_CLEARANCE_TRANS = ('reset3', 'reset4', 'start_clearance')
    8486
    8587registration_workflow = WAeUPWorkflow(REGISTRATION_TRANSITIONS)
     
    111113    history = IObjectHistory(obj)
    112114    history.addMessage(msg)
     115    if event.transition.transition_id in LOCK_CLEARANCE_TRANS:
     116        obj.clearance_locked = True
     117    if event.transition.transition_id in UNLOCK_CLEARANCE_TRANS:
     118        obj.clearance_locked = False
    113119    # In some tests we don't have a students container or a user
    114120    try:
Note: See TracChangeset for help on using the changeset viewer.