- Timestamp:
- 23 Jun 2016, 05:08:41 (9 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/applicants
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py
r13950 r13976 23 23 import transaction 24 24 from datetime import datetime, date 25 from time import time 25 26 from zope.event import notify 26 27 from zope.component import getUtility, queryUtility, createObject, getAdapter … … 33 34 IApplicantsContainer, IApplicantsContainerAdd, 34 35 MAX_UPLOAD_SIZE, IApplicantOnlinePayment, IApplicantsUtils, 35 IApplicantRegisterUpdate, ISpecialApplicant 36 IApplicantRegisterUpdate, ISpecialApplicant, 37 IApplicantRefereeReport 36 38 ) 37 39 from waeup.kofa.utils.helpers import html2dict … … 284 286 return self.context.p_id 285 287 288 class RefereeReportBreadcrumb(Breadcrumb): 289 """A breadcrumb for referee reports. 290 """ 291 grok.context(IApplicantRefereeReport) 292 293 @property 294 def title(self): 295 return self.context.r_id 296 286 297 class ApplicantsStatisticsPage(KofaDisplayFormPage): 287 298 """Some statistics about applicants in a container. … … 900 911 return True 901 912 return getattr(self.context.__parent__, 'application_fee', None) 913 914 @property 915 def display_refereereports(self): 916 if self.context.refereereports: 917 return True 918 return False 902 919 903 920 @property … … 1059 1076 manage_applications = False 1060 1077 submit_state = PAID 1078 1079 @property 1080 def display_refereereports(self): 1081 return False 1061 1082 1062 1083 @property … … 1475 1496 grok.context(VirtualApplicantsExportJobContainer) 1476 1497 grok.require('waeup.manageApplication') 1498 1499 class RefereeReportDisplayFormPage(KofaDisplayFormPage): 1500 """A display view for referee reports. 1501 """ 1502 grok.context(IApplicantRefereeReport) 1503 grok.name('index') 1504 grok.require('waeup.manageApplication') 1505 label = _('Referee Report') 1506 pnav = 3 1507 1508 class RefereeReportAddFormPage(KofaAddFormPage): 1509 """Add-form to add an referee report. This form 1510 is protected by a mandate. (not yet ready) 1511 """ 1512 grok.context(IApplicant) 1513 grok.require('waeup.manageApplication') # XXX: Will be public 1514 grok.name('addrefereereport') 1515 form_fields = grok.AutoFields( 1516 IApplicantRefereeReport).omit('creation_date') 1517 label = _('Add referee report') 1518 pnav = 3 1519 #doclink = DOCLINK + '/refereereports.html' 1520 1521 def update(self): 1522 # XXX: Check mandate 1523 super(RefereeReportAddFormPage, self).update() 1524 return 1525 1526 @action(_('Submit'), 1527 warning=_('Are you really sure? ' 1528 'Reports can neither be modified or added ' 1529 'after submission.'), 1530 style='primary') 1531 def addRefereeReport(self, **data): 1532 report = createObject(u'waeup.ApplicantRefereeReport') 1533 timestamp = ("%d" % int(time()*10000))[1:] 1534 report.r_id = "r%s" % timestamp 1535 self.applyData(report, **data) 1536 self.context[report.r_id] = report 1537 self.flash(_('Referee report created.')) 1538 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 -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser_templates/applicanteditpage.pt
r13968 r13976 87 87 </div> 88 88 89 <tal:refereereports condition="view/display_refereereports"> 90 <br /><br /> 91 <h3 i18n:translate=""> 92 Referee Reports 93 </h3> 94 <table i18n:domain="waeup.kofa" class="table table-condensed"> 95 <thead> 96 <tr> 97 <th i18n:translate="">Report Id</th> 98 <th i18n:translate="">Creation Date</th> 99 <th i18n:translate="">Referee</th> 100 <th i18n:translate="">Email Address</th> 101 </tr> 102 </thead> 103 <tbody> 104 <tr tal:repeat="cl context/refereereports"> 105 <td> <a tal:attributes="href python:view.url(cl)"> 106 <span tal:content="cl/r_id">RID</span></a></td> 107 <td tal:content="python: layout.formatDatetime(cl.creation_date)">CREATION DATE</td> 108 <td tal:content="cl/name">REFEREE</td> 109 <td tal:content="cl/email">EMAIL</td> 110 </tr> 111 </tbody> 112 </table> 113 </tal:refereereports> 114 89 115 <tal:payments condition="view/display_payments"> 90 116 <br /><br /> … … 107 133 <tbody> 108 134 <tr tal:repeat="cl context/payments"> 109 <td> 110 <input type="checkbox" 111 name="val_id" 112 tal:attributes="value cl/__name__" 135 <td> 136 <input type="checkbox" name="val_id" 137 tal:attributes="value cl/__name__" 113 138 tal:condition="python: not view.unremovable(cl)" /> 114 139 </td> … … 117 142 <td tal:content="python: layout.formatDatetime(cl.creation_date)">CREATION DATE</td> 118 143 <td tal:content="python: layout.formatDatetime(cl.payment_date)">PAYMENT DATE</td> 119 <td tal:content ="cl/category">CATEGORY</td>120 <td tal:content ="cl/display_item">ITEM</td>121 <td tal:content ="cl/p_state_title">STATE</td>144 <td tal:content ="cl/category">CATEGORY</td> 145 <td tal:content ="cl/display_item">ITEM</td> 146 <td tal:content ="cl/p_state_title">STATE</td> 122 147 </tr> 123 148 </tbody> -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/interfaces.py
r13975 r13976 635 635 r_id = Attribute('Report identifier') 636 636 637 creation_date = schema.Datetime( 638 title = _(u'Ticket Creation Date'), 639 readonly = False, 640 required = False, 641 ) 642 637 643 name = schema.TextLine( 638 644 title = _(u'Name'), … … 642 648 email = schema.ASCIILine( 643 649 title = _(u'Email Address'), 644 required = False,650 required = True, 645 651 constraint=validate_email, 646 652 ) … … 656 662 required = False, 657 663 ) 658 659 creation_date = schema.Datetime(660 title = _(u'Ticket Creation Date'),661 readonly = False,662 required = False,663 ) -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py
r13968 r13976 1519 1519 '- discarded: job_id=%s' % job_ids[1] in logcontent 1520 1520 ) 1521 1522 class ApplicantRefereeReportTests(ApplicantsFullSetup, FunctionalAsyncTestCase): 1523 # Tests for ApplicantRefereeReport class views and pages 1524 1525 layer = FunctionalLayer 1526 1527 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' 1537 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 1540 self.assertEqual(len(self.applicant.refereereports), 1) 1541 report = self.applicant.refereereports[0] 1542 self.assertEqual( 1543 self.browser.url, self.view_path + '/%s/index' % report.r_id) 1544 # Report creation is logged 1545 logfile = os.path.join( 1546 self.app['datacenter'].storage, 'logs', 'applicants.log') 1547 logcontent = open(logfile).read() 1548 self.assertTrue( 1549 'zope.mgr - applicants.browser.RefereeReportAddFormPage - ' 1550 '%s - added: %s\n' % (self.applicant.applicant_id, report.r_id) 1551 in logcontent 1552 )
Note: See TracChangeset for help on using the changeset viewer.