Changeset 15371 for main/waeup.uniben/trunk
- Timestamp:
- 25 Mar 2019, 17:59:03 (6 years ago)
- Location:
- main/waeup.uniben/trunk/src/waeup/uniben
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.uniben/trunk/src/waeup/uniben/permissions.py
r15366 r15371 23 23 24 24 class ClearLibrary(grok.Permission): 25 grok.name('waeup. clearForLibrary')25 grok.name('waeup.switchLibraryAccess') 26 26 27 27 class PassportPictureManager(grok.Role): … … 37 37 grok.permissions('waeup.showStudents', 38 38 'waeup.viewAcademics', 39 'waeup. clearForLibrary')39 'waeup.switchLibraryAccess') 40 40 41 41 class CRPUOfficer(CCOfficer): -
main/waeup.uniben/trunk/src/waeup/uniben/students/browser.py
r15352 r15371 52 52 NigeriaStudentPersonalManageFormPage, 53 53 NigeriaStudentPersonalEditFormPage, 54 NigeriaAccommodationManageFormPage 54 NigeriaAccommodationManageFormPage, 55 NigeriaStudentBaseDisplayFormPage, 55 56 ) 56 57 … … 66 67 ICustomStudentPersonalEdit) 67 68 from waeup.uniben.interfaces import MessageFactory as _ 69 70 class CustomStudentBaseDisplayFormPage(NigeriaStudentBaseDisplayFormPage): 71 """ Page to display student base data 72 """ 73 form_fields = grok.AutoFields(ICustomStudentBase).omit( 74 'password', 'suspended', 'suspended_comment', 75 'flash_notice', 'provisionally_cleared') 76 form_fields[ 77 'financial_clearance_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') 78 79 #class CustomStudentBaseManageFormPage(NigeriaStudentBaseManageFormPage): 80 # """ View to manage student base data 81 # """ 82 # form_fields = grok.AutoFields(ICustomStudentBase).omit( 83 # 'student_id', 'adm_code', 'suspended', 84 # 'financially_cleared_by', 'financial_clearance_date') 68 85 69 86 class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage): … … 286 303 note=self.note) 287 304 305 class SwitchLibraryAccessView(UtilityView, grok.View): 306 """ Switch the library attribute 307 """ 308 grok.context(ICustomStudent) 309 grok.name('switch_library_access') 310 grok.require('waeup.switchLibraryAccess') 311 312 def update(self): 313 if self.context.library: 314 self.context.library = False 315 self.context.writeLogMessage(self, 'library access disabled') 316 self.flash(_('Library access disabled')) 317 else: 318 self.context.library = True 319 self.context.writeLogMessage(self, 'library access enabled') 320 self.flash(_('Library access enabled')) 321 self.redirect(self.url(self.context)) 322 return 323 324 def render(self): 325 return 326 288 327 class ExportJHLIdCard(UtilityView, grok.View): 289 """Deliver a an id card for the John Harris Library.328 """Deliver an id card for the John Harris Library. 290 329 """ 291 330 grok.context(ICustomStudent) … … 297 336 298 337 omit_fields = ( 299 'suspended', 'email', 338 'suspended', 'email', 'phone', 300 339 'adm_code', 'suspended_comment', 301 'date_of_birth', 'reg_number',340 'date_of_birth', 302 341 'current_mode', 'certificate', 303 342 'entry_session', … … 306 345 form_fields = [] 307 346 308 def _signatures(self):309 return ([(310 'Current HD<br /> D. R. (Exams & Records)<br /> '311 'For: Registrar')],)312 313 347 def _sigsInFooter(self): 348 isStudent = getattr( 349 self.request.principal, 'user_type', None) == 'student' 350 if isStudent: 351 return '' 314 352 return (_("Date, Reader's Signature"), 315 353 _("Date, Circulation Librarian's Signature"), 316 354 ) 355 356 def update(self): 357 if not self.context.library: 358 self.flash(_('Forbidden!'), type="danger") 359 self.redirect(self.url(self.context)) 360 return 317 361 318 362 @property -
main/waeup.uniben/trunk/src/waeup/uniben/students/interfaces.py
r14854 r15371 33 33 """Representation of student base data. 34 34 """ 35 36 library = schema.Bool( 37 title = _(u'Library Id Card'), 38 default = False, 39 required = False, 40 ) 35 41 36 42 class ICustomStudentPersonal(INigeriaStudentPersonal): -
main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py
r15352 r15371 41 41 IExtFileStore, IFileStoreNameChooser) 42 42 from waeup.kofa.students.interfaces import IStudentsUtils 43 from waeup.kofa.tests.test_authentication import SECRET 43 44 from waeup.uniben.testing import FunctionalLayer 44 45 45 46 SAMPLE_FPM = os.path.join(os.path.dirname(__file__), 'sample.fpm') 47 48 class OfficerUITests(StudentsFullSetup): 49 # Tests for Student class views and pages 50 51 layer = FunctionalLayer 52 53 def test_jhl_idcard_officer(self): 54 # Create library officer 55 self.app['users'].addUser('mrlibrary', SECRET) 56 self.app['users']['mrlibrary'].email = 'library@foo.ng' 57 self.app['users']['mrlibrary'].title = 'Carlo Pitter' 58 prmglobal = IPrincipalRoleManager(self.app) 59 prmglobal.assignRoleToPrincipal( 60 'waeup.LibraryClearanceOfficer', 'mrlibrary') 61 prmglobal.assignRoleToPrincipal( 62 'waeup.StudentsOfficer', 'mrlibrary') 63 self.browser.open(self.login_path) 64 self.browser.getControl(name="form.login").value = 'mrlibrary' 65 self.browser.getControl(name="form.password").value = SECRET 66 self.browser.getControl("Login").click() 67 self.assertMatches('...You logged in...', self.browser.contents) 68 self.browser.open(self.student_path) 69 self.assertFalse('JHL' in self.browser.contents) 70 self.browser.getLink("Switch library access").click() 71 self.assertTrue('Library access enabled' in self.browser.contents) 72 self.assertTrue('JHL' in self.browser.contents) 73 self.browser.getLink("Download JHL Id Card").click() 74 self.assertEqual(self.browser.headers['Status'], '200 Ok') 75 self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf') 76 path = os.path.join(samples_dir(), 'jhl_idcard_officer.pdf') 77 open(path, 'wb').write(self.browser.contents) 78 print "Sample PDF jhl_idcard_officer.pdf written to %s" % path 46 79 47 80 class StudentUITests(StudentsFullSetup): … … 219 252 self.browser.getControl(name="form.password").value = 'spwd' 220 253 self.browser.getControl("Login").click() 254 self.assertFalse('JHL' in self.browser.contents) 255 self.student.library = True 256 self.browser.open(self.student_path) 257 self.assertTrue('JHL' in self.browser.contents) 221 258 self.browser.getLink("Download JHL Id Card").click() 222 259 self.assertEqual(self.browser.headers['Status'], '200 Ok') 223 260 self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf') 224 path = os.path.join(samples_dir(), 'jhl_idcard .pdf')261 path = os.path.join(samples_dir(), 'jhl_idcard_student.pdf') 225 262 open(path, 'wb').write(self.browser.contents) 226 print "Sample PDF jhl_idcard .pdf written to %s" % path263 print "Sample PDF jhl_idcard_student.pdf written to %s" % path 227 264 228 265 def test_jupeb_result_slip(self): -
main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_export.py
r14853 r15371 56 56 'fst_sit_type,hq2_degree,hq2_disc,hq2_matric_no,hq2_school,' 57 57 'hq2_session,hq2_type,hq_degree,hq_disc,hq_fname,hq_matric_no,' 58 'hq_school,hq_session,hq_type,is_staff,lastname,lga, '58 'hq_school,hq_session,hq_type,is_staff,lastname,lga,library,' 59 59 'marit_stat,matric_number,middlename,nationality,' 60 60 'next_kin_address,next_kin_name,next_kin_phone,next_kin_relation,' … … 68 68 '"[(\'printing_craft_practice\', \'A1\')]",my clr code,1981-02-04#,,,' 69 69 'anna@sample.com,,,,,,,,,,,,,Anna,,,,,,"[(\'printing_craft_practice\', \'A1\')]"' 70 ',,,,,,,,,,,,,,,,Tester,,, 234,M.,NG,,,,,,,,,,'70 ',,,,,,,,,,,,,,,,Tester,,,,234,M.,NG,,,,,,,,,,' 71 71 '"Studentroad 21\nLagos 123456\n",,+234-123-12345#,,,123,,,,,' 72 72 '"[(\'printing_craft_practice\', \'A1\')]",,f,A111111,0,,,created,' -
main/waeup.uniben/trunk/src/waeup/uniben/students/viewlets.py
r15354 r15371 32 32 from kofacustom.nigeria.interfaces import MessageFactory as _ 33 33 34 class SwitchLibraryAccessActionButton(ManageActionButton): 35 grok.order(7) 36 grok.context(ICustomStudent) 37 grok.view(StudentBaseDisplayFormPage) 38 grok.require('waeup.switchLibraryAccess') 39 text = _('Switch library access') 40 target = 'switch_library_access' 41 icon = 'actionicon_book.png' 42 34 43 class StudyCourseEditActionButton(ManageActionButton): 35 44 grok.order(1) … … 122 131 @property 123 132 def target_url(self): 124 # temporarily disabled125 return ''126 return self.view.url(self.view.context, self.target)133 if self.context.library: 134 return self.view.url(self.view.context, self.target) 135 return 127 136 128 137 class JUPEBResultSlipActionButton(ManageActionButton):
Note: See TracChangeset for help on using the changeset viewer.