Changeset 13991
- Timestamp:
- 25 Jun 2016, 08:26:16 (9 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/applicants
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py
r13976 r13991 1511 1511 """ 1512 1512 grok.context(IApplicant) 1513 grok.require('waeup. manageApplication') # XXX: Will be public1513 grok.require('waeup.Public') 1514 1514 grok.name('addrefereereport') 1515 1515 form_fields = grok.AutoFields( … … 1520 1520 1521 1521 def update(self): 1522 # XXX: Check mandate 1522 blocker = grok.getSite()['configuration'].maintmode_enabled_by 1523 if blocker: 1524 self.flash(_('The portal is in maintenance mode. ' 1525 'Referee report forms are temporarily disabled.'), 1526 type='warning') 1527 self.redirect(self.application_url()) 1528 return 1529 # Check mandate 1530 form = self.request.form 1531 mandate_id = form.get('mandate_id', None) 1532 mandates = grok.getSite()['mandates'] 1533 mandate = mandates.get(mandate_id, None) 1534 if mandate is None and not self.request.form.get('form.actions.submit'): 1535 self.flash(_('No mandate.'), type='warning') 1536 self.redirect(self.application_url()) 1537 return 1538 if mandate: 1539 # Prefill form with mandate params 1540 self.form_fields.get( 1541 'name').field.default = mandate.params['name'] 1542 self.form_fields.get( 1543 'email').field.default = mandate.params['email'] 1523 1544 super(RefereeReportAddFormPage, self).update() 1524 1545 return … … 1535 1556 self.applyData(report, **data) 1536 1557 self.context[report.r_id] = report 1537 self.flash(_('Referee report created.'))1558 self.flash(_('Referee report has been saved. Thank you!')) 1538 1559 self.context.writeLogMessage(self, 'added: %s' % report.r_id) 1539 # XXX: Email has to be sent. 1540 # XXX: Will be replaced by landing page 1541 self.redirect( 1542 self.url(self.context[report.r_id], 'index')) 1543 return 1560 # XXX: Delete mandate 1561 # XXX: Send email 1562 self.redirect(self.application_url()) 1563 return -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py
r13976 r13991 47 47 from waeup.kofa.university.faculty import Faculty 48 48 from waeup.kofa.university.department import Department 49 from waeup.kofa.mandates.mandate import RefereeReportMandate 49 50 from waeup.kofa.tests.test_async import FunctionalAsyncTestCase 50 51 … … 1525 1526 layer = FunctionalLayer 1526 1527 1528 def test_refereereport_mandate(self): 1529 mandate = RefereeReportMandate() 1530 mandate.params['name'] = u'John Referee' 1531 mandate.params['email'] = 'aa@aa.aa' 1532 mandate.params[ 1533 'redirect_path'] = '/applicants/%s/%s/addrefereereport' % ( 1534 container_name_1, self.applicant.application_number) 1535 self.app['mandates'].addMandate(mandate) 1536 # Let's open the add form page via the mandate view 1537 self.browser.open('http://localhost/app/mandate?mandate_id=%s' 1538 % mandate.mandate_id) 1539 # Form page opens and is prefilled 1540 self.assertEqual( 1541 self.browser.url, 1542 'http://localhost/app/applicants/%s/%s/addrefereereport?mandate_id=%s' 1543 % (container_name_1, self.applicant.application_number, 1544 mandate.mandate_id)) 1545 self.assertTrue('value="John Referee"' in self.browser.contents) 1546 # Let's open the page directly with an invalid mandate 1547 self.browser.open( 1548 'http://localhost/app/applicants/%s/%s/addrefereereport?mandate_id=wrongmadate' 1549 % (container_name_1, self.applicant.application_number)) 1550 self.assertTrue('<div class="alert alert-warning">No mandate.</div>' 1551 in self.browser.contents) 1552 self.assertEqual(self.browser.url, 'http://localhost/app') 1553 # Page is also blocked in maintenance mode 1554 grok.getSite()['configuration'].maintmode_enabled_by = u'anybody' 1555 self.browser.open( 1556 'http://localhost/app/applicants/%s/%s/addrefereereport?mandate_id=%s' 1557 % (container_name_1, self.applicant.application_number, 1558 mandate.mandate_id)) 1559 self.assertTrue('<div class="alert alert-warning">The portal is ' 1560 'in maintenance mode' 1561 in self.browser.contents) 1562 self.assertEqual(self.browser.url, 'http://localhost/app') 1563 1527 1564 def test_add_and_view_reports(self): 1528 # Managers can view reports 1529 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 1530 self.browser.open(self.manage_path) 1531 # So far no report has been added 1532 self.assertFalse('Referee' in self.browser.contents) 1533 # XXX: Form will be public 1534 self.browser.open(self.view_path + '/addrefereereport') 1535 self.browser.getControl(name="form.name").value = 'John Trust' 1536 self.browser.getControl(name="form.email").value = 'xx@yy.zz' 1565 mandate = RefereeReportMandate() 1566 mandate.params['name'] = u'John Referee' 1567 mandate.params['email'] = 'aa@aa.aa' 1568 mandate.params[ 1569 'redirect_path'] = '/applicants/%s/%s/addrefereereport' % ( 1570 container_name_1, self.applicant.application_number) 1571 self.app['mandates'].addMandate(mandate) 1572 # Let's open the add form page via the mandate view 1573 self.browser.open('http://localhost/app/mandate?mandate_id=%s' 1574 % mandate.mandate_id) 1537 1575 self.browser.getControl("Submit").click() 1538 self.assertTrue('Referee report created' in self.browser.contents) 1539 # Report has been created and we are viewing the report's index page 1576 self.assertTrue('Referee report has been saved' in self.browser.contents) 1577 self.assertEqual(self.browser.url, 'http://localhost/app') 1578 # Report has been created 1540 1579 self.assertEqual(len(self.applicant.refereereports), 1) 1541 1580 report = self.applicant.refereereports[0] 1581 # Managers can view the report 1582 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 1583 self.browser.open(self.manage_path) 1584 self.browser.getLink("%s" % report.r_id).click() 1542 1585 self.assertEqual( 1543 self.browser.url, self.view_path + '/%s/index' % report.r_id) 1586 self.browser.url, self.view_path + '/%s' % report.r_id) 1587 self.assertTrue('John Referee' in self.browser.contents) 1544 1588 # Report creation is logged 1545 1589 logfile = os.path.join( … … 1547 1591 logcontent = open(logfile).read() 1548 1592 self.assertTrue( 1549 'zope. mgr- applicants.browser.RefereeReportAddFormPage - '1593 'zope.anybody - applicants.browser.RefereeReportAddFormPage - ' 1550 1594 '%s - added: %s\n' % (self.applicant.applicant_id, report.r_id) 1551 1595 in logcontent
Note: See TracChangeset for help on using the changeset viewer.