Changeset 5941 for main/waeup.sirp/trunk


Ignore:
Timestamp:
14 Apr 2011, 08:07:37 (14 years ago)
Author:
uli
Message:

Introduce locked-attribute for applicants to control workflow a bit.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/applicants
Files:
3 edited

Legend:

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

    r5911 r5941  
    4343
    4444    fst_sit_results = FieldProperty(IApplicant['fst_sit_results'])
     45    locked = False
    4546   
    4647    def __init__(self):
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py

    r5937 r5941  
    351351    grok.name('index')
    352352    grok.require('waeup.viewApplication')
    353     form_fields = grok.AutoFields(IApplicant)
     353    form_fields = grok.AutoFields(IApplicant).omit('locked')
    354354    form_fields['fst_sit_results'].custom_widget = list_results_display_widget
    355355    #form_fields['passport'].custom_widget = PassportDisplayWidget
     
    364364    grok.name('edit')
    365365    grok.require('waeup.editApplication')
    366     form_fields = grok.AutoFields(IApplicantPDEEditData)
     366    form_fields = grok.AutoFields(IApplicantPDEEditData).omit('locked')
    367367    #form_fields['passport'].custom_widget = FileWidget
    368368    #form_fields['passport'].custom_widget = PassportWidget
     
    370370    grok.template('form_edit_pde')
    371371
     372    def emitLockMessage(self):
     373        self.flash('The requested form is locked (read-only)')
     374        self.redirect(self.url(self.context))
     375        return
     376   
    372377    def update(self):
     378        if self.context.locked:
     379            self.emitLockMessage()
     380            return
    373381        super(EditApplicant, self).update()
    374         print self.request.form
    375382        return
    376383   
     
    384391    @grok.action('Save')
    385392    def save(self, **data):
     393        if self.context.locked:
     394            self.emitLockMessage()
     395            return
    386396        self.applyData(self.context, **data)
    387397        self.context._p_changed = True
     
    390400    @grok.action('Final Submit')
    391401    def finalsubmit(self, **data):
     402        if self.context.locked:
     403            self.emitLockMessage()
     404            return
    392405        self.applyData(self.context, **data)
    393406        self.context._p_changed = True
    394         # XXX: Lock the form for editing...
    395         return
     407        if not self.dataComplete():
     408            self.flash('Data yet not complete.')
     409            return
     410        self.context.locked = True
     411        return
     412
     413    def dataComplete(self):
     414        if self.request.form.get('confirm', False) is False:
     415            return False
     416        if len(self.errors) > 0:
     417            return False
     418        return True
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/interfaces.py

    r5907 r5941  
    454454    required attributes set to True (which is the default).
    455455    """
     456    locked = schema.Bool(
     457        title = u'Form locked',
     458        default = False,
     459        readonly = True,
     460        )
    456461    access_code = schema.TextLine(
    457462        title = u'Access Code',
     
    558563    """The data set presented to PDE applicants.
    559564    """
     565    locked = schema.Bool(
     566        title = u'Form locked',
     567        default = False,
     568        readonly = True,
     569        )
    560570    reg_no = schema.TextLine(
    561571        title = u'JAMB Registration Number',
Note: See TracChangeset for help on using the changeset viewer.