Changeset 12200 for main


Ignore:
Timestamp:
12 Dec 2014, 15:34:50 (10 years ago)
Author:
Henrik Bettermann
Message:

We need documents which can be accessed or downloaded from product pages. These documents can provide general information of registration processes or pdf forms to be filled offline and later uploaded by customers.

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

Legend:

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

    r12194 r12200  
    338338    for contract in contracts:
    339339        # Remove that referrer...
    340         #contract.product = None
    341340        for key, value in contract.__dict__.items():
    342341            if key.endswith('_object') and \
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/document.py

    r12168 r12200  
    3232from waeup.ikoba.utils.helpers import attrs_to_fields, get_current_principal
    3333from waeup.ikoba.documents.interfaces import (
    34     IDocument, IDocument, IDocumentsUtils)
     34    IDocument, IDocument, IDocumentsUtils,
     35    IPDFDocument, IHTMLDocument)
    3536from waeup.ikoba.documents.utils import generate_document_id
    3637
     
    100101
    101102
     103class PDFDocument(Document):
     104    """This is a  document for a single pdf upload file.
     105    """
     106    grok.implements(IPDFDocument)
     107    grok.provides(IPDFDocument)
     108
     109PDFDocument = attrs_to_fields(PDFDocument)
     110
     111
     112class HTMLDocument(Document):
     113    """This is a  document to render html-coded text.
     114    """
     115    grok.implements(IHTMLDocument)
     116    grok.provides(IHTMLDocument)
     117
     118HTMLDocument = attrs_to_fields(HTMLDocument)
     119
     120
    102121class DocumentFactory(grok.GlobalUtility):
    103122    """A factory for documents.
     
    114133        return implementedBy(Document)
    115134
     135
     136class PDFDocumentFactory(grok.GlobalUtility):
     137    """A factory for documents.
     138    """
     139    grok.implements(IFactory)
     140    grok.name(u'waeup.PDFDocument')
     141    title = u"Create a new PDF document.",
     142    description = u"This factory instantiates new PDF documents."
     143
     144    def __call__(self, *args, **kw):
     145        return PDFDocument(*args, **kw)
     146
     147    def getInterfaces(self):
     148        return implementedBy(PDFDocument)
     149
     150
     151class HTMLDocumentFactory(grok.GlobalUtility):
     152    """A factory for HTML documents.
     153    """
     154    grok.implements(IFactory)
     155    grok.name(u'waeup.HTMLDocument')
     156    title = u"Create a new HTML document.",
     157    description = u"This factory instantiates new HTML documents."
     158
     159    def __call__(self, *args, **kw):
     160        return HTMLDocument(*args, **kw)
     161
     162    def getInterfaces(self):
     163        return implementedBy(HTMLDocument)
     164
     165
    116166@grok.subscribe(IDocument, grok.IObjectAddedEvent)
    117167def handle_document_added(document, event):
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/interfaces.py

    r12168 r12200  
    2424
    2525
    26 class DocumentTypeSource(ContextualDictSourceFactoryBase):
    27     """A document type source delivers all types of documents.
    28 
    29     """
    30     #: name of dict to deliver from ikoba utils.
    31     DICT_NAME = 'DOCUMENT_TYPES'
    32 
    3326class IDocumentsContainer(IIkobaObject):
    3427    """A container for all kind of document objects.
     
    3932        """Add a document.
    4033        """
     34
    4135
    4236class IDocument(IIkobaObject):
     
    7165        """
    7266
     67class IPDFDocument(IDocument):
     68    """A base representation of PDF documents.
     69
     70    """
     71
     72
     73class IHTMLDocument(IDocument):
     74    """A base representation of HTML documents.
     75
     76    """
     77
    7378
    7479class IDocumentsUtils(Interface):
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/tests.py

    r12005 r12200  
    2424    IWorkflowInfo, IWorkflowState, InvalidTransitionError)
    2525from waeup.ikoba.documents.interfaces import (
    26     IDocumentsContainer, IDocument)
     26    IDocumentsContainer, IDocument, IPDFDocument, IHTMLDocument)
    2727from waeup.ikoba.interfaces import IObjectHistory
    2828from waeup.ikoba.documents.container import DocumentsContainer
    29 from waeup.ikoba.documents.document import Document
     29from waeup.ikoba.documents.document import (
     30    Document, PDFDocument, HTMLDocument)
    3031from waeup.ikoba.testing import (FunctionalLayer, FunctionalTestCase)
    3132
     
    5253                IDocument, Document())
    5354            )
     55
     56        self.assertTrue(
     57            verifyClass(
     58                IPDFDocument, PDFDocument)
     59            )
     60        self.assertTrue(
     61            verifyObject(
     62                IPDFDocument, PDFDocument())
     63            )
     64
     65        self.assertTrue(
     66            verifyClass(
     67                IHTMLDocument, HTMLDocument)
     68            )
     69        self.assertTrue(
     70            verifyObject(
     71                IHTMLDocument, HTMLDocument())
     72            )
    5473        return
    5574
    5675    def test_addDocument(self):
    5776        container = DocumentsContainer()
    58         document = createObject(u'waeup.Document')
     77        document = createObject(u'waeup.HTMLDocument')
    5978        document_id = document.document_id
    6079        container.addDocument(document)
     
    6584
    6685    def test_document_workflow(self):
    67         document = createObject(u'waeup.Document')
     86        document = createObject(u'waeup.HTMLDocument')
    6887        IWorkflowInfo(document).fireTransition('create')
    6988        self.assertEqual(IWorkflowState(document).getState(), 'created')
     
    7998        IWorkflowInfo(document).fireTransition('reset3')
    8099        self.assertEqual(IWorkflowState(document).getState(), 'created')
     100        IWorkflowInfo(document).fireTransition('publish')
     101        self.assertEqual(IWorkflowState(document).getState(), 'published')
    81102        return
    82103
    83104    def test_document_history(self):
    84         doc = createObject(u'waeup.Document')
     105        doc = createObject(u'waeup.HTMLDocument')
    85106        IWorkflowInfo(doc).fireTransition('create')
    86107        messages = ' '.join(doc.history.messages)
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/workflow.py

    r12168 r12200  
    2727    IObjectHistory, IIkobaWorkflowInfo,
    2828    SimpleIkobaVocabulary,
    29     CREATED, SUBMITTED, VERIFIED, REJECTED, EXPIRED)
     29    CREATED, SUBMITTED, VERIFIED, REJECTED, EXPIRED, PUBLISHED)
    3030from waeup.ikoba.interfaces import MessageFactory as _
    3131from waeup.ikoba.workflow import IkobaWorkflow, IkobaWorkflowInfo
     
    9999        source = EXPIRED,
    100100        destination = CREATED),
     101
     102    Transition(
     103        transition_id = 'publish',
     104        title = _('Publish'),
     105        msg = _('Published'),
     106        source = CREATED,
     107        destination = PUBLISHED),
    101108    )
    102109
  • main/waeup.ikoba/trunk/src/waeup/ikoba/interfaces.py

    r12186 r12200  
    5757REJECTED = 'rejected'
    5858EXPIRED = 'expired'
     59PUBLISHED = 'published'
    5960
    6061
Note: See TracChangeset for help on using the changeset viewer.