Ignore:
Timestamp:
23 Jun 2016, 05:08:41 (8 years ago)
Author:
Henrik Bettermann
Message:

Add first refereereports browser components.

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  
    2323import transaction
    2424from datetime import datetime, date
     25from time import time
    2526from zope.event import notify
    2627from zope.component import getUtility, queryUtility, createObject, getAdapter
     
    3334    IApplicantsContainer, IApplicantsContainerAdd,
    3435    MAX_UPLOAD_SIZE, IApplicantOnlinePayment, IApplicantsUtils,
    35     IApplicantRegisterUpdate, ISpecialApplicant
     36    IApplicantRegisterUpdate, ISpecialApplicant,
     37    IApplicantRefereeReport
    3638    )
    3739from waeup.kofa.utils.helpers import html2dict
     
    284286        return self.context.p_id
    285287
     288class 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
    286297class ApplicantsStatisticsPage(KofaDisplayFormPage):
    287298    """Some statistics about applicants in a container.
     
    900911            return True
    901912        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
    902919
    903920    @property
     
    10591076    manage_applications = False
    10601077    submit_state = PAID
     1078
     1079    @property
     1080    def display_refereereports(self):
     1081        return False
    10611082
    10621083    @property
     
    14751496    grok.context(VirtualApplicantsExportJobContainer)
    14761497    grok.require('waeup.manageApplication')
     1498
     1499class 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
     1508class 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  
    8787  </div>
    8888
     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
    89115  <tal:payments condition="view/display_payments">
    90116    <br /><br />
     
    107133      <tbody>
    108134        <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__"
    113138           tal:condition="python: not view.unremovable(cl)" />
    114139          </td>
     
    117142          <td tal:content="python: layout.formatDatetime(cl.creation_date)">CREATION DATE</td>
    118143          <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>
    122147        </tr>
    123148      </tbody>
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/interfaces.py

    r13975 r13976  
    635635    r_id = Attribute('Report identifier')
    636636
     637    creation_date = schema.Datetime(
     638        title = _(u'Ticket Creation Date'),
     639        readonly = False,
     640        required = False,
     641        )
     642
    637643    name = schema.TextLine(
    638644        title = _(u'Name'),
     
    642648    email = schema.ASCIILine(
    643649        title = _(u'Email Address'),
    644         required = False,
     650        required = True,
    645651        constraint=validate_email,
    646652        )
     
    656662        required = False,
    657663        )
    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  
    15191519            '- discarded: job_id=%s' % job_ids[1] in logcontent
    15201520            )
     1521
     1522class 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.