Changeset 11607 for main/waeup.aaue/trunk/src/waeup/aaue/students
- Timestamp:
- 30 Apr 2014, 05:30:32 (11 years ago)
- Location:
- main/waeup.aaue/trunk/src/waeup/aaue/students
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.aaue/trunk/src/waeup/aaue/students/browser.py
r11606 r11607 23 23 from waeup.kofa.interfaces import IKofaUtils 24 24 from waeup.kofa.students.interfaces import IStudentsUtils, IStudent 25 from waeup.kofa.students.workflow import PAID 25 26 from waeup.kofa.students.browser import ( 26 27 StudentBasePDFFormPage, … … 39 40 from waeup.aaue.students.interfaces import ( 40 41 ICustomStudentOnlinePayment, 41 ICustomStudentStudyLevel) 42 ICustomStudentStudyLevel, 43 ICustomStudent) 42 44 from waeup.aaue.interfaces import MessageFactory as _ 43 45 … … 222 224 def render(self): 223 225 return 226 227 class ExportPDFMatricNumberSlipPage(UtilityView, grok.View): 228 """Deliver a PDF notification slip. 229 """ 230 grok.context(ICustomStudent) 231 grok.name('matric_number_slip.pdf') 232 grok.require('waeup.viewStudent') 233 prefix = 'form' 234 235 form_fields = grok.AutoFields(ICustomStudent).select( 236 'student_id', 'matric_number') 237 omit_fields = ('date_of_birth', 'current_level') 238 239 @property 240 def label(self): 241 portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE 242 return translate(_('Matriculation Number Slip\n'), 243 'waeup.kofa', target_language=portal_language) \ 244 + ' %s' % self.context.display_fullname 245 246 def render(self): 247 if self.context.state not in (PAID,) or not self.context.is_fresh \ 248 or not self.context.matric_number: 249 self.flash('Not allowed.', type="danger") 250 self.redirect(self.url(self.context)) 251 return 252 students_utils = getUtility(IStudentsUtils) 253 pre_text = _('Congratulations! Your acceptance and school fee payments ' + 254 'have been received and your matriculation number ' + 255 'generated with details as follows:') 256 return students_utils.renderPDFAdmissionLetter(self, 257 self.context.student, omit_fields=self.omit_fields, 258 pre_text=pre_text, post_text='') -
main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py
r11605 r11607 28 28 from waeup.kofa.students.accommodation import BedTicket 29 29 from waeup.kofa.testing import FunctionalTestCase 30 from waeup.kofa.browser.tests.test_pdf import samples_dir 30 31 from waeup.aaue.testing import FunctionalLayer 31 32 … … 351 352 self.student['studycourse'].certificate.study_mode = 'ug_pt' 352 353 self.browser.open(self.student_path) 354 self.assertRaises( 355 LinkNotFoundError, 356 self.browser.getLink, 'Download matriculation number slip') 353 357 self.browser.getLink("Get Matriculation Number").click() 354 358 self.assertTrue('Matriculation number PTP/fac1/dep1/04/00001 assigned.' … … 364 368 self.assertTrue('E1000000 - waeup.aaue.students.browser.StudentGetMatricNumberPage - ' 365 369 'E1000000 - PTP/fac1/dep1/04/00001 assigned' in logcontent) 366 return 367 370 # Matric Number Slip can be downloaded 371 self.browser.getLink("Download matriculation number slip").click() 372 self.assertEqual(self.browser.headers['Status'], '200 Ok') 373 self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf') 374 path = os.path.join(samples_dir(), 'transcript.pdf') 375 open(path, 'wb').write(self.browser.contents) 376 print "Sample PDF matric_number_slip.pdf written to %s" % path 377 return 378 -
main/waeup.aaue/trunk/src/waeup/aaue/students/viewlets.py
r11603 r11607 20 20 from zope.component import getUtility 21 21 from waeup.kofa.students.interfaces import IStudent, IStudentsUtils 22 from waeup.kofa.students.workflow import PAID 22 23 from waeup.kofa.students.viewlets import ( 23 24 AddPreviousPaymentActionButton, AddBalancePaymentActionButton, … … 56 57 return '' 57 58 return self.view.url(self.view.context, 'get_matric_number') 59 60 class MatricNumberSlipActionButton(ManageActionButton): 61 grok.order(10) 62 grok.context(IStudent) 63 grok.view(StudentBaseDisplayFormPage) 64 grok.require('waeup.viewStudent') 65 icon = 'actionicon_pdf.png' 66 text = _('Download matriculation number slip') 67 target = 'matric_number_slip.pdf' 68 69 @property 70 def target_url(self): 71 if self.context.state not in (PAID,) or not self.context.is_fresh \ 72 or not self.context.matric_number: 73 return '' 74 return self.view.url(self.view.context, self.target)
Note: See TracChangeset for help on using the changeset viewer.