Ignore:
Timestamp:
23 Nov 2014, 05:31:13 (10 years ago)
Author:
Henrik Bettermann
Message:

Rename file viewlets.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/files.py

    r12036 r12038  
    226226
    227227
    228 class PassportUploadManage(FileUpload):
     228class PassportManageUpload(FileUpload):
    229229    """Passport upload viewlet for officers.
    230230    """
     
    240240
    241241
    242 class PassportUploadEdit(PassportUploadManage):
     242class PassportEditUpload(PassportManageUpload):
    243243    """Passport upload viewlet for customers.
    244244    """
     
    257257# File viewlets for customer documents
    258258
    259 class GenericUploadManage(FileUpload):
    260     """Generic document upload viewlet for officers.
     259class ScanManageUpload(FileUpload):
     260    """Scan upload viewlet for officers.
    261261    """
    262262    grok.order(1)
     
    264264    grok.view(DocumentManageFormPage)
    265265    grok.require('waeup.manageCustomer')
    266     label = _(u'Generic Document')
    267     title = _(u'Generic Document')
     266    label = _(u'Scan')
     267    title = _(u'Scan')
    268268    mus = 1024 * 50
    269     download_name = u'generic'
     269    download_name = u'scan'
    270270    tab_redirect = '#tab2'
    271271
    272272
    273 class GenericUploadEdit(GenericUploadManage):
    274     """Generic document upload viewlet for customer.
     273class ScanEditUpload(ScanManageUpload):
     274    """Scan upload viewlet for customer.
    275275    """
    276276    grok.view(DocumentEditFormPage)
     
    278278
    279279
    280 class GenericDisplay(FileDisplay):
    281     """Genreric document display viewlet.
     280class ScanDisplay(FileDisplay):
     281    """Scan display viewlet.
    282282    """
    283283    grok.order(1)
     
    285285    grok.require('waeup.viewCustomer')
    286286    grok.view(DocumentDisplayFormPage)
    287     label = _(u'Generic Document')
    288     title = _(u'Generic Document')
    289     download_name = u'generic'
    290 
    291 
    292 class GenericImage(Image):
    293     """Generic document.
    294     """
    295     grok.name('generic')
     287    label = _(u'Scan')
     288    title = _(u'Scan')
     289    download_name = u'scan'
     290
     291
     292class ScanImage(Image):
     293    """Scan document.
     294    """
     295    grok.name('scan')
    296296    grok.context(ICustomerDocument)
    297297    grok.require('waeup.viewCustomer')
    298     download_name = u'generic'
     298    download_name = u'scan'
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py

    r12037 r12038  
    333333        self.browser.open(self.manage_customer_path)
    334334        image = open(SAMPLE_IMAGE_BMP, 'rb')
    335         ctrl = self.browser.getControl(name='passportuploadmanage')
     335        ctrl = self.browser.getControl(name='passportmanageupload')
    336336        file_ctrl = ctrl.mech_control
    337337        file_ctrl.add_file(image, filename='my_photo.bmp')
    338338        self.browser.getControl(
    339             name='upload_passportuploadmanage').click()
     339            name='upload_passportmanageupload').click()
    340340        self.assertTrue('jpg file extension expected'
    341341            in self.browser.contents)
    342         ctrl = self.browser.getControl(name='passportuploadmanage')
     342        ctrl = self.browser.getControl(name='passportmanageupload')
    343343        file_ctrl = ctrl.mech_control
    344344        image = open(SAMPLE_IMAGE, 'rb')
    345345        file_ctrl.add_file(image, filename='my_photo.jpg')
    346346        self.browser.getControl(
    347             name='upload_passportuploadmanage').click()
     347            name='upload_passportmanageupload').click()
    348348        self.assertTrue(
    349349            'src="http://localhost/app/customers/K1000000/passport.jpg"'
     
    561561        # Admitted customer can upload a passport picture
    562562        self.browser.getLink("Change portrait").click()
    563         ctrl = self.browser.getControl(name='passportuploadedit')
     563        ctrl = self.browser.getControl(name='passporteditupload')
    564564        file_obj = open(SAMPLE_IMAGE, 'rb')
    565565        file_ctrl = ctrl.mech_control
    566566        file_ctrl.add_file(file_obj, filename='my_photo.jpg')
    567567        self.browser.getControl(
    568             name='upload_passportuploadedit').click()
     568            name='upload_passporteditupload').click()
    569569        self.assertTrue(
    570570            'src="http://localhost/app/customers/K1000000/passport.jpg"'
     
    786786        self.browser.getLink("Documents").click()
    787787        self.browser.getLink("Add document").click()
    788         self.browser.getControl(name="doctype").value = ['generic']
     788        self.browser.getControl(name="doctype").value = ['sample']
    789789        self.browser.getControl("Create document").click()
    790         self.assertTrue('Generic Document created.' in self.browser.contents)
     790        self.assertTrue('Sample Document created.' in self.browser.contents)
    791791        document = self.customer['documents']['d102']
    792792
     
    827827        self.assertTrue(
    828828            'INFO - zope.mgr - customers.browser.DocumentAddFormPage '
    829             '- K1000000 - added: Generic Document %s'
     829            '- K1000000 - added: Sample Document %s'
    830830            % document.document_id in logcontent)
    831831
     
    845845        self.browser.getLink("Documents").click()
    846846        self.browser.getLink("Add document").click()
    847         self.browser.getControl(name="doctype").value = ['generic']
     847        self.browser.getControl(name="doctype").value = ['sample']
    848848        self.browser.getControl("Create document").click()
    849         self.assertTrue('Generic Document created.' in self.browser.contents)
     849        self.assertTrue('Sample Document created.' in self.browser.contents)
    850850        document = self.customer['documents']['d102']
    851851
     
    866866        # Costumer can upload a document.
    867867        self.browser.getLink("Edit").click()
    868         ctrl = self.browser.getControl(name='genericuploadedit')
     868        ctrl = self.browser.getControl(name='scaneditupload')
    869869        file_obj = open(SAMPLE_IMAGE, 'rb')
    870870        file_ctrl = ctrl.mech_control
    871871        file_ctrl.add_file(file_obj, filename='my_document.jpg')
    872872        self.browser.getControl(
    873             name='upload_genericuploadedit').click()
    874         self.assertTrue(
    875             'href="http://localhost/app/customers/K1000000/documents/d102/generic"'
     873            name='upload_scaneditupload').click()
     874        self.assertTrue(
     875            'href="http://localhost/app/customers/K1000000/documents/d102/scan"'
    876876            in self.browser.contents)
    877877        # Costumer can submit the form. The form is also saved.
     
    890890        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    891891        self.browser.open(self.customer_path + '/documents/d101/manage')
    892         # Create a pseudo image file and select it to be uploaded in form
    893         # as generic document
     892        # Create a pseudo image file and select it to be uploaded
    894893        image = open(SAMPLE_IMAGE, 'rb')
    895         ctrl = self.browser.getControl(name='genericuploadmanage')
     894        ctrl = self.browser.getControl(name='scanmanageupload')
    896895        file_ctrl = ctrl.mech_control
    897         file_ctrl.add_file(image, filename='my_generic_document.jpg')
     896        file_ctrl.add_file(image, filename='my_scan.jpg')
    898897        # The Save action does not upload files
    899898        self.browser.getControl("Save").click() # submit form
    900899        self.assertFalse(
    901             'href="http://localhost/app/customers/K1000000/documents/d101/generic"'
     900            'href="http://localhost/app/customers/K1000000/documents/d101/scan"'
    902901            in self.browser.contents)
    903902        # ... but the correct upload submit button does
    904903        image = open(SAMPLE_IMAGE)
    905         ctrl = self.browser.getControl(name='genericuploadmanage')
     904        ctrl = self.browser.getControl(name='scanmanageupload')
    906905        file_ctrl = ctrl.mech_control
    907         file_ctrl.add_file(image, filename='my_generic_document.jpg')
    908         self.browser.getControl(
    909             name='upload_genericuploadmanage').click()
    910         self.assertTrue(
    911             'href="http://localhost/app/customers/K1000000/documents/d101/generic"'
     906        file_ctrl.add_file(image, filename='my_scan.jpg')
     907        self.browser.getControl(
     908            name='upload_scanmanageupload').click()
     909        self.assertTrue(
     910            'href="http://localhost/app/customers/K1000000/documents/d101/scan"'
    912911            in self.browser.contents)
    913912        # Browsing the link shows a real image
    914         self.browser.open('generic')
     913        self.browser.open('scan')
    915914        self.assertEqual(
    916915            self.browser.headers['content-type'], 'image/jpeg')
     
    919918        self.browser.open(self.customer_path + '/documents/d101/manage')
    920919        self.assertFalse(
    921             'upload_genericuploadmanage' in self.browser.contents)
     920            'upload_scanmanageupload' in self.browser.contents)
    922921        # File must be deleted first
    923         self.browser.getControl(name='delete_genericuploadmanage').click()
    924         self.assertTrue(
    925             'generic deleted' in self.browser.contents)
     922        self.browser.getControl(name='delete_scanmanageupload').click()
     923        self.assertTrue(
     924            'scan deleted' in self.browser.contents)
    926925        # Uploading a file which is bigger than 150k will raise an error
    927926        big_image = StringIO(open(SAMPLE_IMAGE, 'rb').read() * 75)
    928         ctrl = self.browser.getControl(name='genericuploadmanage')
     927        ctrl = self.browser.getControl(name='scanmanageupload')
    929928        file_ctrl = ctrl.mech_control
    930         file_ctrl.add_file(big_image, filename='my_generic_document.jpg')
    931         self.browser.getControl(
    932             name='upload_genericuploadmanage').click()
     929        file_ctrl.add_file(big_image, filename='my_scan.jpg')
     930        self.browser.getControl(
     931            name='upload_scanmanageupload').click()
    933932        self.assertTrue(
    934933            'Uploaded file is too big' in self.browser.contents)
    935934        # we do not rely on filename extensions given by uploaders
    936935        image = open(SAMPLE_IMAGE, 'rb') # a jpg-file
    937         ctrl = self.browser.getControl(name='genericuploadmanage')
     936        ctrl = self.browser.getControl(name='scanmanageupload')
    938937        file_ctrl = ctrl.mech_control
    939938        # tell uploaded file is bmp
    940         file_ctrl.add_file(image, filename='my_generic_document.bmp')
    941         self.browser.getControl(
    942             name='upload_genericuploadmanage').click()
     939        file_ctrl.add_file(image, filename='my_scan.bmp')
     940        self.browser.getControl(
     941            name='upload_scanmanageupload').click()
    943942        self.assertTrue(
    944943            # jpg file was recognized
    945             'File generic.jpg uploaded.' in self.browser.contents)
     944            'File scan.jpg uploaded.' in self.browser.contents)
    946945        # Delete file again
    947         self.browser.getControl(name='delete_genericuploadmanage').click()
    948         self.assertTrue(
    949             'generic deleted' in self.browser.contents)
     946        self.browser.getControl(name='delete_scanmanageupload').click()
     947        self.assertTrue(
     948            'scan deleted' in self.browser.contents)
    950949        # File names must meet several conditions
    951950        bmp_image = open(SAMPLE_IMAGE_BMP, 'rb')
    952         ctrl = self.browser.getControl(name='genericuploadmanage')
     951        ctrl = self.browser.getControl(name='scanmanageupload')
    953952        file_ctrl = ctrl.mech_control
    954         file_ctrl.add_file(bmp_image, filename='my_generic_document.bmp')
    955         self.browser.getControl(
    956             name='upload_genericuploadmanage').click()
     953        file_ctrl.add_file(bmp_image, filename='my_scan.bmp')
     954        self.browser.getControl(
     955            name='upload_scanmanageupload').click()
    957956        self.assertTrue('Only the following extensions are allowed'
    958957            in self.browser.contents)
  • main/waeup.ikoba/trunk/src/waeup/ikoba/utils/utils.py

    r11983 r12038  
    115115        )
    116116
     117    # Should be overridden in custom packages
    117118    DOCUMENT_TYPES = {
    118         'generic': 'Generic Document',
     119        'sample': 'Sample Document',
    119120        }
    120121
Note: See TracChangeset for help on using the changeset viewer.