Changeset 11736 for main/waeup.uniben/trunk/src/waeup/uniben
- Timestamp:
- 5 Jul 2014, 12:21:13 (10 years ago)
- Location:
- main/waeup.uniben/trunk/src/waeup/uniben
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.uniben/trunk/src/waeup/uniben/applicants/browser.py
r11728 r11736 20 20 import grok 21 21 from zope.component import getUtility 22 from zope.security import checkPermission 22 23 from waeup.kofa.interfaces import IExtFileStore 23 24 from waeup.kofa.applicants.browser import ( … … 26 27 from kofacustom.nigeria.applicants.browser import ( 27 28 NigeriaApplicantDisplayFormPage, 29 NigeriaApplicantManageFormPage, 28 30 NigeriaPDFApplicationSlip) 29 31 … … 127 129 return '' 128 130 131 132 class ApplicantManageFormPage(NigeriaApplicantManageFormPage): 133 134 @property 135 def custom_upload_requirements(self): 136 if not checkPermission('waeup.uploadPassportPictures', self.context): 137 return _('You are not entitled to upload passport pictures.') -
main/waeup.uniben/trunk/src/waeup/uniben/applicants/tests/test_browser.py
r10589 r11736 19 19 Test the applicant-related UI components. 20 20 """ 21 from StringIO import StringIO 22 from zope.securitypolicy.interfaces import IPrincipalRoleManager 21 23 from waeup.uniben.testing import FunctionalLayer 22 from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup 24 from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup, PH_LEN 23 25 24 26 class CustomApplicantUITests(ApplicantsFullSetup): … … 47 49 return 48 50 51 def image_url(self, filename): 52 return self.edit_path.replace('edit', filename) 53 54 def test_upload_passport_wo_permission(self): 55 # Create CRPU officer 56 self.app['users'].addUser('mrcrpu', 'mrcrpusecret') 57 self.app['users']['mrcrpu'].email = 'mrcrpu@foo.ng' 58 self.app['users']['mrcrpu'].title = 'Carlo Pitter' 59 prmglobal = IPrincipalRoleManager(self.app) 60 prmglobal.assignRoleToPrincipal('waeup.CCOfficer', 'mrcrpu') 61 # Login as CRPU officer 62 self.browser.open(self.login_path) 63 self.browser.getControl(name="form.login").value = 'mrcrpu' 64 self.browser.getControl(name="form.password").value = 'mrcrpusecret' 65 self.browser.getControl("Login").click() 66 self.assertMatches('...You logged in...', self.browser.contents) 67 # Let's try to change the passport image 68 self.browser.open(self.manage_path) 69 self.fill_correct_values() 70 # Create a pseudo image file and select it to be uploaded in form 71 pseudo_image = StringIO('I pretend to be a graphics file') 72 ctrl = self.browser.getControl(name='form.passport') 73 file_ctrl = ctrl.mech_control 74 file_ctrl.add_file(pseudo_image, filename='myphoto.jpg') 75 self.browser.getControl("Save").click() 76 self.assertMatches('...You are not entitled to upload passport pictures...', 77 self.browser.contents) 78 # The officer still sees the placeholder passport image 79 self.browser.open(self.image_url('passport.jpg')) 80 self.assertEqual( 81 self.browser.headers['content-type'], 'image/jpeg') 82 self.assertEqual(len(self.browser.contents), PH_LEN) 83 # After adding the additional role ... 84 prmglobal.assignRoleToPrincipal('waeup.PassportPictureManager', 'mrcrpu') 85 # ... passport pictures can be uploaded 86 self.browser.open(self.manage_path) 87 self.fill_correct_values() 88 pseudo_image = StringIO('I pretend to be a graphics file') 89 ctrl = self.browser.getControl(name='form.passport') 90 file_ctrl = ctrl.mech_control 91 file_ctrl.add_file(pseudo_image, filename='myphoto.jpg') 92 self.browser.getControl("Save").click() 93 self.assertMatches('...Form has been saved...', self.browser.contents) 94 # There is a correct <img> link included 95 self.assertTrue( 96 '<img src="passport.jpg" height="180px" />' in self.browser.contents) 97 # Browsing the link shows a real image 98 self.browser.open(self.image_url('passport.jpg')) 99 self.assertEqual( 100 self.browser.headers['content-type'], 'image/jpeg') 101 self.assertEqual(len(self.browser.contents), 31) -
main/waeup.uniben/trunk/src/waeup/uniben/permissions.py
r9488 r11736 19 19 from waeup.kofa.permissions import CCOfficer 20 20 21 class UploadPassportPictures(grok.Permission): 22 grok.name('waeup.uploadPassportPictures') 23 24 class PassportPictureManager(grok.Role): 25 grok.name('waeup.PassportPictureManager') 26 grok.title(u'Passport Picture Manager') 27 grok.permissions('waeup.uploadPassportPictures') 21 28 22 29 class CRPUOfficer(CCOfficer):
Note: See TracChangeset for help on using the changeset viewer.