Changeset 12553 for main/waeup.ikoba/trunk/src/waeup/ikoba/customers
- Timestamp:
- 3 Feb 2015, 16:54:56 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba/customers
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/customer.py
r12398 r12553 110 110 111 111 @property 112 def title(self): 113 return self.display_fullname 114 115 @property 112 116 def fullname(self): 113 117 firstname = getattr(self, 'firstname', None) -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/interfaces.py
r12537 r12553 78 78 fullname = Attribute('All name parts separated by hyphens') 79 79 display_fullname = Attribute('The fullname of an applicant') 80 title = Attribute('A title used for email notifications only') 80 81 81 82 suspended = schema.Bool( -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py
r12540 r12553 21 21 import shutil 22 22 import tempfile 23 import logging 23 24 import pytz 24 25 import base64 … … 301 302 # Tests for Customer class views and pages 302 303 304 305 def setup_logging(self): 306 # setup a log-handler that catches all fake mailer output 307 self.stream = StringIO() 308 handler = logging.StreamHandler(self.stream) 309 logger = logging.getLogger('test.smtp') 310 logger.addHandler(handler) 311 logger.setLevel(logging.INFO) 312 return 313 314 def get_fake_smtp_output(self): 315 # get output generated by fake mailer 316 self.stream.flush() 317 self.stream.seek(0) 318 return self.stream.read() 319 320 def teardown_logging(self): 321 # remove the log handler for fake mailer output 322 logger = logging.getLogger('test.smtp') 323 handlers = [x for x in logger.handlers] 324 for handler in handlers: 325 logger.removeHandler(handler) 326 return 327 303 328 def test_basic_auth(self): 304 329 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') … … 386 411 387 412 388 def test_manage_workflow (self):413 def test_manage_workflow_send_transition_information(self): 389 414 # Managers can pass through the whole workflow 415 config = grok.getSite()['configuration'] 416 config.email_notification = True 417 self.setup_logging() 390 418 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 391 419 customer = self.app['customers'][self.customer_id] … … 399 427 self.browser.getControl(name="transition").value = ['reject'] 400 428 self.browser.getControl("Apply").click() 429 # The customer is being notified by email after rejection 430 expected = [ 431 u'Sending email from no-reply@waeup.org to aa@aa.ng:', 432 u'Message:', u'msg: MIME-Version: 1.0', 433 u'msg: Content-Type: text/plain; charset="us-ascii"', 434 u'msg: Content-Transfer-Encoding: 7bit', 435 u'msg: From: Administrator <no-reply@waeup.org>', 436 u'msg: To: Anna Tester <aa@aa.ng>', 437 u'msg: Reply-To: Administrator <contact@waeup.org>', 438 u'msg: Subject: Ikoba status change information', 439 u'msg: ', 440 u'msg: Dear Anna Tester,', 441 u'msg: ', 442 u'msg: The status of the following object has been changed:', 443 u'msg: ', u'msg: Object Id: K1000000', 444 u'msg: Title: Anna Tester', 445 u'msg: Transition: customer registration rejected', 446 u'msg: New state: started', 447 u'msg: ', 448 u'msg: Regards,', 449 u'msg: ', 450 u'msg: Manager', 451 u'msg: ', 452 u'msg: --', 453 u'msg: Sample Company', 454 u'msg: ', 455 u''] 456 self.assertEqual(expected, self.get_fake_smtp_output().split('\n')) 401 457 self.browser.open(self.trigtrans_path) 402 458 self.browser.getControl(name="transition").value = ['request'] … … 411 467 self.browser.getControl(name="transition").value = ['reset1'] 412 468 self.browser.getControl("Apply").click() 469 self.teardown_logging() 413 470 return 414 471 -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/workflow.py
r12526 r12553 21 21 from datetime import datetime 22 22 from zope.component import getUtility 23 from zope.i18n import translate 23 24 from hurry.workflow.workflow import Transition, WorkflowState, NullCondition 24 25 from hurry.workflow.interfaces import ( 25 26 IWorkflowState, IWorkflowTransitionEvent, InvalidTransitionError) 26 27 from waeup.ikoba.interfaces import ( 27 IObjectHistory, IIkobaWorkflowInfo, IIkobaUtils, 28 IObjectHistory, IIkobaWorkflowInfo, IIkobaUtils, IUserAccount, 28 29 STARTED, CREATED, REQUESTED, PROVISIONALLY, APPROVED, 29 30 SUBMITTED, VERIFIED, REJECTED, EXPIRED) … … 159 160 def handle_customer_transition_event(obj, event): 160 161 """Append message to customer history and log file when transition happened. 162 163 Notify customer by email. 161 164 """ 162 165 … … 164 167 history = IObjectHistory(obj) 165 168 history.addMessage(msg) 169 if event.transition.transition_id not in ('create', 'start', 'request'): 170 ikoba_utils = getUtility(IIkobaUtils) 171 ikoba_utils.sendTransitionInfo(IUserAccount(obj), obj, msg) 166 172 try: 167 173 customers_container = grok.getSite()['customers'] … … 280 286 history = IObjectHistory(obj) 281 287 history.addMessage(msg) 288 if event.transition.transition_id not in ('create', 'submit') \ 289 and obj.customer: 290 ikoba_utils = getUtility(IIkobaUtils) 291 ikoba_utils.sendTransitionInfo(IUserAccount(obj.customer), obj, msg) 282 292 try: 283 293 customers_container = grok.getSite()['customers']
Note: See TracChangeset for help on using the changeset viewer.