Ignore:
Timestamp:
14 Nov 2014, 22:32:42 (10 years ago)
Author:
Henrik Bettermann
Message:

Add components for customer management. Some tests are still missing.

Location:
main/waeup.kofa/branches/henrik-regista/src/waeup/ikoba
Files:
20 added
6 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/branches/henrik-regista/src/waeup/ikoba/browser/interfaces.py

    r11954 r11958  
    184184        constraint=validate_email,
    185185        )
     186
     187class ICustomerNavigationBase(IIkobaObject):
     188    """Objects that provide customer navigation should
     189       implement this interface.
     190    """
     191    customer = Attribute('''Some customer object that has a '''
     192                        ''' `display_fullname` attribute.''')
  • main/waeup.kofa/branches/henrik-regista/src/waeup/ikoba/browser/layout.py

    r11954 r11958  
    3636from waeup.ikoba.utils.helpers import to_timezone
    3737from waeup.ikoba.authentication import get_principal_role_manager
     38from waeup.ikoba.browser.interfaces import ICustomerNavigationBase
    3839
    3940grok.templatedir('templates')
     
    258259        return self.request.principal.user_type == 'customer'
    259260
     261    def getCustomerName(self):
     262        """Return the customer name.
     263        """
     264        if ICustomerNavigationBase.providedBy(self.context):
     265            return self.context.customer.display_fullname
     266
    260267    def formatDatetime(self,datetimeobj):
    261268        if isinstance(datetimeobj, datetime):
  • main/waeup.kofa/branches/henrik-regista/src/waeup/ikoba/customers/interfaces.py

    r11956 r11958  
    2222from zc.sourcefactory.contextual import BasicContextualSourceFactory
    2323from waeup.ikoba.interfaces import MessageFactory as _
     24from waeup.ikoba.interfaces import (
     25    IIkobaObject, application_sessions_vocab, validate_email, ICSVExporter)
    2426from waeup.ikoba.schema import TextLineChoice, FormattedDate, PhoneNumber
    25 from waeup.ikoba.interfaces import IIkobaObject
     27from waeup.ikoba.browser.interfaces import ICustomerNavigationBase
     28
     29from waeup.ikoba.customers.vocabularies import (
     30    contextual_reg_num_source, GenderSource, nats_vocab)
    2631
    2732class ICustomersUtils(Interface):
     
    7176    unique_customer_id = Attribute("""A unique customer id.""")
    7277
     78
     79class ICustomerNavigation(ICustomerNavigationBase):
     80    """Interface needed for custom navigation, logging, etc.
     81
     82    """
     83    customer = Attribute('Customer object of context.')
     84
     85    def writeLogMessage(view, message):
     86        """Write a view specific log message into custom.log.
     87
     88        """
     89
    7390class ICustomer(IIkobaObject):
    7491    """Representation of a customer.
     
    7693    """
    7794
     95    history = Attribute('Object history, a list of messages')
     96    state = Attribute('Returns the registration state of a customer')
     97    password = Attribute('Encrypted password of a customer')
     98    temp_password = Attribute(
     99        'Dictionary with user name, timestamp and encrypted password')
     100    fullname = Attribute('All name parts separated by hyphens')
     101    display_fullname = Attribute('The fullname of an applicant')
     102
     103    suspended = schema.Bool(
     104        title = _(u'Account suspended'),
     105        default = False,
     106        required = False,
     107        )
     108
     109    suspended_comment = schema.Text(
     110        title = _(u"Reasons for Deactivation"),
     111        required = False,
     112        description = _(
     113            u'This message will be shown if and only if deactivated '
     114            'customers try to login.'),
     115        )
     116
     117    customer_id = schema.TextLine(
     118        title = _(u'Student Id'),
     119        required = False,
     120        )
     121
     122    firstname = schema.TextLine(
     123        title = _(u'First Name'),
     124        required = True,
     125        )
     126
     127    middlename = schema.TextLine(
     128        title = _(u'Middle Name'),
     129        required = False,
     130        )
     131
     132    lastname = schema.TextLine(
     133        title = _(u'Last Name (Surname)'),
     134        required = True,
     135        )
     136
     137    sex = schema.Choice(
     138        title = _(u'Sex'),
     139        source = GenderSource(),
     140        required = True,
     141        )
     142
     143    reg_number = TextLineChoice(
     144        title = _(u'Registration Number'),
     145        required = True,
     146        readonly = False,
     147        source = contextual_reg_num_source,
     148        )
     149
     150    email = schema.ASCIILine(
     151        title = _(u'Email'),
     152        required = False,
     153        constraint=validate_email,
     154        )
     155    phone = PhoneNumber(
     156        title = _(u'Phone'),
     157        description = u'',
     158        required = False,
     159        )
     160
     161    def setTempPassword(user, password):
     162        """Set a temporary password (LDAP-compatible) SSHA encoded for
     163        officers.
     164
     165        """
     166
     167    def getTempPassword():
     168        """Check if a temporary password has been set and if it
     169        is not expired.
     170
     171        Return the temporary password if valid,
     172        None otherwise. Unset the temporary password if expired.
     173        """
     174
     175class ICustomerUpdateByRegNo(ICustomer):
     176    """Representation of a customer. Skip regular reg_number validation.
     177
     178    """
     179    reg_number = schema.TextLine(
     180        title = _(u'Registration Number'),
     181        required = False,
     182        )
     183
     184class ICSVCustomerExporter(ICSVExporter):
     185    """A regular ICSVExporter that additionally supports exporting
     186      data from a given customer object.
     187    """
     188    def get_filtered(site, **kw):
     189        """Get a filtered set of customer.
     190        """
     191
     192    def export_student(student, filepath=None):
     193        """Export data for a given customer.
     194        """
     195
     196    def export_filtered(site, filepath=None, **kw):
     197        """Export filtered set of customers.
     198        """
     199
  • main/waeup.kofa/branches/henrik-regista/src/waeup/ikoba/interfaces.py

    r11954 r11958  
    101101    (_('courses validated'), VALIDATED),
    102102    (_('returning'), RETURNING),
    103     (_('graduated'), GRADUATED),
    104     (_('transcript requested'), TRANSCRIPT),
    105103    )
    106104
  • main/waeup.kofa/branches/henrik-regista/src/waeup/ikoba/permissions.py

    r11949 r11958  
    156156                     'waeup.manageReports',
    157157                     'waeup.manageJobs',
     158                     'waeup.viewCustomer', 'waeup.viewCustomers',
     159                     'waeup.manageCustomer', 'waeup.viewCustomersContainer',
     160                     'waeup.payCustomer', 'waeup.uploadCustomerFile',
     161                     'waeup.viewCustomersTab'
    158162                     )
    159163
     
    177181                     'waeup.manageReports',
    178182                     #'waeup.manageJobs',
     183                     'waeup.viewCustomer', 'waeup.viewCustomers',
     184                     'waeup.manageCustomer', 'waeup.viewCustomersContainer',
     185                     'waeup.payCustomer', 'waeup.uploadCustomerFile',
     186                     'waeup.viewCustomersTab'
    179187                     )
    180188
  • main/waeup.kofa/branches/henrik-regista/src/waeup/ikoba/permissions.txt

    r11949 r11958  
    2929
    3030    >>> sorted(list(get_all_roles()))
    31     [(u'waeup.DataCenterManager', <waeup.ikoba.permissions.DataCenterManager object at 0x...]
     31    [(u'waeup.Customer', <waeup.ikoba.customers.permissions.CustomerRole object at 0x...]
    3232
    3333:func:`get_waeup_roles`
     
    3939    >>> from waeup.ikoba.permissions import get_waeup_roles
    4040    >>> len(list(get_waeup_roles()))
    41     9
     41    13
    4242
    4343    >>> len(list(get_waeup_roles(also_local=True)))
    44     10
     44    15
    4545
    4646
     
    5353    >>> from waeup.ikoba.permissions import get_waeup_role_names
    5454    >>> list(get_waeup_role_names())
    55     [u'waeup.DataCenterManager',
     55    [u'waeup.Customer',
     56    u'waeup.CustomerImpersonator',
     57    u'waeup.CustomersManager',
     58    u'waeup.CustomersOfficer',
     59    u'waeup.DataCenterManager',
    5660    u'waeup.ExportManager',
    5761    u'waeup.ImportManager',
Note: See TracChangeset for help on using the changeset viewer.