Ignore:
Timestamp:
22 Apr 2013, 10:36:25 (12 years ago)
Author:
Henrik Bettermann
Message:

Prepare browser components for file uploads in custom packages.

File:
1 edited

Legend:

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

    r9984 r10090  
    796796        self.wf_info = IWorkflowInfo(self.context)
    797797        self.max_upload_size = string_from_bytes(MAX_UPLOAD_SIZE)
    798         self.passport_changed = None
     798        self.files_uploaded = []
     799        self.upload_success = None
    799800        upload = self.request.form.get('form.passport', None)
    800801        if upload:
    801             # We got a fresh upload
    802             self.passport_changed = handle_img_upload(
     802            # We got a fresh upload, upload_success is
     803            # either True or False
     804            self.upload_success = handle_img_upload(
    803805                upload, self.context, self)
     806            if self.upload_success:
     807                self.files_uploaded.append('passport')
    804808        return
    805809
     
    833837                self.flash( ' '.join(errors))
    834838                return
    835         if self.passport_changed is False:  # False is not None!
    836             return # error during image upload. Ignore other values
     839        if self.upload_success is False:  # False is not None!
     840            # Error during image upload. Ignore other values.
     841            # In custom packages other file uploads might have been
     842            # successful.
     843            changed_fields = self.files_uploaded
     844            fields_string = ' + '.join(changed_fields)
     845            if fields_string:
     846                self.context.writeLogMessage(self, 'saved: % s' % fields_string)
     847            return
    837848        changed_fields = self.applyData(self.context, **data)
    838849        # Turn list of lists into single list
     
    841852        else:
    842853            changed_fields = []
    843         if self.passport_changed:
    844             changed_fields.append('passport')
     854        if self.upload_success:
     855            changed_fields += self.files_uploaded
    845856        if password:
    846857            # Now we know that the form has no errors and can set password ...
     
    973984    @action(_('Save'), style='primary')
    974985    def save(self, **data):
    975         if self.passport_changed is False:  # False is not None!
    976             return # error during image upload. Ignore other values
     986        if self.upload_success is False:  # False is not None!
     987            # Error during image upload. Ignore other values.
     988            # In custom packages other file uploads might have been
     989            # successful.
     990            changed_fields = self.files_uploaded
     991            fields_string = ' + '.join(changed_fields)
     992            if fields_string:
     993                self.context.writeLogMessage(self, 'saved: % s' % fields_string)
     994            return
    977995        self.applyData(self.context, **data)
    978996        self.flash('Form has been saved.')
     
    981999    @submitaction(_('Final Submit'))
    9821000    def finalsubmit(self, **data):
    983         if self.passport_changed is False:  # False is not None!
     1001        if self.upload_success is False:  # False is not None!
    9841002            return # error during image upload. Ignore other values
    9851003        if self.dataNotComplete():
Note: See TracChangeset for help on using the changeset viewer.