Changeset 12032


Ignore:
Timestamp:
21 Nov 2014, 18:52:43 (10 years ago)
Author:
Henrik Bettermann
Message:

Implement translated_state property correctly so that we can more easily customized customer registration and document verification state names.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba
Files:
8 edited

Legend:

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

    r12005 r12032  
    3636from waeup.ikoba.interfaces import (
    3737    IObjectHistory, IUserAccount, IFileStoreNameChooser, IFileStoreHandler,
    38     IIkobaUtils, registration_states_vocab, IExtFileStore,
     38    IIkobaUtils, IExtFileStore,
    3939    CREATED, REQUESTED, APPROVED)
    4040from waeup.ikoba.customers.export import EXPORTER_NAMES
    4141from waeup.ikoba.customers.interfaces import (
    42     ICustomer, ICustomerNavigation, ICSVCustomerExporter)
     42    ICustomer, ICustomerNavigation, ICSVCustomerExporter,
     43    ICustomersUtils)
    4344from waeup.ikoba.customers.utils import generate_customer_id
    4445from waeup.ikoba.customers.documents import CustomerDocumentsContainer
     
    126127    @property
    127128    def translated_state(self):
    128         state = registration_states_vocab.getTermByToken(
    129             self.state).title
    130         return state
     129        try:
     130            TRANSLATED_STATES = getUtility(ICustomersUtils).TRANSLATED_STATES
     131            ts = TRANSLATED_STATES[self.state]
     132            return ts
     133        except KeyError:
     134            return
    131135
    132136    @property
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/export.py

    r12018 r12032  
    2323from zope.component import getUtility
    2424from waeup.ikoba.interfaces import (
    25     IExtFileStore, IFileStoreNameChooser, IIkobaUtils)
     25    IExtFileStore, IFileStoreNameChooser)
    2626from waeup.ikoba.interfaces import MessageFactory as _
    2727from waeup.ikoba.customers.catalog import CustomersQuery
     
    147147            ICustomerDocument,
    148148            exclude_attribs=False,
    149             omit=['is_editable']))) + (
     149            omit=['is_editable', 'translated_state']))) + (
    150150            'customer_id',)
    151151
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/utils.py

    r12018 r12032  
    1919"""
    2020import grok
    21 from waeup.ikoba.interfaces import STARTED, APPROVED
     21from waeup.ikoba.interfaces import MessageFactory as _
     22from waeup.ikoba.interfaces import CREATED, STARTED, REQUESTED, APPROVED
    2223from waeup.ikoba.customers.interfaces import ICustomersUtils
    2324
     
    4142
    4243    DOCMANAGE_STATES = (APPROVED,)
     44
     45    TRANSLATED_STATES = {
     46        CREATED: _('created'),
     47        STARTED: _('started'),
     48        REQUESTED: _('requested'),
     49        APPROVED: _('approved'),
     50        }
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/document.py

    r12017 r12032  
    3232from waeup.ikoba.utils.helpers import attrs_to_fields, get_current_principal
    3333from waeup.ikoba.utils.logger import Logger
    34 from waeup.ikoba.documents.interfaces import IDocument, IDocument
     34from waeup.ikoba.documents.interfaces import (
     35    IDocument, IDocument, IDocumentsUtils)
    3536from waeup.ikoba.documents.utils import generate_document_id
    3637
     
    5253        return
    5354
    54     #def __init__(self):
    55     #    super(Document, self).__init__()
    56     #    timestamp = ("%d" % int(time()*10000))[1:]
    57     #    self.document_id = "d%s" % timestamp
    58      #   return
    59 
    6055    def __init__(self):
    6156        super(Document, self).__init__()
     
    7671        state = IWorkflowState(self).getState()
    7772        return state
     73
     74    @property
     75    def translated_state(self):
     76        try:
     77            TRANSLATED_STATES = getUtility(IDocumentsUtils).TRANSLATED_STATES
     78            ts = TRANSLATED_STATES[self.state]
     79            return ts
     80        except KeyError:
     81            return
    7882
    7983Document = attrs_to_fields(Document)
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/interfaces.py

    r12018 r12032  
    1919from zope import schema
    2020from waeup.ikoba.interfaces import (
    21     IIkobaObject, SimpleIkobaVocabulary,
     21    IIkobaObject,
    2222    ContextualDictSourceFactoryBase)
    2323from waeup.ikoba.interfaces import MessageFactory as _
     24
    2425
    2526class DocumentTypeSource(ContextualDictSourceFactoryBase):
     
    4647    history = Attribute('Object history, a list of messages')
    4748    state = Attribute('Returns the verification state of a document')
     49    translated_state = Attribute(
     50        'Returns a translated, more verbose verification state of a document')
    4851
    4952    title = schema.TextLine(
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/utils.py

    r12018 r12032  
    1919"""
    2020import grok
     21from waeup.ikoba.interfaces import MessageFactory as _
    2122from waeup.ikoba.documents.workflow import CREATED
    2223from waeup.ikoba.documents.interfaces import IDocumentsUtils
     24from waeup.ikoba.documents.workflow import (
     25    CREATED, SUBMITTED,
     26    VERIFIED, REJECTED, OUTDATED)
    2327
    2428
     
    3438
    3539    DOCMANAGE_STATES = (CREATED,)
     40
     41    TRANSLATED_STATES = {
     42        CREATED: _('document created'),
     43        SUBMITTED: _('document submitted'),
     44        VERIFIED: _('document verified'),
     45        REJECTED: _('document rejected'),
     46        OUTDATED:_('document outdated')
     47        }
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/workflow.py

    r12015 r12032  
    2424from hurry.workflow.interfaces import IWorkflowState, IWorkflowTransitionEvent
    2525from waeup.ikoba.interfaces import (
    26     IObjectHistory, IIkobaWorkflowInfo, IIkobaUtils)
     26    IObjectHistory, IIkobaWorkflowInfo,
     27    SimpleIkobaVocabulary)
    2728from waeup.ikoba.interfaces import MessageFactory as _
    2829from waeup.ikoba.workflow import IkobaWorkflow, IkobaWorkflowInfo
  • main/waeup.ikoba/trunk/src/waeup/ikoba/interfaces.py

    r11981 r12032  
    8383application_sessions_vocab = SimpleIkobaVocabulary(*application_sessions())
    8484
    85 registration_states_vocab = SimpleIkobaVocabulary(
    86     (_('created'), CREATED),
    87     (_('started'), STARTED),
    88     (_('requested'), REQUESTED),
    89     (_('approved'), APPROVED),
    90     )
    91 
    9285class ContextualDictSourceFactoryBase(SmartBasicContextualSourceFactory):
    9386    """A base for contextual sources based on IkobaUtils dicts.
Note: See TracChangeset for help on using the changeset viewer.