Changeset 12349 for main


Ignore:
Timestamp:
31 Dec 2014, 11:08:41 (10 years ago)
Author:
Henrik Bettermann
Message:

Use CustomerBaseEditFormPage? for editing all base data and requesting customer registration.

File:
1 edited

Legend:

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

    r12348 r12349  
    3838    IContactForm, IObjectHistory, IIkobaObject, IIkobaUtils,
    3939    IPasswordValidator, IUserAccount,
    40     VERIFIED, REJECTED, EXPIRED, APPROVED)
     40    VERIFIED, REJECTED, EXPIRED, REQUESTED, APPROVED)
    4141from waeup.ikoba.browser.layout import (
    4242    IkobaPage, IkobaEditFormPage, IkobaAddFormPage, IkobaDisplayFormPage,
     
    678678    grok.name('edit_base')
    679679    grok.require('waeup.handleCustomer')
    680     form_fields = grok.AutoFields(ICustomer).select(
    681         'email', 'phone')
    682680    label = _('Edit base data')
    683681    pnav = 4
     682
     683    @property
     684    def form_fields(self):
     685        if self.context.state in (REQUESTED, APPROVED):
     686            return grok.AutoFields(ICustomer).select('email', 'phone')
     687        return grok.AutoFields(ICustomer).omit(
     688            'suspended', 'suspended_comment', 'reg_number', 'customer_id')
    684689
    685690    @action(_('Save'), style='primary')
    686691    def save(self, **data):
    687692        msave(self, **data)
     693        return
     694
     695    def is_editable(self, action):
     696        if self.context.state in (REQUESTED, APPROVED):
     697            return False
     698        return True
     699
     700    @action(_('Request registration now'), warning=WARNING, condition=is_editable)
     701    def finalsubmit(self, **data):
     702        msave(self, **data)
     703        IWorkflowInfo(self.context).fireTransition('request')
     704        self.flash(_('Registration form has been submitted.'))
     705        self.redirect(self.url(self.context))
    688706        return
    689707
Note: See TracChangeset for help on using the changeset viewer.