Changeset 11971


Ignore:
Timestamp:
16 Nov 2014, 17:50:55 (10 years ago)
Author:
Henrik Bettermann
Message:

Add file upload and display components.

Adjust workflow.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba
Files:
7 added
6 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/app.txt

    r11954 r11971  
    11:mod:`waeup.ikoba.app` -- central components for Ikoba
    2 ****************************************************
     2******************************************************
    33
    44.. :doctest:
     
    2525
    2626Creating `Company` instances
    27 ===============================
     27============================
    2828
    2929As :class:`Company` instances make use of the Zope Component
     
    6969
    7070Ikoba plugins
    71 ============
     71=============
    7272
    7373waeup.ikoba provides an API to 'plugin' components. Things that should
  • main/waeup.ikoba/trunk/src/waeup/ikoba/browser/templates/default_waeup_edit_form.pt

    r11947 r11971  
    55    <tbody>
    66      <tal:widgets content="structure provider:widgets" />
     7      <tal:files content="structure provider:files" />
    78    </tbody>
    89  </table>
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser.py

    r11967 r11971  
    3333from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
    3434from waeup.ikoba.interfaces import MessageFactory as _
    35 from waeup.ikoba.interfaces import IContactForm, IObjectHistory, IIkobaObject
     35from waeup.ikoba.interfaces import (
     36    IContactForm, IObjectHistory, IIkobaObject, IIkobaUtils,
     37    IPasswordValidator, IUserAccount)
    3638from waeup.ikoba.browser.layout import (
    3739    IkobaPage, IkobaEditFormPage, IkobaAddFormPage, IkobaDisplayFormPage,
     
    3941from waeup.ikoba.browser.pages import ContactAdminForm
    4042from waeup.ikoba.browser.breadcrumbs import Breadcrumb
     43from waeup.ikoba.browser.interfaces import ICaptchaManager
    4144from waeup.ikoba.utils.helpers import get_current_principal, to_timezone, now
    4245from waeup.ikoba.customers.interfaces import (
     
    485488            return
    486489
    487         kofa_utils = getUtility(IKofaUtils)
     490        kofa_utils = getUtility(IIkobaUtils)
    488491        password = kofa_utils.genPassword()
    489492        mandate = PasswordMandate()
     
    523526        self.customer_id = customer_id
    524527        return
     528
     529class CustomerFilesUploadPage(IkobaPage):
     530    """ View to upload files by customer
     531    """
     532    grok.context(ICustomer)
     533    grok.name('change_portrait')
     534    grok.require('waeup.uploadCustomerFile')
     535    grok.template('filesuploadpage')
     536    label = _('Upload files')
     537    pnav = 4
     538
     539    def update(self):
     540        PWCHANGE_STATES = getUtility(ICustomersUtils).PWCHANGE_STATES
     541        if self.context.customer.state not in PWCHANGE_STATES:
     542            emit_lock_message(self)
     543            return
     544        super(CustomerFilesUploadPage, self).update()
     545        return
     546
     547# Pages for customers only
     548
     549class CustomerBaseEditFormPage(IkobaEditFormPage):
     550    """ View to edit customer base data
     551    """
     552    grok.context(ICustomer)
     553    grok.name('edit_base')
     554    grok.require('waeup.handleCustomer')
     555    form_fields = grok.AutoFields(ICustomer).select(
     556        'email', 'phone')
     557    label = _('Edit base data')
     558    pnav = 4
     559
     560    @action(_('Save'), style='primary')
     561    def save(self, **data):
     562        msave(self, **data)
     563        return
     564
     565class CustomerChangePasswordPage(IkobaEditFormPage):
     566    """ View to edit customer passords
     567    """
     568    grok.context(ICustomer)
     569    grok.name('change_password')
     570    grok.require('waeup.handleCustomer')
     571    grok.template('change_password')
     572    label = _('Change password')
     573    pnav = 4
     574
     575    @action(_('Save'), style='primary')
     576    def save(self, **data):
     577        form = self.request.form
     578        password = form.get('change_password', None)
     579        password_ctl = form.get('change_password_repeat', None)
     580        if password:
     581            validator = getUtility(IPasswordValidator)
     582            errors = validator.validate_password(password, password_ctl)
     583            if not errors:
     584                IUserAccount(self.context).setPassword(password)
     585                self.context.writeLogMessage(self, 'saved: password')
     586                self.flash(_('Password changed.'))
     587            else:
     588                self.flash( ' '.join(errors), type="warning")
     589        return
     590
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser_templates/basepage.pt

    r11967 r11971  
    1919      </td>
    2020    </tr>
     21    <tal:files content="structure provider:files" />
    2122  </tbody>
    2223  <tfoot>
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/utils.py

    r11956 r11971  
    1919"""
    2020import grok
     21from waeup.ikoba.interfaces import STARTED
    2122from waeup.ikoba.customers.interfaces import ICustomersUtils
    2223
     
    3435    #: start with this string. The default is 'K'.
    3536    CUSTOMER_ID_PREFIX = u'K'
     37
     38    PWCHANGE_STATES = (STARTED,)
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/workflow.py

    r11967 r11971  
    6666
    6767    Transition(
     68        transition_id = 'reject',
     69        title = _('Reject customer'),
     70        msg = _('Customer registration rejected'),
     71        source = REQUESTED,
     72        destination = STARTED),
     73
     74    Transition(
    6875        transition_id = 'reset1',
    6976        title = _('Reset customer'),
Note: See TracChangeset for help on using the changeset viewer.