Ignore:
Timestamp:
25 Nov 2014, 08:19:54 (10 years ago)
Author:
Henrik Bettermann
Message:

Add second customer document class.
Select document factory when adding documents.
Add last_transition_date attribute and further property attributes to documents.

File:
1 edited

Legend:

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

    r12035 r12053  
    3333from waeup.ikoba.customers.interfaces import (
    3434    ICustomerDocumentsContainer, ICustomerNavigation, ICustomerDocument,
    35     ICustomersUtils)
     35    ICustomersUtils, ICustomerPDFDocument)
    3636from waeup.ikoba.documents import DocumentsContainer, Document
    3737from waeup.ikoba.documents.interfaces import IDocumentsUtils
     
    6060
    6161class CustomerDocument(Document):
    62     """This is an document.
     62    """This is a customer document.
    6363    """
    6464    grok.implements(ICustomerDocument, ICustomerNavigation)
     
    9494        return True
    9595
     96    @property
     97    def translated_classname(self):
     98        try:
     99            DOCTYPES_DICT = getUtility(ICustomersUtils).DOCTYPES_DICT
     100            return DOCTYPES_DICT[self.classname]
     101        except KeyError:
     102            return
     103
    96104CustomerDocument = attrs_to_fields(CustomerDocument)
     105
     106class CustomerPDFDocument(CustomerDocument):
     107    """This is a customer document for a single pdf upload file only.
     108    """
     109    grok.implements(ICustomerPDFDocument, ICustomerNavigation)
     110    grok.provides(ICustomerPDFDocument)
     111
     112CustomerPDFDocument = attrs_to_fields(CustomerPDFDocument)
    97113
    98114
     
    104120    grok.name(u'waeup.CustomerDocument')
    105121    title = u"Create a new document.",
    106     description = u"This factory instantiates new document instances."
     122    description = u"This factory instantiates new sample document instances."
    107123
    108124    def __call__(self, *args, **kw):
     
    111127    def getInterfaces(self):
    112128        return implementedBy(CustomerDocument)
     129
     130# Customer documents must be importable. So we might need a factory.
     131class CustomerPDFDocumentFactory(grok.GlobalUtility):
     132    """A factory for customer pdf documents.
     133    """
     134    grok.implements(IFactory)
     135    grok.name(u'waeup.CustomerPDFDocument')
     136    title = u"Create a new document.",
     137    description = u"This factory instantiates new pdf document instances."
     138
     139    def __call__(self, *args, **kw):
     140        return CustomerPDFDocument(*args, **kw)
     141
     142    def getInterfaces(self):
     143        return implementedBy(CustomerPDFDocument)
    113144
    114145#: The file id marker for customer files
Note: See TracChangeset for help on using the changeset viewer.