Ignore:
Timestamp:
27 Jan 2015, 11:42:21 (10 years ago)
Author:
Henrik Bettermann
Message:

Fire transition when customer logs in for the first time.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba/customers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser.py

    r12500 r12517  
    3838    IContactForm, IObjectHistory, IIkobaObject, IIkobaUtils,
    3939    IPasswordValidator, IUserAccount,
    40     VERIFIED, REJECTED, EXPIRED, REQUESTED, APPROVED)
     40    VERIFIED, REJECTED, EXPIRED, CREATED, REQUESTED, APPROVED)
    4141from waeup.ikoba.browser.layout import (
    4242    IkobaPage, IkobaEditFormPage, IkobaAddFormPage, IkobaDisplayFormPage,
     
    326326        return True
    327327
     328    def update(self):
     329        # Fire transition if customer logs in for the first time
     330        usertype = getattr(self.request.principal, 'user_type', None)
     331        if usertype == 'customer' and \
     332            IWorkflowState(self.context).getState() == CREATED:
     333            IWorkflowInfo(self.context).fireTransition('start')
     334        return
     335
    328336
    329337class ContactCustomerForm(ContactAdminForm):
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py

    r12500 r12517  
    500500        prmglobal.assignRoleToPrincipal('waeup.CustomerImpersonator', 'mrofficer')
    501501        prmglobal.assignRoleToPrincipal('waeup.CustomersManager', 'mrofficer')
     502        self.assertEqual(self.customer.state, 'created')
    502503        # Login as customer impersonator
    503504        self.browser.open(self.login_path)
     
    513514        self.assertMatches(
    514515            '...You successfully logged in as...', self.browser.contents)
     516        # Status has changed
     517        self.assertEqual(self.customer.state, 'started')
    515518        # We are logged in as customer and can see the 'My Data' tab
    516519        self.assertMatches(
     
    549552    def test_customer_change_password(self):
    550553        # Customers can change the password
     554        self.assertEqual(self.customer.state, 'created')
    551555        self.customer.personal_updated = datetime.utcnow()
    552556        self.browser.open(self.login_path)
     
    556560        self.assertEqual(self.browser.url, self.customer_path)
    557561        self.assertTrue('You logged in' in self.browser.contents)
     562        # Status has changed
     563        self.assertEqual(self.customer.state, 'started')
    558564        # Change password
    559565        self.browser.getLink("Change password").click()
     
    592598    def test_customer_upload_passport(self):
    593599        # Customer cant login if their password is not set
    594         IWorkflowInfo(self.customer).fireTransition('start')
    595600        self.browser.open(self.login_path)
    596601        self.browser.getControl(name="form.login").value = self.customer_id
Note: See TracChangeset for help on using the changeset viewer.