Changeset 16243 for main/waeup.kofa/trunk/src/waeup/kofa/applicants
- Timestamp:
- 23 Sep 2020, 19:42:07 (4 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
r16231 r16243 1862 1862 'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') 1863 1863 1864 class 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 1864 1889 class RemoveRefereeReportPage(UtilityView, grok.View): 1865 1890 """ … … 1941 1966 'name').field.default = mandate.params['name'] 1942 1967 self.form_fields.get( 1943 'email ').field.default = mandate.params['email']1968 'email_pref').field.default = mandate.params['email'] 1944 1969 self.passport_url = self.url( 1945 1970 self.context, 'passport_for_report.jpg') + '?%s' % urlencode(args) … … 1956 1981 timestamp = ("%d" % int(time()*10000))[1:] 1957 1982 report.r_id = "r%s" % timestamp 1983 report.email = self.mandates[self.mandate_id].params['email'] 1958 1984 self.applyData(report, **data) 1959 1985 self.context[report.r_id] = report -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/interfaces.py
r16228 r16243 673 673 674 674 r_id = Attribute('Report identifier') 675 email = Attribute('Referee email address taken from the mandate') 675 676 676 677 creation_date = schema.Datetime( … … 685 686 ) 686 687 687 email = schema.ASCIILine(688 title = _(u' RefereeEmail 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, 692 693 ) 693 694 -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/refereereport.py
r13975 r16243 42 42 self.r_id = None 43 43 self.creation_date = datetime.utcnow() 44 self.email = None 44 45 return 45 46 -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py
r16231 r16243 25 25 import grok 26 26 import logging 27 from datetime import datetime28 27 from StringIO import StringIO 29 28 from datetime import datetime, date, timedelta … … 1805 1804 return 1806 1805 1807 def test_add_and_view_ reports(self):1806 def test_add_and_view_manage_reports(self): 1808 1807 mandate = RefereeReportMandate() 1809 1808 mandate.params['name'] = u'John Referee' … … 1844 1843 self.assertEqual(len(self.applicant.refereereports), 1) 1845 1844 report = self.applicant.refereereports[0] 1845 # The email address has been stored 1846 self.assertEqual(report.email, 'aa@aa.aa') 1846 1847 # Referee can use mandate again to download the pdf report 1847 1848 self.browser.open('http://localhost/app/mandate?mandate_id=%s' … … 1875 1876 self.assertEqual(self.browser.headers['Content-Type'], 1876 1877 '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" % path1880 1878 # Mandate is not deleted ... 1881 1879 self.assertEqual(len(self.app['mandates'].keys()), 2) … … 1888 1886 self.app['mandates'][mandate.mandate_id].params['redirect_path2'], 1889 1887 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') 1890 1893 # Managers can delete referee reports 1891 1894 self.browser.open(self.manage_path) … … 1896 1899 self.assertTrue('Referee report removed.' in self.browser.contents) 1897 1900 self.assertEqual(self.browser.url, self.view_path) 1898 # Report creation and deletion is logged1901 # Report creation, managing and deletion is logged 1899 1902 logfile = os.path.join( 1900 1903 self.app['datacenter'].storage, 'logs', 'applicants.log') … … 1904 1907 '%s - added: %s\n' % (self.applicant.applicant_id, report.r_id) 1905 1908 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) 1906 1913 self.assertTrue( 1907 1914 'zope.mgr - applicants.browser.RemoveRefereeReportPage - '
Note: See TracChangeset for help on using the changeset viewer.