Ignore:
Timestamp:
31 Dec 2014, 17:12:41 (10 years ago)
Author:
Henrik Bettermann
Message:

Adjust and fix components.

Add file viewlets for SkeletonCustomerDocument?.

Location:
main/ikobacustom.skeleton/trunk/src/ikobacustom/skeleton/customers
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • main/ikobacustom.skeleton/trunk/src/ikobacustom/skeleton/customers/documents.py

    r12286 r12355  
    3434
    3535    grok.implements(ISkeletonCustomerDocument, ICustomerNavigation)
     36    grok.provides(ISkeletonCustomerDocument)
    3637
    3738    # Ikoba can store any number of files per Document object.
  • main/ikobacustom.skeleton/trunk/src/ikobacustom/skeleton/customers/tests/test_browser.py

    r12354 r12355  
    2929from hurry.workflow.interfaces import IWorkflowState
    3030from waeup.ikoba.customers.tests.test_batching import CustomerImportExportSetup
     31from waeup.ikoba.customers.tests.test_browser import CustomersFullSetup
    3132from ikobacustom.skeleton.customers.export import (
    3233    SkeletonCustomerExporter,
     
    3940from ikobacustom.skeleton.testing import FunctionalLayer
    4041
     42SAMPLE_IMAGE = os.path.join(os.path.dirname(__file__), 'test_image.jpg')
     43SAMPLE_IMAGE_BMP = os.path.join(os.path.dirname(__file__), 'test_image.bmp')
     44SAMPLE_PDF = os.path.join(os.path.dirname(__file__), 'test_pdf.pdf')
    4145
    4246class CustomerImportExportTest(CustomerImportExportSetup):
     
    202206        self.assertEqual(num_fail,0)
    203207        return
     208
     209class DocumentUITests(CustomersFullSetup):
     210    # Tests for customer document related views and pages
     211
     212    layer = FunctionalLayer
     213
     214    def test_manage_upload_pdf_file(self):
     215        # Managers can upload a file via the DocumentManageFormPage
     216        # The image is stored even if form has errors
     217        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     218        self.browser.open(self.customer_path + '/documents')
     219        self.browser.getControl("Add document").click()
     220        self.browser.getControl(name="doctype").value = ['SkeletonCustomerDocument']
     221        self.browser.getControl(name="form.title").value = 'My Skeleton Document'
     222        self.browser.getControl("Add document").click()
     223        docid = [i for i in self.customer['documents'].keys() if len(i) > 10][0]
     224        self.browser.open(self.documents_path + '/%s/manage' % docid)
     225        # Create a pseudo image file and select it to be uploaded
     226        image = open(SAMPLE_IMAGE, 'rb')
     227        ctrl = self.browser.getControl(name='pdfscanmanageupload')
     228        file_ctrl = ctrl.mech_control
     229        file_ctrl.add_file(image, filename='my_sample_scan.jpg')
     230        self.browser.getControl(
     231            name='upload_pdfscanmanageupload').click()
     232        self.assertTrue(
     233            'pdf file extension expected' in self.browser.contents)
     234        ctrl = self.browser.getControl(name='pdfscanmanageupload')
     235        file_ctrl = ctrl.mech_control
     236        file_ctrl.add_file(image, filename='my_sample_scan.pdf')
     237        self.browser.getControl(
     238            name='upload_pdfscanmanageupload').click()
     239        self.assertTrue(
     240            'Could not determine file type' in self.browser.contents)
     241        pdf = open(SAMPLE_PDF, 'rb')
     242        ctrl = self.browser.getControl(name='pdfscanmanageupload')
     243        file_ctrl = ctrl.mech_control
     244        file_ctrl.add_file(pdf, filename='my_sample_scan.pdf')
     245        self.browser.getControl(
     246            name='upload_pdfscanmanageupload').click()
     247        self.assertTrue(
     248            'href="http://localhost/app/customers/K1000000/documents/%s/sample.pdf">PDF File</a>'
     249            % docid in self.browser.contents)
     250        # Browsing the link shows a real pdf
     251        self.browser.open('sample.pdf')
     252        self.assertEqual(
     253            self.browser.headers['content-type'], 'application/pdf')
  • main/ikobacustom.skeleton/trunk/src/ikobacustom/skeleton/customers/utils.py

    r12286 r12355  
    1919"""
    2020
     21from copy import deepcopy
    2122from waeup.ikoba.customers.utils import CustomersUtils
    2223from ikobacustom.skeleton.interfaces import MessageFactory as _
     
    3132        'CustomerPDFDocument': _('PDF Document'),
    3233
    33         'SkeletonSampleDocument': _('Skeleton Document'),
     34        'SkeletonCustomerDocument': _('Skeleton Document'),
    3435        }
    3536
     
    4041        }
    4142
    42     SELECTABLE_DOCTYPES_DICT = DOCTYPES_DICT
     43    SELECTABLE_DOCTYPES_DICT = deepcopy(DOCTYPES_DICT)
    4344
    44     SELECTABLE_CONTYPES_DICT = CONTYPES_DICT
     45    SELECTABLE_CONTYPES_DICT = deepcopy(CONTYPES_DICT)
Note: See TracChangeset for help on using the changeset viewer.