Ignore:
Timestamp:
29 Apr 2013, 08:18:41 (12 years ago)
Author:
Henrik Bettermann
Message:

Make provision for uploading the referee's form. Rename form extension.

File:
1 edited

Legend:

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

    r10096 r10105  
    8282        html = ''
    8383        pdf = getUtility(IExtFileStore).getFileByContext(
    84             self.context, attr='formextension.pdf')
     84            self.context, attr='extraform.pdf')
    8585        if pdf:
    86             html += '<a href="formextension.pdf">Offline Form Extension</a>'
     86            html += '<a href="extraform.pdf">Extra Applicant Information Form</a>, '
     87        pdf = getUtility(IExtFileStore).getFileByContext(
     88            self.context, attr='refereeform.pdf')
     89        if pdf:
     90            html += '<a href="refereeform.pdf">Referee\'s Form</a>'
    8791        return html
    8892
     
    113117    def update(self):
    114118        super(CustomApplicantDisplayFormPage, self).update()
    115         self.formextension_url = self.url(self.context, 'formextension.pdf')
     119        self.extraform_url = self.url(self.context, 'extraform.pdf')
     120        self.referreeform_url = self.url(self.context, 'refereeform.pdf')
    116121        return
    117122
     
    161166    def update(self):
    162167        super(CustomApplicantManageFormPage, self).update()
    163         upload_formextension = self.request.form.get('form.formextension', None)
    164         if upload_formextension:
    165             # We got a fresh formextension upload
    166             self.upload_success = handle_file_upload(
    167                 upload_formextension, self.context, self, attr='formextension.pdf')
    168             if self.upload_success:
    169                 self.context.writeLogMessage(self, 'saved: formextension')
     168        upload_extraform = self.request.form.get('form.extraform', None)
     169        if upload_extraform:
     170            # We got a fresh extraform upload
     171            success = handle_file_upload(
     172                upload_extraform, self.context, self, attr='extraform.pdf')
     173            if success:
     174                self.context.writeLogMessage(self, 'saved: extraform')
     175            else:
     176                self.upload_success = False
     177        upload_refereeform = self.request.form.get('form.refereeform', None)
     178        if upload_refereeform:
     179            # We got a fresh refereeform upload
     180            success = handle_file_upload(
     181                upload_refereeform, self.context, self, attr='refereeform.pdf')
     182            if success:
     183                self.context.writeLogMessage(self, 'saved: refereeform')
     184            else:
     185                self.upload_success = False
    170186        self.max_file_upload_size = string_from_bytes(MAX_FILE_UPLOAD_SIZE)
    171187        return
     
    195211        if not store.getFileByContext(self.context, attr=u'passport.jpg'):
    196212            return _('No passport picture uploaded.')
    197         if not store.getFileByContext(self.context, attr=u'formextension.pdf'):
    198             return _('No form extension pdf file uploaded.')
     213        if not store.getFileByContext(self.context, attr=u'extraform.pdf'):
     214            return _('No extra information form pdf file uploaded.')
     215        if not store.getFileByContext(self.context, attr=u'refereeform.pdf'):
     216            return _('No referee form pdf file uploaded.')
    199217        if not self.request.form.get('confirm_passport', False):
    200218            return _('Passport picture confirmation box not ticked.')
     
    208226            return
    209227        super(CustomApplicantEditFormPage, self).update()
    210         upload_formextension = self.request.form.get('form.formextension', None)
    211         if upload_formextension:
    212             # We got a fresh formextension upload
    213             self.upload_success = handle_file_upload(
    214                 upload_formextension, self.context, self, attr='formextension.pdf')
     228        upload_extraform = self.request.form.get('form.extraform', None)
     229        if upload_extraform:
     230            # We got a fresh extraform upload
     231            success = handle_file_upload(
     232                upload_extraform, self.context, self, attr='extraform.pdf')
     233            if not success:
     234                self.upload_success = False
     235        upload_refereeform = self.request.form.get('form.refereeform', None)
     236        if upload_refereeform:
     237            # We got a fresh refereeform upload
     238            success = handle_file_upload(
     239                upload_refereeform, self.context, self, attr='refereeform.pdf')
     240            if not success:
     241                self.upload_success = False
    215242        self.max_file_upload_size = string_from_bytes(MAX_FILE_UPLOAD_SIZE)
    216243        return
    217244
    218 class FormExtension(grok.View):
     245class ExtraForm(grok.View):
    219246    """Renders the pdf form extension for applicants.
    220247    """
    221     grok.name('formextension.pdf')
     248    grok.name('extraform.pdf')
    222249    grok.context(ICustomApplicant)
    223250    grok.require('waeup.viewApplication')
     
    225252    def render(self):
    226253        pdf = getUtility(IExtFileStore).getFileByContext(
    227             self.context, attr='formextension.pdf')
     254            self.context, attr='extraform.pdf')
    228255        self.response.setHeader('Content-Type', 'application/pdf')
    229256        return pdf
     257
     258class RefereeForm(grok.View):
     259    """Renders the pdf referee's form for applicants.
     260    """
     261    grok.name('refereeform.pdf')
     262    grok.context(ICustomApplicant)
     263    grok.require('waeup.viewApplication')
     264
     265    def render(self):
     266        pdf = getUtility(IExtFileStore).getFileByContext(
     267            self.context, attr='refereeform.pdf')
     268        self.response.setHeader('Content-Type', 'application/pdf')
     269        return pdf
Note: See TracChangeset for help on using the changeset viewer.