Changeset 12534 for main


Ignore:
Timestamp:
1 Feb 2015, 07:11:07 (10 years ago)
Author:
Henrik Bettermann
Message:

PCN requires a birth certificate upload.

Location:
main/ikobacustom.pcn/trunk/src/ikobacustom/pcn/customers
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/ikobacustom.pcn/trunk/src/ikobacustom/pcn/customers/browser.py

    r12529 r12534  
    1818
    1919from zope.component import getUtility
    20 from waeup.ikoba.interfaces import IIkobaUtils
     20from waeup.ikoba.interfaces import IIkobaUtils, IExtFileStore
    2121from waeup.ikoba.customers.browser import (
    2222    PDFContractSlipPage, CustomerBaseEditFormPage)
     
    3838
    3939    def dataNotComplete(self):
    40         """To be implemented in the customization package.
    41         """
    42         return False
     40        store = getUtility(IExtFileStore)
     41        error = ''
     42        if not store.getFileByContext(self.context, attr=u'birth_certificate.pdf'):
     43            error += _('Birth certificate is missing. ')
     44        if not store.getFileByContext(self.context, attr=u'passport.jpg'):
     45            error += _('Passport picture is missing.')
     46        if error:
     47            return error
     48        return
  • main/ikobacustom.pcn/trunk/src/ikobacustom/pcn/customers/fileviewlets.py

    r12460 r12534  
    1919import grok
    2020from waeup.ikoba.interfaces import MessageFactory as _
    21 
     21from waeup.ikoba.customers.interfaces import ICustomer
    2222from waeup.ikoba.browser.fileviewlets import (
    2323    FileDisplay, FileUpload, Image)
     
    2727
    2828from waeup.ikoba.customers.browser import (
     29    CustomerBaseDisplayFormPage,
     30    CustomerBaseManageFormPage,
     31    CustomerFilesUploadPage,
    2932    DocumentDisplayFormPage,
    3033    DocumentManageFormPage,
    3134    DocumentEditFormPage,
    32     PDFDocumentSlipPage,)
     35    PDFDocumentSlipPage)
    3336
    3437grok.templatedir('browser_templates')
     38
     39# File viewlets for customer base page
     40
     41class BirthCertificateDisplay(FileDisplay):
     42    """Birth certificate display viewlet.
     43    """
     44    grok.order(2)
     45    grok.context(ICustomer)
     46    grok.view(CustomerBaseDisplayFormPage)
     47    grok.require('waeup.viewCustomer')
     48    label = _(u'Birth Certificate')
     49    download_name = u'birth_certificate.pdf'
     50    download_filename = u'birth_certificate.pdf'
     51
     52
     53class BirthCertificateManageUpload(FileUpload):
     54    """Birth Certificate upload viewlet for officers.
     55    """
     56    grok.order(2)
     57    grok.context(ICustomer)
     58    grok.view(CustomerBaseManageFormPage)
     59    grok.require('waeup.manageCustomer')
     60    label = _(u'Birth Certificate (pdf only)')
     61    mus = 1024 * 200
     62    download_name = u'birth_certificate.pdf'
     63    download_filename = u'birth_certificate.pdf'
     64    tab_redirect = '#tab2'
     65
     66
     67class BirthCertificateEditUpload(BirthCertificateManageUpload):
     68    """Birth certificate upload viewlet for customers.
     69    """
     70    grok.view(CustomerFilesUploadPage)
     71    grok.require('waeup.handleCustomer')
     72
     73
     74class BirthCertificate(Image):
     75    """Renders pdf.
     76    """
     77    grok.name('birth_certificate.pdf')
     78    download_name = u'birth_certificate.pdf'
     79    grok.context(ICustomer)
     80    grok.require('waeup.viewCustomer')
     81    download_filename = u'birth_certificate.pdf'
    3582
    3683# File viewlets for customer documents
  • main/ikobacustom.pcn/trunk/src/ikobacustom/pcn/customers/tests/test_browser.py

    r12529 r12534  
    332332        return
    333333
     334
     335class CustomerUITests(CustomersFullSetup):
     336
     337    layer = FunctionalLayer
     338
     339    def setup_customizable_params(self):
     340        self._contract_category = u'ron'
     341        self._document_factory = 'waeup.PCNCustomerPDFDocument'
     342        self._contract_factory = 'waeup.RONContract'
     343        return
     344
     345    def test_customer_edit_upload_upload_and_request(self):
     346        # Customer cant login if their password is not set
     347        self.browser.open(self.login_path)
     348        self.browser.getControl(name="form.login").value = self.customer_id
     349        self.browser.getControl(name="form.password").value = 'cpwd'
     350        self.browser.getControl("Login").click()
     351        self.assertMatches(
     352            '...You logged in...', self.browser.contents)
     353        self.browser.getLink("Edit").click()
     354        self.browser.getControl(name="form.email").value = 'new_email@aa.ng'
     355        self.browser.getControl("Save", index=0).click()
     356        self.assertMatches('...Form has been saved...',
     357                           self.browser.contents)
     358        self.browser.getControl("Save and request registration").click()
     359        self.assertMatches('...Passport picture is missing...',
     360                           self.browser.contents)
     361        self.assertEqual(self.customer.state, 'started')
     362        # Customer must upload a passport picture. We are already on
     363        # the upload page.
     364        ctrl = self.browser.getControl(name='passporteditupload')
     365        file_obj = open(SAMPLE_IMAGE, 'rb')
     366        file_ctrl = ctrl.mech_control
     367        file_ctrl.add_file(file_obj, filename='my_photo.jpg')
     368        self.browser.getControl(
     369            name='upload_passporteditupload').click()
     370        self.assertTrue(
     371            'src="http://localhost/app/customers/K1000000/passport.jpg"'
     372            in self.browser.contents)
     373        self.browser.getControl(name="CANCEL").click()
     374        self.assertEqual(self.browser.url, self.customer_path)
     375        self.browser.getLink("Edit").click()
     376        self.browser.getControl("Save and request registration").click()
     377        self.assertMatches('...Birth certificate is missing...',
     378                           self.browser.contents)
     379        self.assertEqual(self.customer.state, 'started')
     380        ctrl = self.browser.getControl(name='birthcertificateeditupload')
     381        file_obj = open(SAMPLE_PDF, 'rb')
     382        file_ctrl = ctrl.mech_control
     383        file_ctrl.add_file(file_obj, filename='my_bc.pdf')
     384        self.browser.getControl(
     385            name='upload_birthcertificateeditupload').click()
     386        self.assertTrue(
     387            'href="http://localhost/app/customers/K1000000/birth_certificate.pdf"'
     388            in self.browser.contents)
     389        self.browser.getControl(name="CANCEL").click()
     390        self.browser.getLink("Edit").click()
     391        self.browser.getControl("Save and request registration").click()
     392        self.assertMatches('...Registration form has been submitted...',
     393                           self.browser.contents)
     394        self.assertEqual(self.customer.state, 'requested')
     395        # Customer can view history
     396        self.browser.getLink("History").click()
     397        self.assertMatches('...Customer created by system...',
     398            self.browser.contents)
     399
     400
    334401class DocumentUITests(CustomersFullSetup):
    335402    # Tests for customer document related views and pages
     
    388455            'attachment; filename="%s.pdf' % docid[:9])
    389456
     457
    390458class ContractUITests(CustomersFullSetup):
    391459    # Tests for contract related views and pages
Note: See TracChangeset for help on using the changeset viewer.