Changeset 12785 for main/waeup.ikoba/trunk/src/waeup/ikoba
- Timestamp:
- 18 Mar 2015, 08:45:41 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_interfaces.py
r12585 r12785 24 24 import shutil 25 25 from datetime import date 26 from zope.event import notify 26 27 from zope.component.hooks import setSite 27 28 from zope.component import queryUtility, createObject 28 29 from hurry.workflow.interfaces import IWorkflowState 29 30 from waeup.ikoba.app import Company 30 from waeup.ikoba.interfaces import SUBMITTED 31 from waeup.ikoba.interfaces import SUBMITTED, APPROVED 31 32 from waeup.ikoba.customers.vocabularies import ( 32 ConCatProductSource, ConCatActiveProductSource, CustomerDocumentSource) 33 ConCatProductSource, ConCatActiveProductSource, CustomerDocumentSource, 34 RefereeSourceFactory 35 ) 33 36 from waeup.ikoba.testing import FunctionalLayer, FunctionalTestCase 34 37 … … 133 136 self.assertEqual(result, u'DOC1... - My Sample Document') 134 137 138 def test_getValues_RefereeSourceFactory(self): 139 source = RefereeSourceFactory() 140 result = source.factory.getValues(object()) 141 self.assertFalse(self.customer in result) 142 IWorkflowState(self.customer).setState(APPROVED) 143 notify(grok.ObjectModifiedEvent(self.customer)) 144 result = source.factory.getValues(object()) 145 self.assertTrue(self.customer in result) 146 147 def test_getTitle_RefereeSourceFactory(self): 148 source = RefereeSourceFactory() 149 result = source.factory.getTitle(object(), self.customer) 150 self.assertEqual(result, u'Bob Tester (K1000000)') -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/vocabularies.py
r12770 r12785 29 29 from zc.sourcefactory.interfaces import IContextualSource 30 30 from waeup.ikoba.sourcefactory import SmartBasicContextualSourceFactory 31 from waeup.ikoba.interfaces import SimpleIkobaVocabulary, SUBMITTED, VERIFIED 31 from waeup.ikoba.interfaces import ( 32 SimpleIkobaVocabulary, SUBMITTED, VERIFIED, APPROVED 33 ) 32 34 from waeup.ikoba.interfaces import MessageFactory as _ 33 35 from waeup.ikoba.utils.helpers import get_sorted_preferred … … 167 169 if not concat: 168 170 return products 169 170 171 resultlist = [ 171 172 value for value in products … … 238 239 currency = ISO_4217_CURRENCIES[value.currency][1] 239 240 return "%s @ %s %s" % (value.title, value.fee, currency) 241 242 243 class IRefereeSource(IContextualSource): 244 """A source operating in context. 245 246 This is a marker interface needed for the registration of the 247 IkobaSequenceWidget when using the List-Choice-RefereeSourceFactory 248 field combination primarily in ICustomer as a replacement for 249 the SourceOrderedMultiSelectWidget. 250 """ 251 252 253 class RefereeSource(FactoredContextualSource): 254 255 implements(IRefereeSource) 256 257 258 class RefereeSourceFactory(BasicContextualSourceFactory): 259 """A referee source delivers all registered and approved customers. 260 """ 261 262 source_class = RefereeSource 263 264 def getValues(self, context): 265 user_id = getattr(getattr(context, 'customer', None), 'user_id', None) 266 catalog = getUtility(ICatalog, name='customers_catalog') 267 results = catalog.searchResults(state=(APPROVED, APPROVED)) 268 return list(results) 269 270 def getToken(self, context, value): 271 return value.customer_id 272 273 def getTitle(self, context, value): 274 return "%s (%s)" % (value.display_fullname, value.customer_id[:9]) -
main/waeup.ikoba/trunk/src/waeup/ikoba/widgets/overrides.zcml
r12506 r12785 52 52 permission="zope.Public" 53 53 /> 54 55 <!-- Register IkobaSequenceWidget for RefereeSource --> 56 <adapter 57 for="zope.schema.interfaces.IList 58 waeup.ikoba.customers.vocabularies.IRefereeSource 59 zope.publisher.interfaces.browser.IBrowserRequest" 60 provides="zope.formlib.interfaces.ISimpleInputWidget" 61 factory="waeup.ikoba.widgets.sequencewidget.IkobaSequenceWidget" 62 permission="zope.Public" 63 /> 54 64 55 65 <!-- Register IkobaSourceOrderedMultiSelectWidget for IterableSource -->
Note: See TracChangeset for help on using the changeset viewer.