- Timestamp:
- 12 Dec 2014, 15:34:50 (10 years ago)
- 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 338 338 for contract in contracts: 339 339 # Remove that referrer... 340 #contract.product = None341 340 for key, value in contract.__dict__.items(): 342 341 if key.endswith('_object') and \ -
main/waeup.ikoba/trunk/src/waeup/ikoba/documents/document.py
r12168 r12200 32 32 from waeup.ikoba.utils.helpers import attrs_to_fields, get_current_principal 33 33 from waeup.ikoba.documents.interfaces import ( 34 IDocument, IDocument, IDocumentsUtils) 34 IDocument, IDocument, IDocumentsUtils, 35 IPDFDocument, IHTMLDocument) 35 36 from waeup.ikoba.documents.utils import generate_document_id 36 37 … … 100 101 101 102 103 class PDFDocument(Document): 104 """This is a document for a single pdf upload file. 105 """ 106 grok.implements(IPDFDocument) 107 grok.provides(IPDFDocument) 108 109 PDFDocument = attrs_to_fields(PDFDocument) 110 111 112 class HTMLDocument(Document): 113 """This is a document to render html-coded text. 114 """ 115 grok.implements(IHTMLDocument) 116 grok.provides(IHTMLDocument) 117 118 HTMLDocument = attrs_to_fields(HTMLDocument) 119 120 102 121 class DocumentFactory(grok.GlobalUtility): 103 122 """A factory for documents. … … 114 133 return implementedBy(Document) 115 134 135 136 class 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 151 class 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 116 166 @grok.subscribe(IDocument, grok.IObjectAddedEvent) 117 167 def handle_document_added(document, event): -
main/waeup.ikoba/trunk/src/waeup/ikoba/documents/interfaces.py
r12168 r12200 24 24 25 25 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 33 26 class IDocumentsContainer(IIkobaObject): 34 27 """A container for all kind of document objects. … … 39 32 """Add a document. 40 33 """ 34 41 35 42 36 class IDocument(IIkobaObject): … … 71 65 """ 72 66 67 class IPDFDocument(IDocument): 68 """A base representation of PDF documents. 69 70 """ 71 72 73 class IHTMLDocument(IDocument): 74 """A base representation of HTML documents. 75 76 """ 77 73 78 74 79 class IDocumentsUtils(Interface): -
main/waeup.ikoba/trunk/src/waeup/ikoba/documents/tests.py
r12005 r12200 24 24 IWorkflowInfo, IWorkflowState, InvalidTransitionError) 25 25 from waeup.ikoba.documents.interfaces import ( 26 IDocumentsContainer, IDocument )26 IDocumentsContainer, IDocument, IPDFDocument, IHTMLDocument) 27 27 from waeup.ikoba.interfaces import IObjectHistory 28 28 from waeup.ikoba.documents.container import DocumentsContainer 29 from waeup.ikoba.documents.document import Document 29 from waeup.ikoba.documents.document import ( 30 Document, PDFDocument, HTMLDocument) 30 31 from waeup.ikoba.testing import (FunctionalLayer, FunctionalTestCase) 31 32 … … 52 53 IDocument, Document()) 53 54 ) 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 ) 54 73 return 55 74 56 75 def test_addDocument(self): 57 76 container = DocumentsContainer() 58 document = createObject(u'waeup. Document')77 document = createObject(u'waeup.HTMLDocument') 59 78 document_id = document.document_id 60 79 container.addDocument(document) … … 65 84 66 85 def test_document_workflow(self): 67 document = createObject(u'waeup. Document')86 document = createObject(u'waeup.HTMLDocument') 68 87 IWorkflowInfo(document).fireTransition('create') 69 88 self.assertEqual(IWorkflowState(document).getState(), 'created') … … 79 98 IWorkflowInfo(document).fireTransition('reset3') 80 99 self.assertEqual(IWorkflowState(document).getState(), 'created') 100 IWorkflowInfo(document).fireTransition('publish') 101 self.assertEqual(IWorkflowState(document).getState(), 'published') 81 102 return 82 103 83 104 def test_document_history(self): 84 doc = createObject(u'waeup. Document')105 doc = createObject(u'waeup.HTMLDocument') 85 106 IWorkflowInfo(doc).fireTransition('create') 86 107 messages = ' '.join(doc.history.messages) -
main/waeup.ikoba/trunk/src/waeup/ikoba/documents/workflow.py
r12168 r12200 27 27 IObjectHistory, IIkobaWorkflowInfo, 28 28 SimpleIkobaVocabulary, 29 CREATED, SUBMITTED, VERIFIED, REJECTED, EXPIRED )29 CREATED, SUBMITTED, VERIFIED, REJECTED, EXPIRED, PUBLISHED) 30 30 from waeup.ikoba.interfaces import MessageFactory as _ 31 31 from waeup.ikoba.workflow import IkobaWorkflow, IkobaWorkflowInfo … … 99 99 source = EXPIRED, 100 100 destination = CREATED), 101 102 Transition( 103 transition_id = 'publish', 104 title = _('Publish'), 105 msg = _('Published'), 106 source = CREATED, 107 destination = PUBLISHED), 101 108 ) 102 109 -
main/waeup.ikoba/trunk/src/waeup/ikoba/interfaces.py
r12186 r12200 57 57 REJECTED = 'rejected' 58 58 EXPIRED = 'expired' 59 PUBLISHED = 'published' 59 60 60 61
Note: See TracChangeset for help on using the changeset viewer.