Changeset 6196


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.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/applicants
Files:
2 edited
1 copied

Legend:

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

    r6187 r6196  
    2828from waeup.sirp.app import University
    2929from waeup.sirp.applicants.interfaces import (
    30     IResultEntry, IApplicant, IApplicantPDEEditData,
     30    IResultEntry, IApplicant, IApplicantEdit,
    3131    DEFAULT_PASSPORT_IMAGE_MALE,
    3232    )
     
    4141
    4242class Applicant(grok.Model):
    43     grok.implements(IApplicant, IApplicantPDEEditData)
     43    grok.implements(IApplicant,IApplicantEdit)
    4444    grok.provides(IApplicant)
    4545
  • 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
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser_templates/form_edit.pt

    r6194 r6196  
    2121  </div>
    2222
    23   <div class="block">
    24     <h3>Instructions</h3>
    25     <ol class="list">
    26       <li>
    27         Fill the form and upload your Passport Photograph with red background
    28         in jpg format.
    29       </li>
    30       <li>
    31         Save and preview picture.
    32       </li>
    33       <li>
    34         Press the <em>Final Submit</em> button.
    35       </li>
    36     </ol>
    37   </div>
    38 
    3923  <table class="form-fields zebra">
    4024    <tbody>
    41       <tal:block repeat="widget view/filteredWidgets">
     25      <tal:block repeat="widget view/widgets">
    4226        <tr>
    4327          <td class="label" tal:define="hint widget/hint">
    4428            <label tal:condition="python:hint"
    4529                   tal:attributes="for widget/name">
    46               <span class="required" tal:condition="widget/required"
    47               >*</span><span i18n:translate=""
     30              <span class="required" tal:condition="widget/required">*
     31              </span><span i18n:translate=""
    4832                             tal:content="widget/label">label</span>
    4933            </label>
    5034            <label tal:condition="python:not hint"
    5135                   tal:attributes="for widget/name">
    52               <span class="required" tal:condition="widget/required"
    53               >*</span><span i18n:translate=""
     36              <span class="required" tal:condition="widget/required">*
     37              </span><span i18n:translate=""
    5438                             tal:content="widget/label">label</span>
    5539            </label>
     
    6549        </tr>
    6650      </tal:block>
    67       <tr>
    68         <td colspan="2">
    69           <input class="hiddenType" id="form.confirm_passport.used"
    70                  name="form.confirm_passport.used" type="hidden" value="" />
    71           <input type="checkbox" name="form.confirm_passport"
    72                  tal:attributes="checked context/confirm_passport"
    73                  />
    74           <label for="confirm"></label>
    75 <span>
    76             I confirm that the Passport Photograph uploaded on this form
    77             is a true picture of me.
    78           </span>
    79         </td>
    80       </tr>
    8151    </tbody>
    8252  </table>
     
    9060  </div>
    9161</form>
    92 
    93 <br />
    94 
Note: See TracChangeset for help on using the changeset viewer.