Ignore:
Timestamp:
26 May 2011, 05:26:37 (13 years ago)
Author:
Henrik Bettermann
Message:

Reorganize views for applicants and application officers. We don't need a special treatment for the Uniben passport confirmation check box.

File:
1 edited

Legend:

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

    r6189 r6196  
    5454from waeup.sirp.applicants import ResultEntry, Applicant, get_applicant_data
    5555from waeup.sirp.applicants.interfaces import (
    56     IApplicant, IApplicantPrincipal, IApplicantPDEEditData,
     56    IApplicant, IApplicantPrincipal,IApplicantEdit,
    5757    IApplicantsRoot, IApplicantsContainer, IApplicantsContainerProvider,
    5858    IApplicantsContainerAdd, application_types_vocab
     
    435435    grok.require('waeup.viewApplication')
    436436    form_fields = grok.AutoFields(IApplicant).omit('locked')
    437     form_fields['fst_sit_results'].custom_widget = list_results_display_widget
     437    #form_fields['fst_sit_results'].custom_widget = list_results_display_widget
    438438    form_fields['passport'].custom_widget = ThumbnailWidget
    439439    form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
    440440    label = 'Applicant'
    441     title = 'Applicant'
    442     pnav = 3
    443 
    444 class EditApplicantStudent(WAeUPEditFormPage):
     441    pnav = 3
     442
     443    @property
     444    def title(self):
     445        return '%s' % self.context.access_code
     446
     447    @property
     448    def label(self):
     449        container_title = self.context.__parent__.title
     450        return '%s Application Record' % container_title
     451
     452class EditApplicantFull(WAeUPEditFormPage):
     453    """A full edit view for applicant data.
     454    """
     455    grok.context(IApplicant)
     456    grok.name('edit_full')
     457    grok.require('waeup.editFullApplication')
     458    form_fields = grok.AutoFields(IApplicant)   #.omit('locked')
     459    form_fields['passport'].custom_widget = EncodingImageFileWidget
     460    form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
     461    grok.template('form_edit')
     462    pnav = 3
     463
     464    def update(self):
     465        datepicker.need() # Enable jQuery datepicker in date fields.
     466        super(EditApplicantFull, self).update()
     467        return
     468
     469    @property
     470    def title(self):
     471        return self.context.access_code
     472
     473    @property
     474    def label(self):
     475        container_title = self.context.__parent__.title
     476        return '%s Application Form' % container_title
     477
     478    @grok.action('Save')
     479    def save(self, **data):
     480        self.applyData(self.context, **data)
     481        self.context._p_changed = True
     482        self.flash('Form has been saved.')
     483        return
     484
     485class EditApplicantStudent(EditApplicantFull):
    445486    """An applicant-centered edit view for applicant data.
    446487    """
    447     grok.context(IApplicant)
     488    grok.context(IApplicantEdit)
    448489    grok.name('edit')
    449490    grok.require('waeup.editApplication')
    450     form_fields = grok.AutoFields(IApplicantPDEEditData).omit('locked')
     491    form_fields = grok.AutoFields(IApplicantEdit).omit('locked')
    451492    form_fields['passport'].custom_widget = EncodingImageFileWidget
    452493    form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
    453     grok.template('form_edit_pde')
     494    grok.template('form_edit')
    454495
    455496    def emitLockMessage(self):
     
    466507        return
    467508
    468     def filteredWidgets(self):
    469         for widget in self.widgets:
    470             if widget.name == 'form.confirm_passport':
    471                 continue
    472             yield widget
    473 
    474     @property
    475     def label(self):
    476         # XXX: Use current/upcoming session
    477         return 'Apply for Post UDE Screening Test (2009/2010)'
    478     title = 'Edit Application'
    479     pnav = 3
     509    def dataNotComplete(self):
     510        if self.context.confirm_passport is not True:
     511            return 'Passport confirmation box not ticked.'
     512        if len(self.errors) > 0:
     513            return 'Form has errors.'
     514        return False
    480515
    481516    @grok.action('Save')
     
    486521        self.applyData(self.context, **data)
    487522        self.context._p_changed = True
     523        self.flash('Form has been saved.')
    488524        return
    489525
     
    495531        self.applyData(self.context, **data)
    496532        self.context._p_changed = True
    497         if not self.dataComplete():
    498             self.flash('Data yet not complete.')
     533        if self.dataNotComplete():
     534            self.flash(self.dataNotComplete())
    499535            return
    500536        self.context.locked = True
    501         return
    502 
    503     def dataComplete(self):
    504         if self.context.confirm_passport is not True:
    505             return False
    506         if len(self.errors) > 0:
    507             return False
    508         return True
    509 
    510 class EditApplicantFull(WAeUPEditFormPage):
    511     """A full edit view for applicant data.
    512 
    513     This one is meant to be used by officers only.
    514     """
    515     grok.context(IApplicant)
    516     grok.name('edit_full')
    517     grok.require('waeup.editFullApplication')
    518     form_fields = grok.AutoFields(IApplicantPDEEditData).omit('locked')
    519     form_fields['passport'].custom_widget = EncodingImageFileWidget
    520     form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
    521     grok.template('form_edit_full')
    522 
    523     def update(self):
    524         if self.context.locked:
    525             self.emitLockMessage()
    526             return
    527         datepicker.need() # Enable jQuery datepicker in date fields.
    528         super(EditApplicantFull, self).update()
    529         return
    530 
    531     def filteredWidgets(self):
    532         for widget in self.widgets:
    533             if widget.name == 'form.confirm_passport':
    534                 continue
    535             yield widget
    536 
    537     @property
    538     def label(self):
    539         return 'Application for %s' % self.context.access_code
    540     title = 'Edit Application'
    541     pnav = 3
    542 
    543     @grok.action('Save')
    544     def save(self, **data):
    545         self.applyData(self.context, **data)
    546         self.context._p_changed = True
    547         return
     537        self.flash('Form has been submitted.')
     538        self.redirect(self.url(self.context))
     539        return
     540
Note: See TracChangeset for help on using the changeset viewer.