Changeset 9156


Ignore:
Timestamp:
4 Sep 2012, 11:18:20 (12 years ago)
Author:
Henrik Bettermann
Message:

Customize StartClearancePage?. In Okene the students can just start clearance without entering an activation code.

Location:
main/waeup.fceokene/trunk/src/waeup/fceokene/students
Files:
1 added
2 edited

Legend:

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

    r8913 r9156  
    1818import grok
    1919from zope.i18n import translate
     20from hurry.workflow.interfaces import IWorkflowInfo
     21from waeup.kofa.interfaces import ADMITTED
     22from waeup.kofa.interfaces import MessageFactory as _
    2023from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
     24from waeup.kofa.students.browser import StartClearancePage
    2125from kofacustom.nigeria.students.browser import (
    2226    NigeriaOnlinePaymentDisplayFormPage,
     
    4953    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
    5054    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
     55
     56class CustomStartClearancePage(StartClearancePage):
     57
     58    grok.template('startclearance')
     59
     60    def update(self, SUBMIT=None):
     61        if not self.context.state == ADMITTED:
     62            self.flash(_("Wrong state"))
     63            self.redirect(self.url(self.context))
     64            return
     65        if not self.portrait_uploaded:
     66            self.flash(_("No portrait uploaded."))
     67            self.redirect(self.url(self.context, 'change_portrait'))
     68            return
     69        if not self.all_required_fields_filled:
     70            self.flash(_("Not all required fields filled."))
     71            self.redirect(self.url(self.context, 'edit_base'))
     72            return
     73        if SUBMIT is None:
     74            return
     75        IWorkflowInfo(self.context).fireTransition('start_clearance')
     76        self.flash(_('Clearance process has been started.'))
     77        self.redirect(self.url(self.context,'cedit'))
     78        return
  • main/waeup.fceokene/trunk/src/waeup/fceokene/students/tests/test_browser.py

    r9153 r9156  
    2020import tempfile
    2121from StringIO import StringIO
    22 from hurry.workflow.interfaces import IWorkflowState
     22from hurry.workflow.interfaces import IWorkflowState, IWorkflowInfo
    2323from zope.component.hooks import setSite, clearSite
    2424from zope.component import getUtility, createObject
    2525from zope.interface import verify
    2626from waeup.kofa.app import University
    27 from waeup.kofa.students.tests.test_browser import StudentsFullSetup
     27from waeup.kofa.students.tests.test_browser import (
     28    StudentsFullSetup, SAMPLE_IMAGE)
    2829from waeup.kofa.testing import FunctionalTestCase
    2930from waeup.kofa.interfaces import (
     
    247248        self.assertEqual(error, u'Previous session payment not yet implemented.')
    248249        return
     250
     251    def test_student_start_clearance(self):
     252        self.browser.open(self.login_path)
     253        self.browser.getControl(name="form.login").value = self.student_id
     254        self.browser.getControl(name="form.password").value = 'spwd'
     255        self.browser.getControl("Login").click()
     256
     257        IWorkflowInfo(self.student).fireTransition('admit')
     258        self.browser.open(self.student_path + '/change_portrait')
     259        image = open(SAMPLE_IMAGE, 'rb')
     260        ctrl = self.browser.getControl(name='passportuploadedit')
     261        file_ctrl = ctrl.mech_control
     262        file_ctrl.add_file(image, filename='my_photo.jpg')
     263        self.browser.getControl(
     264            name='upload_passportuploadedit').click()
     265        self.browser.open(self.student_path + '/start_clearance')
     266        # In Okene the students can just start clearance without entering
     267        # an activation code.
     268        self.browser.getControl("Start clearance now").click()
     269        self.assertMatches('...Clearance process has been started...',
     270                           self.browser.contents)
Note: See TracChangeset for help on using the changeset viewer.