Ignore:
Timestamp:
18 Apr 2020, 16:42:14 (5 years ago)
Author:
Henrik Bettermann
Message:

Implement referee report slip. Show passport picture on referee pages.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/applicants
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py

    r16006 r16058  
    862862    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
    863863    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
    864     prefix = 'form'
     864    #prefix = 'form'
    865865    note = None
    866866
     
    903903    grok.name('application_slip.pdf')
    904904    grok.require('waeup.viewApplication')
    905     prefix = 'form'
     905    #prefix = 'form'
    906906
    907907    def update(self):
     
    12891289            if referee.email_sent:
    12901290                continue
    1291             mandate = RefereeReportMandate()
     1291            mandate = RefereeReportMandate(days=7)
    12921292            mandate.params['name'] = referee.name
    12931293            mandate.params['email'] = referee.email
     
    16821682    label = _('Referee Report')
    16831683    pnav = 3
     1684    form_fields = grok.AutoFields(IApplicantRefereeReport)
     1685    form_fields[
     1686        'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
    16841687
    16851688class RefereeReportAddFormPage(KofaAddFormPage):
     
    17141717            self.redirect(self.application_url())
    17151718            return
     1719        self.passport_url = self.url(self.context, 'passport.jpg')
    17161720        if mandate:
     1721            # Check the mandate expiration date after redirect again
     1722            if mandate.expires < datetime.utcnow():
     1723                self.flash(_('Mandate expired.'),
     1724                           type='warning')
     1725                self.redirect(self.application_url())
     1726                return
    17171727            # Prefill form with mandate params
    17181728            self.form_fields.get(
     
    17411751        return
    17421752
     1753class ExportPDFReportSlipPage(UtilityView, grok.View):
     1754    """Deliver a PDF slip of the context.
     1755    """
     1756    grok.context(IApplicantRefereeReport)
     1757    grok.name('referee_report_slip.pdf')
     1758    grok.require('waeup.manageApplication')
     1759    form_fields = grok.AutoFields(IApplicantRefereeReport)
     1760    form_fields[
     1761        'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
     1762    #prefix = 'form'
     1763    note = None
     1764
     1765    @property
     1766    def title(self):
     1767        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
     1768        return translate(_('Referee Report'), 'waeup.kofa',
     1769            target_language=portal_language)
     1770
     1771    @property
     1772    def label(self):
     1773        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
     1774        return translate(_('Referee Report Slip'),
     1775            'waeup.kofa', target_language=portal_language) \
     1776            + ' %s' % self.context.r_id
     1777
     1778    def render(self):
     1779        applicantview = ApplicantBaseDisplayFormPage(self.context.__parent__,
     1780            self.request)
     1781        students_utils = getUtility(IStudentsUtils)
     1782        return students_utils.renderPDF(self,'referee_report_slip.pdf',
     1783            self.context.__parent__, applicantview, note=self.note)
     1784
    17431785class AdditionalFile(grok.View):
    17441786    """Renders additional pdf files for applicants.
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser_templates/refereereportpage.pt

    r16056 r16058  
    1414  </strong>
    1515  of the <span i18n:name="app_title" tal:replace="layout/getAppTitle"></span>.
     16 
    1617  <br /><br />
    17   Please fill and submit the following form. After submission the form will
    18   be locked. You can neither view nor edit your report after submission.
     18
     19  <img tal:condition="python: context.__parent__.with_picture"
     20       src="" height="180px" tal:attributes="src view/passport_url" />
     21
     22  <br /><br />
     23
     24  Please fill and submit the following referee report form. After submission
     25  the form will be locked. You can neither view nor edit
     26  your report after submission.
    1927</p>
    2028
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/interfaces.py

    r15833 r16058  
    668668
    669669    creation_date = schema.Datetime(
    670         title = _(u'Ticket Creation Date'),
     670        title = _(u'Report Creation Date'),
    671671        readonly = False,
    672672        required = False,
     
    674674
    675675    name = schema.TextLine(
    676         title = _(u'Name'),
     676        title = _(u'Referee Name'),
    677677        required = True,
    678678        )
    679679
    680680    email = schema.ASCIILine(
    681         title = _(u'Email Address'),
     681        title = _(u'Referee Email Address'),
    682682        required = True,
    683683        constraint=validate_email,
     
    685685
    686686    phone = PhoneNumber(
    687         title = _(u'Phone'),
     687        title = _(u'Referee Phone'),
    688688        description = u'',
    689689        required = False,
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py

    r15943 r16058  
    3838from zope.testbrowser.testing import Browser
    3939from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
     40from waeup.kofa.browser.tests.test_pdf import samples_dir
    4041from waeup.kofa.testing import FunctionalLayer, FunctionalTestCase
    4142from waeup.kofa.app import University
     
    17231724            self.browser.url, self.view_path  + '/%s' % report.r_id)
    17241725        self.assertTrue('John Referee' in self.browser.contents)
     1726        # Managers can download a pdf slip
     1727        self.browser.getLink("Download report").click()
     1728        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     1729        self.assertEqual(self.browser.headers['Content-Type'],
     1730                         'application/pdf')
     1731        path = os.path.join(samples_dir(), 'referee_report_slip.pdf')
     1732        open(path, 'wb').write(self.browser.contents)
     1733        print "Sample PDF referee_report_slip.pdf written to %s" % path
    17251734        # Report creation is logged
    17261735        logfile = os.path.join(
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/viewlets.py

    r15843 r16058  
    2323from waeup.kofa.applicants.interfaces import (
    2424    IApplicant, IApplicantsRoot, IApplicantsContainer,
    25     IApplicantOnlinePayment
     25    IApplicantOnlinePayment, IApplicantRefereeReport
    2626    )
    2727from waeup.kofa.applicants.browser import (
    2828    ApplicantsRootPage, ApplicantsContainerPage, ApplicantManageFormPage,
    2929    ApplicantDisplayFormPage, OnlinePaymentDisplayFormPage,
    30     ApplicantsContainerManageFormPage, ApplicantsStatisticsPage
     30    ApplicantsContainerManageFormPage, ApplicantsStatisticsPage,
     31    RefereeReportDisplayFormPage
    3132    )
    3233
     
    285286        return self.view.url(self.view.context, self.target)
    286287
     288class ReportSlipActionButton(ManageActionButton):
     289    grok.order(1)
     290    grok.context(IApplicantRefereeReport)
     291    grok.view(RefereeReportDisplayFormPage)
     292    grok.require('waeup.manageApplication')
     293    icon = 'actionicon_pdf.png'
     294    text = _('Download report slip')
     295    target = 'referee_report_slip.pdf'
     296
     297    @property
     298    def target_url(self):
     299        return self.view.url(self.view.context, self.target)
     300
    287301class ApprovePaymentActionButton(ManageActionButton):
    288302    grok.order(8)
Note: See TracChangeset for help on using the changeset viewer.