- Timestamp:
- 10 Sep 2020, 07:22:19 (4 years ago)
- Location:
- main/waeup.kofa/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/CHANGES.txt
r16228 r16231 4 4 1.6.1.dev0 (unreleased) 5 5 ======================= 6 7 * Implement `ContactApplicantFormPage`. 6 8 7 9 * Use `Applicant.createStudent` method also to create graduated -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py
r16221 r16231 66 66 from waeup.kofa.permissions import get_users_with_local_roles 67 67 from waeup.kofa.students.interfaces import IStudentsUtils 68 from waeup.kofa.students.browser import ContactStudentFormPage 68 69 from waeup.kofa.utils.helpers import string_from_bytes, file_size, now 69 70 from waeup.kofa.widgets.datewidget import ( … … 712 713 return form_fields 713 714 return form_fields 715 716 class ContactApplicantFormPage(ContactStudentFormPage): 717 grok.context(IApplicant) 718 grok.name('contactapplicant') 719 grok.require('waeup.viewApplication') 720 pnav = 3 714 721 715 722 class CreateStudentPage(UtilityView, grok.View): -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py
r16215 r16231 37 37 from zope.security.interfaces import Unauthorized 38 38 from zope.testbrowser.testing import Browser 39 from zope.interface import implementedBy 40 from zope.schema.fieldproperty import FieldProperty 39 41 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState 40 42 from waeup.kofa.browser.tests.test_pdf import samples_dir … … 583 585 layer = FunctionalLayer 584 586 587 def setUp(self): 588 super(ApplicantUITests, self).setUp() 589 self.setup_logging() 590 return 591 592 def tearDown(self): 593 super(ApplicantUITests, self).tearDown() 594 self.teardown_logging() 595 return 596 597 def setup_logging(self): 598 # setup a log-handler that catches all fake mailer output 599 self.stream = StringIO() 600 handler = logging.StreamHandler(self.stream) 601 logger = logging.getLogger('test.smtp') 602 logger.addHandler(handler) 603 logger.setLevel(logging.INFO) 604 return 605 606 def get_fake_smtp_output(self): 607 # get output generated by fake mailer 608 self.stream.flush() 609 self.stream.seek(0) 610 return self.stream.read() 611 612 def teardown_logging(self): 613 # remove the log handler for fake mailer output 614 logger = logging.getLogger('test.smtp') 615 handlers = [x for x in logger.handlers] 616 for handler in handlers: 617 logger.removeHandler(handler) 618 return 619 585 620 def test_manage_and_view_applicant(self): 586 621 # Managers can manage applicants … … 623 658 # If applicant is in correct state the pdf slip can be opened. 624 659 IWorkflowState(self.applicant).setState('submitted') 625 self.browser.open(self. manage_path)660 self.browser.open(self.view_path) 626 661 self.browser.getLink("Download application slip").click() 627 662 self.assertEqual(self.browser.headers['Status'], '200 Ok') … … 924 959 file_ctrl.add_file(pseudo_image, filename='myphoto.jpg') 925 960 self.browser.getControl("Save").click() # submit form 926 self.browser.open(self. manage_path)961 self.browser.open(self.view_path) 927 962 self.browser.getLink("Download application slip").click() 928 963 self.assertEqual(self.browser.headers['Status'], '200 Ok') … … 1331 1366 return 1332 1367 1368 def test_manage_contact_applicant(self): 1369 # Managers can contact student 1370 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 1371 # Remove required FieldProperty attribute first ... 1372 delattr(Applicant, 'email') 1373 # ... and replace by None 1374 self.applicant.email = None 1375 # Now we have to add the FieldProperty attribute again. Otherwise 1376 # many other tests below will fail. 1377 iface = list(implementedBy(Applicant))[0] 1378 field_property = FieldProperty(iface['email']) 1379 setattr(Applicant, 'email', field_property) 1380 self.browser.open(self.view_path) 1381 self.browser.getLink("Send email").click() 1382 self.browser.getControl( 1383 name="form.subject").value = 'Important subject' 1384 self.browser.getControl(name="form.body").value = 'Hello!' 1385 self.browser.getControl("Send message now").click() 1386 self.assertTrue( 1387 'An smtp server error occurred' in self.browser.contents) 1388 self.applicant.email = 'xx@yy.zz' 1389 self.browser.getControl("Send message now").click() 1390 self.assertTrue('Your message has been sent' in self.browser.contents) 1391 self.assertMatches( 1392 'Sending email from no-reply@waeup.org to xx@yy.zz:' 1393 '\nMessage:' 1394 '\nmsg: MIME-Version: 1.0' 1395 '\nmsg: Content-Type: text/plain; charset="us-ascii"' 1396 '\nmsg: Content-Transfer-Encoding: 7bit' 1397 '\nmsg: From: Manager <no-reply@waeup.org>' 1398 '\nmsg: To: Joan None <xx@yy.zz>' 1399 '\nmsg: Reply-To: Manager <contact@waeup.org>' 1400 '\nmsg: Subject: Important subject' 1401 '\nmsg:' 1402 '\nmsg: Hello!' 1403 '\nmsg:' 1404 '\nmsg: ---' 1405 '\nmsg: Manager (id: zope.mgr)' 1406 '\nmsg: Sample University' 1407 '\nmsg:', 1408 self.get_fake_smtp_output() 1409 ) 1410 return 1411 1333 1412 1334 1413 class ApplicantRegisterTests(ApplicantsFullSetup): … … 1956 2035 # Managers can remind referees 1957 2036 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 1958 self.browser.open(self. manage_path)2037 self.browser.open(self.view_path) 1959 2038 self.browser.getLink("Remind referees").click() 1960 2039 self.assertTrue('2 referee(s) have been reminded by email.' … … 2035 2114 report.email = 'linda@forest.de' 2036 2115 self.applicant[report.r_id] = report 2037 self.browser.open(self. manage_path)2116 self.browser.open(self.view_path) 2038 2117 self.browser.getLink("Remind referees").click() 2039 2118 self.assertTrue('1 referee(s) have been reminded by email.' -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/viewlets.py
r16214 r16231 242 242 grok.require('waeup.viewApplication') 243 243 grok.name('pdfactionbutton') 244 grok.view(ApplicantDisplayFormPage) 244 245 icon = 'actionicon_pdf.png' 245 246 text = _('Download application slip') … … 275 276 grok.context(IApplicant) 276 277 grok.require('waeup.manageApplication') 278 grok.view(ApplicantDisplayFormPage) 277 279 icon = 'actionicon_alarm.png' 278 280 text = _('Remind referees') … … 293 295 return 294 296 return self.view.url(self.view.context, self.target) 297 298 class ContactActionButton(ManageActionButton): 299 grok.order(6) 300 grok.context(IApplicant) 301 grok.view(ApplicantDisplayFormPage) 302 grok.require('waeup.viewApplication') 303 icon = 'actionicon_mail.png' 304 text = _('Send email') 305 target = 'contactapplicant' 295 306 296 307 class PaymentReceiptActionButton(ManageActionButton):
Note: See TracChangeset for help on using the changeset viewer.