Changeset 16231 for main


Ignore:
Timestamp:
10 Sep 2020, 07:22:19 (4 years ago)
Author:
Henrik Bettermann
Message:

Implement ContactApplicantFormPage.

Location:
main/waeup.kofa/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/CHANGES.txt

    r16228 r16231  
    441.6.1.dev0 (unreleased)
    55=======================
     6
     7* Implement `ContactApplicantFormPage`.
    68
    79* Use `Applicant.createStudent` method also to create graduated
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py

    r16221 r16231  
    6666from waeup.kofa.permissions import get_users_with_local_roles
    6767from waeup.kofa.students.interfaces import IStudentsUtils
     68from waeup.kofa.students.browser import ContactStudentFormPage
    6869from waeup.kofa.utils.helpers import string_from_bytes, file_size, now
    6970from waeup.kofa.widgets.datewidget import (
     
    712713            return form_fields
    713714        return form_fields
     715
     716class ContactApplicantFormPage(ContactStudentFormPage):
     717    grok.context(IApplicant)
     718    grok.name('contactapplicant')
     719    grok.require('waeup.viewApplication')
     720    pnav = 3
    714721
    715722class CreateStudentPage(UtilityView, grok.View):
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py

    r16215 r16231  
    3737from zope.security.interfaces import Unauthorized
    3838from zope.testbrowser.testing import Browser
     39from zope.interface import implementedBy
     40from zope.schema.fieldproperty import FieldProperty
    3941from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
    4042from waeup.kofa.browser.tests.test_pdf import samples_dir
     
    583585    layer = FunctionalLayer
    584586
     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
    585620    def test_manage_and_view_applicant(self):
    586621        # Managers can manage applicants
     
    623658        # If applicant is in correct state the pdf slip can be opened.
    624659        IWorkflowState(self.applicant).setState('submitted')
    625         self.browser.open(self.manage_path)
     660        self.browser.open(self.view_path)
    626661        self.browser.getLink("Download application slip").click()
    627662        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     
    924959        file_ctrl.add_file(pseudo_image, filename='myphoto.jpg')
    925960        self.browser.getControl("Save").click() # submit form
    926         self.browser.open(self.manage_path)
     961        self.browser.open(self.view_path)
    927962        self.browser.getLink("Download application slip").click()
    928963        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     
    13311366        return
    13321367
     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
    13331412
    13341413class ApplicantRegisterTests(ApplicantsFullSetup):
     
    19562035        # Managers can remind referees
    19572036        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    1958         self.browser.open(self.manage_path)
     2037        self.browser.open(self.view_path)
    19592038        self.browser.getLink("Remind referees").click()
    19602039        self.assertTrue('2 referee(s) have been reminded by email.'
     
    20352114        report.email = 'linda@forest.de'
    20362115        self.applicant[report.r_id] = report
    2037         self.browser.open(self.manage_path)
     2116        self.browser.open(self.view_path)
    20382117        self.browser.getLink("Remind referees").click()
    20392118        self.assertTrue('1 referee(s) have been reminded by email.'
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/viewlets.py

    r16214 r16231  
    242242    grok.require('waeup.viewApplication')
    243243    grok.name('pdfactionbutton')
     244    grok.view(ApplicantDisplayFormPage)
    244245    icon = 'actionicon_pdf.png'
    245246    text = _('Download application slip')
     
    275276    grok.context(IApplicant)
    276277    grok.require('waeup.manageApplication')
     278    grok.view(ApplicantDisplayFormPage)
    277279    icon = 'actionicon_alarm.png'
    278280    text = _('Remind referees')
     
    293295            return
    294296        return self.view.url(self.view.context, self.target)
     297
     298class 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'
    295306
    296307class PaymentReceiptActionButton(ManageActionButton):
Note: See TracChangeset for help on using the changeset viewer.