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

Save email address provided by mandate when referee report
is created. Add RefereeReportManageFormPage (no button available).

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

    r16231 r16243  
    18621862        'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
    18631863
     1864class RefereeReportManageFormPage(KofaEditFormPage):
     1865    """A displaymanage for referee reports.
     1866    """
     1867    grok.context(IApplicantRefereeReport)
     1868    grok.name('manage')
     1869    grok.require('waeup.managePortal')
     1870    label = _('Manage Referee Report')
     1871    pnav = 3
     1872    form_fields = grok.AutoFields(IApplicantRefereeReport).omit('creation_date')
     1873
     1874    @action(_('Save'), style='primary')
     1875    def save(self, **data):
     1876        changed_fields = self.applyData(self.context, **data)
     1877        # Turn list of lists into single list
     1878        if changed_fields:
     1879            changed_fields = reduce(lambda x,y: x+y, changed_fields.values())
     1880        else:
     1881            changed_fields = []
     1882        fields_string = ' + '.join(changed_fields)
     1883        self.flash(_('Form has been saved.'))
     1884        if fields_string:
     1885            self.context.__parent__.writeLogMessage(
     1886                self, '%s - saved: %s' % (self.context.r_id, fields_string))
     1887        return
     1888
    18641889class RemoveRefereeReportPage(UtilityView, grok.View):
    18651890    """
     
    19411966                'name').field.default = mandate.params['name']
    19421967            self.form_fields.get(
    1943                 'email').field.default = mandate.params['email']
     1968                'email_pref').field.default = mandate.params['email']
    19441969            self.passport_url = self.url(
    19451970                self.context, 'passport_for_report.jpg') + '?%s' % urlencode(args)
     
    19561981        timestamp = ("%d" % int(time()*10000))[1:]
    19571982        report.r_id = "r%s" % timestamp
     1983        report.email = self.mandates[self.mandate_id].params['email']
    19581984        self.applyData(report, **data)
    19591985        self.context[report.r_id] = report
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/interfaces.py

    r16228 r16243  
    673673
    674674    r_id = Attribute('Report identifier')
     675    email = Attribute('Referee email address taken from the mandate')
    675676
    676677    creation_date = schema.Datetime(
     
    685686        )
    686687
    687     email = schema.ASCIILine(
    688         title = _(u'Referee Email Address'),
    689         #required = True,
    690         #constraint=validate_email,
    691         readonly = True,
     688    email_pref = schema.ASCIILine(
     689        title = _(u'Preferred Email Address'),
     690        required = False,
     691        constraint=validate_email,
     692        readonly = False,
    692693        )
    693694
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/refereereport.py

    r13975 r16243  
    4242        self.r_id = None
    4343        self.creation_date = datetime.utcnow()
     44        self.email = None
    4445        return
    4546
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py

    r16231 r16243  
    2525import grok
    2626import logging
    27 from datetime import datetime
    2827from StringIO import StringIO
    2928from datetime import datetime, date, timedelta
     
    18051804        return
    18061805
    1807     def test_add_and_view_reports(self):
     1806    def test_add_and_view_manage_reports(self):
    18081807        mandate = RefereeReportMandate()
    18091808        mandate.params['name'] = u'John Referee'
     
    18441843        self.assertEqual(len(self.applicant.refereereports), 1)
    18451844        report = self.applicant.refereereports[0]
     1845        # The email address has been stored
     1846        self.assertEqual(report.email, 'aa@aa.aa')
    18461847        # Referee can use mandate again to download the pdf report
    18471848        self.browser.open('http://localhost/app/mandate?mandate_id=%s'
     
    18751876        self.assertEqual(self.browser.headers['Content-Type'],
    18761877                         'application/pdf')
    1877         path = os.path.join(samples_dir(), 'referee_report_slip.pdf')
    1878         open(path, 'wb').write(self.browser.contents)
    1879         print "Sample PDF referee_report_slip.pdf written to %s" % path
    18801878        # Mandate is not deleted ...
    18811879        self.assertEqual(len(self.app['mandates'].keys()), 2)
     
    18881886            self.app['mandates'][mandate.mandate_id].params['redirect_path2'],
    18891887            redirect_path2)
     1888        # Portal managers can edit referee reports (no button available!)
     1889        self.browser.open(self.view_path + '/%s/manage' % report.r_id)
     1890        self.browser.getControl(name="form.email_pref").value = 'bb@bb.de'
     1891        self.browser.getControl("Save").click()
     1892        self.assertEqual(report.email_pref, 'bb@bb.de')
    18901893        # Managers can delete referee reports
    18911894        self.browser.open(self.manage_path)
     
    18961899        self.assertTrue('Referee report removed.' in self.browser.contents)
    18971900        self.assertEqual(self.browser.url, self.view_path)
    1898         # Report creation and deletion is logged
     1901        # Report creation, managing and deletion is logged
    18991902        logfile = os.path.join(
    19001903            self.app['datacenter'].storage, 'logs', 'applicants.log')
     
    19041907            '%s - added: %s\n' % (self.applicant.applicant_id, report.r_id)
    19051908            in logcontent)
     1909        self.assertTrue(
     1910            'zope.mgr - applicants.browser.RefereeReportManageFormPage - '
     1911            '%s - %s - saved: email_pref\n' % (
     1912            self.applicant.applicant_id, report.r_id) in logcontent)
    19061913        self.assertTrue(
    19071914            'zope.mgr - applicants.browser.RemoveRefereeReportPage - '
Note: See TracChangeset for help on using the changeset viewer.