Ignore:
Timestamp:
22 Oct 2012, 06:07:58 (12 years ago)
Author:
Henrik Bettermann
Message:

Define dataNotComplete in Uniben package.

Location:
main/waeup.uniben/trunk/src/waeup/uniben/students
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.uniben/trunk/src/waeup/uniben/students/browser.py

    r9281 r9380  
    1919from zope.i18n import translate
    2020from zope.schema.interfaces import ConstraintNotSatisfied
     21from zope.component import getUtility
    2122from hurry.workflow.interfaces import IWorkflowInfo
    22 from waeup.kofa.interfaces import REQUESTED
     23from waeup.kofa.interfaces import REQUESTED, IExtFileStore
    2324from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
    2425from waeup.kofa.browser.layout import KofaEditFormPage
     
    3435    NigeriaOnlinePaymentDisplayFormPage,
    3536    NigeriaStudentBaseManageFormPage,
     37    NigeriaStudentClearanceEditFormPage,
    3638    NigeriaOnlinePaymentAddFormPage,
    3739    NigeriaExportPDFPaymentSlipPage,
     
    7375        'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
    7476
     77class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage):
     78    """ View to edit student clearance data by student
     79    """
     80
     81    def dataNotComplete(self):
     82        store = getUtility(IExtFileStore)
     83        if not store.getFileByContext(self.context, attr=u'birth_certificate.jpg'):
     84            return _('No birth certificate uploaded.')
     85        if not store.getFileByContext(self.context, attr=u'ref_let.jpg'):
     86            return _('No guarantor/referee letter uploaded.')
     87        if not store.getFileByContext(self.context, attr=u'acc_let.jpg'):
     88            return _('No acceptance letter uploaded.')
     89        if not store.getFileByContext(self.context, attr=u'fst_sit_scan.jpg'):
     90            return _('No first sitting result uploaded.')
     91        if not store.getFileByContext(self.context, attr=u'scd_sit_scan.jpg'):
     92            return _('No second sitting result uploaded.')
     93        if not store.getFileByContext(self.context, attr=u'secr_cults.jpg'):
     94            return _('No affidavit of non-menbership of secret cults uploaded.')
     95        return False
     96
    7597class CustomOnlinePaymentAddFormPage(NigeriaOnlinePaymentAddFormPage):
    7698    """ Page to add an online payment ticket
  • main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py

    r9346 r9380  
    116116                           self.browser.contents)
    117117
     118    def test_student_access(self):
     119        # Students can edit clearance data
     120        IWorkflowState(self.student).setState('clearance started')
     121        self.student.clearance_locked = False
     122        self.student.nationality = u'NG'
     123        file_store = getUtility(IExtFileStore)
     124        self.browser.open(self.login_path)
     125        self.browser.getControl(name="form.login").value = self.student_id
     126        self.browser.getControl(name="form.password").value = 'spwd'
     127        self.browser.getControl("Login").click()
     128        self.browser.open(self.edit_clearance_path)
     129
     130        # Clearance can only be requested if all required documents
     131        # have been uploaded.
     132        self.browser.getControl("Save and request clearance").click()
     133        self.assertTrue('No birth certificate uploaded'
     134            in self.browser.contents)
     135        birth_certificate = 'My birth certificate'
     136        file_id = IFileStoreNameChooser(self.student).chooseName(
     137            attr="birth_certificate.jpg")
     138        file_store.createFile(file_id, StringIO(birth_certificate))
     139        self.browser.open(self.edit_clearance_path)
     140        self.browser.getControl("Save and request clearance").click()
     141
     142        self.assertTrue('No guarantor/referee letter uploaded'
     143            in self.browser.contents)
     144        ref_let = 'My ref let'
     145        file_id = IFileStoreNameChooser(self.student).chooseName(
     146            attr="ref_let.jpg")
     147        file_store.createFile(file_id, StringIO(ref_let))
     148        self.browser.open(self.edit_clearance_path)
     149        self.browser.getControl("Save and request clearance").click()
     150
     151        self.assertTrue('No acceptance letter uploaded'
     152            in self.browser.contents)
     153        acc_let = 'My acc let'
     154        file_id = IFileStoreNameChooser(self.student).chooseName(
     155            attr="acc_let.jpg")
     156        file_store.createFile(file_id, StringIO(acc_let))
     157        self.browser.open(self.edit_clearance_path)
     158        self.browser.getControl("Save and request clearance").click()
     159
     160        self.assertTrue('No first sitting result uploaded'
     161            in self.browser.contents)
     162        fst_sit_scan = 'My first sitting result'
     163        file_id = IFileStoreNameChooser(self.student).chooseName(
     164            attr="fst_sit_scan.jpg")
     165        file_store.createFile(file_id, StringIO(fst_sit_scan))
     166        self.browser.open(self.edit_clearance_path)
     167        self.browser.getControl("Save and request clearance").click()
     168
     169        self.assertTrue('No second sitting result uploaded'
     170            in self.browser.contents)
     171        scd_sit_scan = 'My second sitting result'
     172        file_id = IFileStoreNameChooser(self.student).chooseName(
     173            attr="scd_sit_scan.jpg")
     174        file_store.createFile(file_id, StringIO(scd_sit_scan))
     175        self.browser.open(self.edit_clearance_path)
     176        self.browser.getControl("Save and request clearance").click()
     177
     178        self.assertTrue('No affidavit of non-menbership of secret cults uploaded'
     179            in self.browser.contents)
     180        secr_cults = 'My non-membership scan'
     181        file_id = IFileStoreNameChooser(self.student).chooseName(
     182            attr="secr_cults.jpg")
     183        file_store.createFile(file_id, StringIO(secr_cults))
     184        self.browser.open(self.edit_clearance_path)
     185        self.browser.getControl("Save and request clearance").click()
     186
     187        self.assertTrue('Clearance has been requested'
     188            in self.browser.contents)
     189
    118190    def test_manage_payments(self):
    119191        # Add missing configuration data
Note: See TracChangeset for help on using the changeset viewer.