Ignore:
Timestamp:
12 Oct 2023, 21:45:55 (11 months ago)
Author:
Henrik Bettermann
Message:

Customize LoginPage? to redirect to request_webservice instead of showing the login page.

Location:
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/browser/pages.py

    r16508 r17611  
    2626    SessionConfigurationManageFormPage,
    2727    ConfigurationContainerManageFormPage,
    28     SourcesOverview)
     28    SourcesOverview, LoginPage)
    2929from waeup.kofa.browser.layout import KofaPage
    3030from kofacustom.nigeria.interfaces import (
     
    3333    ICustomSessionConfigurationAdd)
    3434from kofacustom.nigeria.interfaces import MessageFactory as _
     35
     36class NigeriaLoginPage(LoginPage):
     37    """A login page, available for all objects.
     38    """
     39
     40    def update(self, SUBMIT=None, camefrom=None, login=None, password=None):
     41
     42        # Redirect to camefrom if user is still logged in. Don't show login page.
     43        if camefrom and 'request_webservice' in camefrom and \
     44            self.request.principal.id != 'zope.anybody':
     45            self.redirect(self.application_url() + camefrom)
     46            return
     47
     48        super(NigeriaLoginPage, self).update(SUBMIT, camefrom, login, password)
     49
    3550
    3651class NigeriaSourcesOverview(SourcesOverview):
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/tests/test_browser.py

    r15351 r17611  
    480480            '<h1 class="kofa-content-label">Edit clearance data</h1>'
    481481            in self.browser.contents)
     482
     483    def test_student_redirect_camefrom(self):
     484        payment1 = createObject(u'waeup.StudentOnlinePayment')
     485        payment1.p_id = "p4153206270"
     486        payment1.p_category = 'schoolfee'
     487        payment1.p_item = u'My School Fee'
     488        payment1.p_session = 2015
     489        payment1.p_level = 100
     490        payment1.p_current = True
     491        payment1.amount_auth = 23456.9
     492        payment1.approve()
     493        self.student['payments'][payment1.p_id] = payment1
     494        self.browser.open(self.login_path)
     495        self.browser.getControl(name="form.login").value = self.student_id
     496        self.browser.getControl(name="form.password").value = 'spwd'
     497        self.browser.getControl("Login").click()
     498        self.assertMatches(
     499            '...You logged in...', self.browser.contents)
     500        camefrom = '/students/K1000000/studycourse'
     501        self.browser.open(self.login_path + '?camefrom=%s' % camefrom)
     502        # nothing happens
     503        self.assertEqual(self.browser.url, self.login_path + '?camefrom=%s' % camefrom)
     504        camefrom = '/students/K1000000/payments/%s/request_webservice' % payment1.p_id
     505        # Kofa redirects to request_webservice and then returns to payment ticket index view
     506        self.browser.open(self.login_path + '?camefrom=%s' % camefrom)
     507        self.assertEqual(
     508            self.browser.url,
     509            'http://localhost/app/students/K1000000/payments/p4153206270/@@index')
Note: See TracChangeset for help on using the changeset viewer.