Ignore:
Timestamp:
16 Nov 2011, 11:12:54 (13 years ago)
Author:
Henrik Bettermann
Message:

Add upload pages for students.

input_name should correspond with the name of the view otherwise zope.manager will get problems when uploading a file because zope.manager does see both viewlets.

File:
1 edited

Legend:

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

    r7114 r7117  
    275275    grok.require('waeup.manageStudents')
    276276    mus = 1024 * 150
    277     input_name = u'filename'
     277
     278    @property
     279    def input_name(self):
     280        return "%s" % self.__name__
    278281
    279282    def update(self):
    280283        self.max_upload_size = string_from_bytes(self.mus)
    281         delete_button = self.request.form.get('delete_%s' % self.input_name, None)
    282         upload_button = self.request.form.get('upload_%s' % self.input_name, None)
     284        delete_button = self.request.form.get(
     285            'delete_%s' % self.input_name, None)
     286        upload_button = self.request.form.get(
     287            'upload_%s' % self.input_name, None)
    283288        if delete_button:
    284289            handle_file_delete(
     
    296301                self.view.redirect(
    297302                    self.view.url(self.context, self.view.__name__))
     303            else:
     304                self.view.flash('No local file selected.')
     305                self.view.redirect(
     306                    self.view.url(self.context, self.view.__name__))
    298307        return
    299308
     
    320329    mus = 1024 * 50
    321330    download_name = u'passport.jpg'
    322     input_name = u'passport'
    323331
    324332class PassportUploadEdit(PassportUploadManage):
     
    335343    download_name = u'birth_certificate.jpg'
    336344
    337 class BirthCertificateUpload(FileUpload):
     345class BirthCertificateUploadManage(FileUpload):
    338346    """Birth Certificate upload viewlet.
    339347    """
     
    342350    mus = 1024 * 150
    343351    download_name = u'birth_certificate.jpg'
    344     input_name = u'birth_certificate'
    345352
    346353class AcceptanceLetterDisplay(FileDisplay):
     
    351358    download_name = u'acceptance_letter.jpg'
    352359
    353 class AcceptanceLetterUpload(FileUpload):
     360class AcceptanceLetterUploadManage(FileUpload):
    354361    """AcceptanceLetter upload viewlet.
    355362    """
     
    358365    mus = 1024 * 150
    359366    download_name = u'acceptance_letter.jpg'
    360     input_name = u'acceptance_letter'
     367
     368class BirthCertificateUploadEdit(BirthCertificateUploadManage):
     369    """Birth Certificate upload viewlet for student.
     370    """
     371    grok.require('waeup.handleStudent')
     372
     373class AcceptanceLetterUploadEdit(AcceptanceLetterUploadManage):
     374    """AcceptanceLetter upload viewlet for student.
     375    """
     376    grok.require('waeup.handleStudent')
    361377
    362378class Image(grok.View):
Note: See TracChangeset for help on using the changeset viewer.