Changeset 14661 for main/waeup.aaue
- Timestamp:
- 30 Mar 2017, 07:51:15 (8 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
r14650 r14661 126 126 'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le') 127 127 128 129 class ExportExaminationScheduleSlip(UtilityView, grok.View): 130 """Deliver a examination schedule slip. 131 132 This form page is available only in Uniben and AAUE. 133 """ 134 grok.context(ICustomStudent) 135 grok.name('examination_schedule_slip.pdf') 136 grok.require('waeup.viewStudent') 137 prefix = 'form' 138 139 label = u'Examination Schedule Slip' 140 141 omit_fields = ( 142 'suspended', 'phone', 'email', 143 'adm_code', 'suspended_comment', 144 'date_of_birth', 'current_level', 145 'current_mode', 146 'entry_session', 147 'flash_notice') 148 149 form_fields = [] 150 151 @property 152 def note(self): 153 return """ 154 <br /><br /><br /><br /><font size='12'> 155 Your examination date, time and venue is scheduled as follows: 156 <br /><br /> 157 <strong>%s</strong> 158 </font> 159 160 """ % self.context.flash_notice 161 return 162 163 164 def update(self): 165 if not self.context.flash_notice \ 166 or not 'exam' in self.context.flash_notice.lower(): 167 self.flash(_('Forbidden'), type="warning") 168 self.redirect(self.url(self.context)) 169 170 def render(self): 171 studentview = StudentBasePDFFormPage(self.context.student, 172 self.request, self.omit_fields) 173 students_utils = getUtility(IStudentsUtils) 174 return students_utils.renderPDF( 175 self, 'examination_schedule_slip', 176 self.context.student, studentview, 177 omit_fields=self.omit_fields, 178 note=self.note) 179 128 180 class CustomStudentClearanceDisplayFormPage(NigeriaStudentClearanceDisplayFormPage): 129 181 """ Page to display student clearance data -
main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py
r14613 r14661 1240 1240 '...Successfully added COURSE2...', self.browser.contents) 1241 1241 return 1242 1243 def test_examination_schedule_slip(self): 1244 self.student.flash_notice = u'My Examination Date' 1245 self.browser.open(self.login_path) 1246 self.browser.getControl(name="form.login").value = self.student_id 1247 self.browser.getControl(name="form.password").value = 'spwd' 1248 self.browser.getControl("Login").click() 1249 self.browser.getLink("Download examination schedule slip").click() 1250 self.assertEqual(self.browser.headers['Status'], '200 Ok') 1251 self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf') 1252 path = os.path.join(samples_dir(), 'examination_schedule_slip.pdf') 1253 open(path, 'wb').write(self.browser.contents) 1254 print "Sample PDF examination_schedule_slip.pdf written to %s" % path 1255 # If flash_notive does not contain exam' the button does not show up. 1256 self.student.flash_notice = u'anything' 1257 self.browser.open(self.student_path) 1258 self.assertFalse('examination schedule slip' in self.browser.contents) -
main/waeup.aaue/trunk/src/waeup/aaue/students/viewlets.py
r14544 r14661 104 104 return self.view.url(self.view.context, self.target) 105 105 106 class ExaminationScheduleSlipActionButton(ManageActionButton): 107 grok.order(10) 108 grok.context(ICustomStudent) 109 grok.view(StudentBaseDisplayFormPage) 110 grok.require('waeup.viewStudent') 111 icon = 'actionicon_pdf.png' 112 text = _('Download examination schedule slip') 113 target = 'examination_schedule_slip.pdf' 114 115 @property 116 def target_url(self): 117 if self.context.flash_notice \ 118 and 'exam' in self.context.flash_notice.lower(): 119 return self.view.url(self.view.context, self.target) 120 return False 121 106 122 class PersonalDataSlipActionButton(ManageActionButton): 107 123 grok.order(3)
Note: See TracChangeset for help on using the changeset viewer.