Ignore:
Timestamp:
19 Nov 2014, 06:42:39 (10 years ago)
Author:
Henrik Bettermann
Message:

Add missing buttons.

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

Legend:

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

    r11985 r11986  
    5050
    5151grok.context(IIkobaObject)
     52
     53
     54# Save function used for save methods in pages
     55def msave(view, **data):
     56    changed_fields = view.applyData(view.context, **data)
     57    # Turn list of lists into single list
     58    if changed_fields:
     59        changed_fields = reduce(lambda x,y: x+y, changed_fields.values())
     60    fields_string = ' + '.join(changed_fields)
     61    view.flash(_('Form has been saved.'))
     62    if fields_string:
     63        view.context.writeLogMessage(view, 'saved: %s' % fields_string)
     64    return
     65
     66
     67def emit_lock_message(view):
     68    """Flash a lock message.
     69    """
     70    view.flash(_('The requested form is locked (read-only).'), type="warning")
     71    view.redirect(view.url(view.context))
     72    return
    5273
    5374
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py

    r11978 r11986  
    555555            '...You logged in...', self.browser.contents)
    556556        # Admitted customer can upload a passport picture
    557         self.browser.open(self.customer_path + '/change_portrait')
     557        self.browser.getLink("Change portrait").click()
    558558        ctrl = self.browser.getControl(name='passportuploadedit')
    559559        file_obj = open(SAMPLE_IMAGE, 'rb')
     
    565565            'src="http://localhost/app/customers/K1000000/passport.jpg"'
    566566            in self.browser.contents)
     567
     568    def test_customer_baseedit(self):
     569        # Customers can change the password
     570        self.customer.personal_updated = datetime.utcnow()
     571        self.browser.open(self.login_path)
     572        self.browser.getControl(name="form.login").value = self.customer_id
     573        self.browser.getControl(name="form.password").value = 'spwd'
     574        self.browser.getControl("Login").click()
     575        self.assertEqual(self.browser.url, self.customer_path)
     576        self.assertTrue('You logged in' in self.browser.contents)
     577        self.browser.getLink("Edit").click()
     578        self.browser.getControl(name="form.email").value = 'new_email@aa.ng'
     579        self.browser.getControl("Save").click()
     580        self.assertMatches('...Form has been saved...',
     581                           self.browser.contents)
     582        # Customer can view history
     583        self.browser.getLink("History").click()
     584        self.assertMatches('...Customer record created by system...',
     585            self.browser.contents)
    567586
    568587    def test_customer_login(self):
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/viewlets.py

    r11985 r11986  
    252252
    253253
     254class CustomerBaseActionButton(ManageActionButton):
     255    grok.order(1)
     256    grok.context(ICustomer)
     257    grok.view(CustomerBaseDisplayFormPage)
     258    grok.require('waeup.handleCustomer')
     259    text = _('Edit')
     260    target = 'edit_base'
     261
    254262class CustomerPasswordActionButton(ManageActionButton):
    255263    grok.order(2)
     
    260268    text = _('Change password')
    261269    target = 'changepassword'
     270
     271class CustomerPassportActionButton(ManageActionButton):
     272    grok.order(3)
     273    grok.context(ICustomer)
     274    grok.view(CustomerBaseDisplayFormPage)
     275    grok.require('waeup.handleCustomer')
     276    icon = 'actionicon_portrait.png'
     277    text = _('Change portrait')
     278    target = 'change_portrait'
Note: See TracChangeset for help on using the changeset viewer.