Changeset 7122 for main/waeup.sirp/trunk/src/waeup/sirp
- Timestamp:
- 16 Nov 2011, 21:31:38 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/permissions.py
r6907 r7122 69 69 'waeup.managePortalConfiguration', 70 70 'waeup.manageApplications', 'waeup.handleApplication', 71 'waeup.viewStudents', 'waeup.manageStudents') 71 'waeup.viewStudent', 'waeup.manageStudents', 72 'waeup.viewHostels', 'waeup.manageHostels') 72 73 73 74 def getRoles(): -
main/waeup.sirp/trunk/src/waeup/sirp/students/student.py
r7106 r7122 223 223 """ 224 224 marker, filename, basename, ext = store.extractMarker(file_id) 225 return os.path.join(root, 'students', filename) 225 sub_root = os.path.join(root, 'students') 226 return super(StudentFileStoreHandler, self).pathFromFileID( 227 store, sub_root, basename) 226 228 227 229 def createFile(self, store, root, filename, file_id, file): 228 230 """Create a browsable file-like object. 229 231 """ 230 # possible other actions: check for jpeg format 231 path = self.pathFromFileID(store, root, file_id) 232 return file, path, WAeUPImageFile(filename, file_id) 232 ext = os.path.splitext(filename)[1].lower() 233 if ext not in ['.jpg', '.png']: 234 raise ValueError('Only .jpg and .png allowed') 235 # call super method to ensure that any old files with 236 # different filename extension are deleted. 237 file, path, file_obj = super( 238 StudentFileStoreHandler, self).createFile( 239 store, root, filename, file_id, file) 240 return file, path, WAeUPImageFile( 241 file_obj.filename, file_obj.data) -
main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py
r7111 r7122 372 372 self.browser.open(self.edit_clearance_student_path) 373 373 pseudo_image = StringIO('I pretend to be a graphics file') 374 ctrl = self.browser.getControl(name='birth _certificate')374 ctrl = self.browser.getControl(name='birthcertificateuploadmanage') 375 375 file_ctrl = ctrl.mech_control 376 376 file_ctrl.add_file(pseudo_image, filename='my_birth_certificate.jpg') … … 382 382 # ... but the correct upload submit button does 383 383 pseudo_image = StringIO('I pretend to be a graphics file') 384 ctrl = self.browser.getControl(name='birth _certificate')384 ctrl = self.browser.getControl(name='birthcertificateuploadmanage') 385 385 file_ctrl = ctrl.mech_control 386 386 file_ctrl.add_file(pseudo_image, filename='my_birth_certificate.jpg') 387 self.browser.getControl(name='upload_birth_certificate').click() 387 self.browser.getControl( 388 name='upload_birthcertificateuploadmanage').click() 388 389 # There is a correct <img> link included 389 390 self.assertTrue( 390 391 '<a target="image" href="birth_certificate.jpg">' 391 392 in self.browser.contents) 393 392 394 # Browsing the link shows a real image 393 395 self.browser.open('birth_certificate.jpg') … … 399 401 photo_content = 'A' * 1024 * 151 # A string of 21 KB size 400 402 pseudo_image = StringIO(photo_content) 401 ctrl = self.browser.getControl(name='birth _certificate')403 ctrl = self.browser.getControl(name='birthcertificateuploadmanage') 402 404 file_ctrl = ctrl.mech_control 403 405 file_ctrl.add_file(pseudo_image, filename='my_birth_certificate.jpg') 404 self.browser.getControl(name='upload_birth_certificate').click() 406 self.browser.getControl( 407 name='upload_birthcertificateuploadmanage').click() 405 408 self.assertTrue( 406 409 'Uploaded file is too big' in self.browser.contents) 407 410 # File names must meet several conditions 408 411 pseudo_image = StringIO('I pretend to be a graphics file') 409 ctrl = self.browser.getControl(name='birth _certificate')412 ctrl = self.browser.getControl(name='birthcertificateuploadmanage') 410 413 file_ctrl = ctrl.mech_control 411 414 file_ctrl.add_file(pseudo_image, filename='my.photo.jpg') 412 self.browser.getControl(name='upload_birth_certificate').click() 415 self.browser.getControl( 416 name='upload_birthcertificateuploadmanage').click() 413 417 self.assertTrue('File name contains more than one dot' 414 418 in self.browser.contents) 415 ctrl = self.browser.getControl(name='birth _certificate')419 ctrl = self.browser.getControl(name='birthcertificateuploadmanage') 416 420 file_ctrl = ctrl.mech_control 417 421 file_ctrl.add_file(pseudo_image, filename='my_birth_certificate') 418 self.browser.getControl(name='upload_birth_certificate').click() 422 self.browser.getControl( 423 name='upload_birthcertificateuploadmanage').click() 419 424 self.assertTrue('File name has no extension' in self.browser.contents) 420 ctrl = self.browser.getControl(name='birth _certificate')425 ctrl = self.browser.getControl(name='birthcertificateuploadmanage') 421 426 file_ctrl = ctrl.mech_control 422 427 file_ctrl.add_file(pseudo_image, filename='my_birth_certificate.bmp') 423 self.browser.getControl(name='upload_birth_certificate').click() 428 self.browser.getControl( 429 name='upload_birthcertificateuploadmanage').click() 424 430 self.assertTrue('.jpg file extension expected' in self.browser.contents) 425 431 # Managers can delete files 426 self.browser.getControl(name='delete_birth _certificate').click()432 self.browser.getControl(name='delete_birthcertificateuploadmanage').click() 427 433 self.assertTrue( 428 434 'File birth_certificate.jpg deleted' … … 431 437 self.browser.open(self.edit_clearance_student_path) 432 438 pseudo_image = StringIO('I pretend to be a graphics file') 433 ctrl = self.browser.getControl(name='birth _certificate')439 ctrl = self.browser.getControl(name='birthcertificateuploadmanage') 434 440 file_ctrl = ctrl.mech_control 435 441 file_ctrl.add_file(pseudo_image, filename='my_acceptance_letter.jpg') 436 self.browser.getControl(name='upload_acceptance_letter').click() 442 self.browser.getControl( 443 name='upload_acceptanceletteruploadmanage').click() 437 444 self.assertFalse( 438 445 '<a target="image" href="acceptance_letter.jpg">' 439 446 in self.browser.contents) 440 ctrl = self.browser.getControl(name='acceptance _letter')447 ctrl = self.browser.getControl(name='acceptanceletteruploadmanage') 441 448 file_ctrl = ctrl.mech_control 442 449 file_ctrl.add_file(pseudo_image, filename='my_acceptance_letter.jpg') 443 self.browser.getControl(name='upload_acceptance_letter').click() 450 self.browser.getControl( 451 name='upload_acceptanceletteruploadmanage').click() 444 452 self.assertTrue( 445 453 '<a target="image" href="acceptance_letter.jpg">' 446 454 in self.browser.contents) 447 self.browser.getControl(name='delete_acceptance_letter').click() 455 self.browser.getControl( 456 name='delete_acceptanceletteruploadmanage').click() 448 457 self.assertTrue( 449 458 'File acceptance_letter.jpg deleted'
Note: See TracChangeset for help on using the changeset viewer.