Changeset 7127
- Timestamp:
- 17 Nov 2011, 13:55:14 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/students
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py
r7116 r7127 1505 1505 def update(self): 1506 1506 super(StudentPasswordFormPage, self).update() 1507 self.wf_info = IWorkflowInfo(self.context)1507 #self.wf_info = IWorkflowInfo(self.context) 1508 1508 return 1509 1509 … … 1537 1537 grok.context(IStudent) 1538 1538 grok.name('change_portrait') 1539 grok.require('waeup. handleStudent')1539 grok.require('waeup.uploadStudentFile') 1540 1540 grok.template('filesuploadpage') 1541 1541 label = 'Upload portrait' -
main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/filesuploadpage.pt
r7114 r7127 3 3 tal:content="view/label">Label</h2> 4 4 5 <table class="zebra"> 6 <tbody> 7 <tal:files content="structure provider:files" /> 8 </tbody> 9 </table> 5 <form action="." tal:attributes="action request/URL" method="post" 6 class="edit-form" enctype="multipart/form-data"> 7 <table class="zebra"> 8 <tbody> 9 <tal:files content="structure provider:files" /> 10 </tbody> 11 </table> 12 </form> -
main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/fileupload.pt
r7111 r7127 7 7 <td class="field"> 8 8 <span class="widget"> 9 9 10 <tal:file tal:condition="viewlet/file_exists"> 10 11 <a tal:attributes="href viewlet/download_name" 11 tal:content="viewlet/ download_name"12 tal:content="viewlet/title" 12 13 target="image"> 13 14 LINK 14 15 </a> 15 <input type="submit"16 tal:attributes="id python:('delete_%s' % viewlet.input_name);17 name python:('delete_%s' % viewlet.input_name)"18 value="Delete" class="button" />19 <br />20 16 </tal:file> 17 <br /> 21 18 <input type="file" tal:attributes="name viewlet/input_name"/> 19 <br /> 20 <input type="submit" tal:condition="viewlet/file_exists" 21 tal:attributes="id python:('delete_%s' % viewlet.input_name); 22 name python:('delete_%s' % viewlet.input_name)" 23 value="Delete attachment" class="button" /> 22 24 <input type="submit" 23 25 tal:attributes="id python:('upload_%s' % viewlet.input_name); 24 26 name python:('upload_%s' % viewlet.input_name)" 25 value="Upload" class="button" /> 26 <br /> 27 value="Upload new file" class="button" /> 27 28 <span i18n:translate=""> 28 29 Max. file size: … … 30 31 </span> 31 32 </span> 33 <br /> 32 34 </td> 33 35 </tr> -
main/waeup.sirp/trunk/src/waeup/sirp/students/permissions.py
r6930 r7127 30 30 grok.name('waeup.payStudent') 31 31 32 class UploadStudentFile(grok.Permission): 33 grok.name('waeup.uploadStudentFile') 34 32 35 class ManageStudents(grok.Permission): 33 36 grok.name('waeup.manageStudents') … … 37 40 grok.name('waeup.local.StudentRecordOwner') 38 41 grok.title(u'Student Record Owner') 39 grok.permissions('waeup.handleStudent', 42 grok.permissions('waeup.handleStudent', 'waeup.uploadStudentFile', 40 43 'waeup.viewStudent', 'waeup.payStudent') 41 44 … … 50 53 grok.permissions('waeup.View', 'waeup.Public', 51 54 'waeup.viewStudent', 'waeup.manageStudents', 52 'waeup.payStudent' )55 'waeup.payStudent', 'waeup.uploadStudentFile') -
main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py
r7124 r7127 357 357 return 358 358 359 def test_ upload_file(self):359 def test_manage_upload_file(self): 360 360 # Managers can upload a file via the StudentClearanceManageFormPage 361 361 # The image is stored even if form has errors … … 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='birthcertificateupload manage')374 ctrl = self.browser.getControl(name='birthcertificateupload') 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='birthcertificateupload manage')384 ctrl = self.browser.getControl(name='birthcertificateupload') 385 385 file_ctrl = ctrl.mech_control 386 386 file_ctrl.add_file(pseudo_image, filename='my_birth_certificate.jpg') 387 387 self.browser.getControl( 388 name='upload_birthcertificateupload manage').click()388 name='upload_birthcertificateupload').click() 389 389 # There is a correct <img> link included 390 390 self.assertTrue( … … 401 401 photo_content = 'A' * 1024 * 151 # A string of 21 KB size 402 402 pseudo_image = StringIO(photo_content) 403 ctrl = self.browser.getControl(name='birthcertificateupload manage')403 ctrl = self.browser.getControl(name='birthcertificateupload') 404 404 file_ctrl = ctrl.mech_control 405 405 file_ctrl.add_file(pseudo_image, filename='my_birth_certificate.jpg') 406 406 self.browser.getControl( 407 name='upload_birthcertificateupload manage').click()407 name='upload_birthcertificateupload').click() 408 408 self.assertTrue( 409 409 'Uploaded file is too big' in self.browser.contents) 410 410 # File names must meet several conditions 411 411 pseudo_image = StringIO('I pretend to be a graphics file') 412 ctrl = self.browser.getControl(name='birthcertificateupload manage')412 ctrl = self.browser.getControl(name='birthcertificateupload') 413 413 file_ctrl = ctrl.mech_control 414 414 file_ctrl.add_file(pseudo_image, filename='my.photo.jpg') 415 415 self.browser.getControl( 416 name='upload_birthcertificateupload manage').click()416 name='upload_birthcertificateupload').click() 417 417 self.assertTrue('File name contains more than one dot' 418 418 in self.browser.contents) 419 ctrl = self.browser.getControl(name='birthcertificateupload manage')419 ctrl = self.browser.getControl(name='birthcertificateupload') 420 420 file_ctrl = ctrl.mech_control 421 421 file_ctrl.add_file(pseudo_image, filename='my_birth_certificate') 422 422 self.browser.getControl( 423 name='upload_birthcertificateupload manage').click()423 name='upload_birthcertificateupload').click() 424 424 self.assertTrue('File name has no extension' in self.browser.contents) 425 ctrl = self.browser.getControl(name='birthcertificateupload manage')425 ctrl = self.browser.getControl(name='birthcertificateupload') 426 426 file_ctrl = ctrl.mech_control 427 427 file_ctrl.add_file(pseudo_image, filename='my_birth_certificate.bmp') 428 428 self.browser.getControl( 429 name='upload_birthcertificateupload manage').click()429 name='upload_birthcertificateupload').click() 430 430 self.assertTrue('Only the following extension are allowed' 431 431 in self.browser.contents) 432 432 # Managers can delete files 433 self.browser.getControl(name='delete_birthcertificateupload manage').click()433 self.browser.getControl(name='delete_birthcertificateupload').click() 434 434 self.assertTrue( 435 435 'birth_certificate deleted' in self.browser.contents) … … 437 437 self.browser.open(self.edit_clearance_student_path) 438 438 pseudo_image = StringIO('I pretend to be a graphics file') 439 ctrl = self.browser.getControl(name='birthcertificateupload manage')439 ctrl = self.browser.getControl(name='birthcertificateupload') 440 440 file_ctrl = ctrl.mech_control 441 441 file_ctrl.add_file(pseudo_image, filename='my_acceptance_letter.jpg') 442 442 self.browser.getControl( 443 name='upload_acceptanceletterupload manage').click()443 name='upload_acceptanceletterupload').click() 444 444 self.assertFalse( 445 445 '<a target="image" href="acceptance_letter">' 446 446 in self.browser.contents) 447 ctrl = self.browser.getControl(name='acceptanceletterupload manage')447 ctrl = self.browser.getControl(name='acceptanceletterupload') 448 448 file_ctrl = ctrl.mech_control 449 449 file_ctrl.add_file(pseudo_image, filename='my_acceptance_letter.jpg') 450 450 self.browser.getControl( 451 name='upload_acceptanceletterupload manage').click()451 name='upload_acceptanceletterupload').click() 452 452 self.assertTrue( 453 453 '<a target="image" href="acceptance_letter">' 454 454 in self.browser.contents) 455 455 self.browser.getControl( 456 name='delete_acceptanceletterupload manage').click()456 name='delete_acceptanceletterupload').click() 457 457 self.assertTrue( 458 458 'acceptance_letter deleted' … … 738 738 self.browser.getControl(name="form.password").value = 'spwd' 739 739 self.browser.getControl("Login").click() 740 # Student can upload a passport picture 741 self.browser.open(self.student_path + '/change_portrait') 742 pseudo_image = StringIO('I pretend to be a graphics file') 743 ctrl = self.browser.getControl(name='passportuploadedit') 744 file_ctrl = ctrl.mech_control 745 file_ctrl.add_file(pseudo_image, filename='my_photo.jpg') 746 self.browser.getControl( 747 name='upload_passportuploadedit').click() 748 self.assertTrue( 749 '<img align="middle" height="125px" src="passport.jpg" />' 750 in self.browser.contents) 740 751 # Student can view the clearance data 741 752 self.browser.getLink("Clearance Data").click() -
main/waeup.sirp/trunk/src/waeup/sirp/students/viewlets.py
r7123 r7127 265 265 grok.require('waeup.viewStudent') 266 266 label = u'File:' 267 title = u'Scan' 267 268 download_name = u'filename.jpg' 268 269 … … 284 285 grok.view(StudentClearanceManageFormPage) 285 286 grok.template('fileupload') 286 grok.require('waeup. manageStudents')287 grok.require('waeup.uploadStudentFile') 287 288 mus = 1024 * 150 288 289 … … 345 346 """ 346 347 grok.view(StudentFilesUploadPage) 347 grok.require('waeup. handleStudent')348 grok.require('waeup.uploadStudentFile') 348 349 349 350 class BirthCertificateDisplay(FileDisplay): … … 352 353 grok.order(1) 353 354 label = u'Birth Certificate:' 355 title = u'Birth Certificate Scan' 354 356 download_name = u'birth_certificate' 355 357 356 class BirthCertificateUpload Manage(FileUpload):358 class BirthCertificateUpload(FileUpload): 357 359 """Birth Certificate upload viewlet. 358 360 """ 359 361 grok.order(1) 360 362 label = u'Birth Certificate:' 363 title = u'Birth Certificate Scan' 361 364 mus = 1024 * 150 362 365 download_name = u'birth_certificate' … … 367 370 grok.order(1) 368 371 label = u'Acceptance Letter:' 372 title = u'Acceptance Letter Scan' 369 373 download_name = u'acceptance_letter' 370 374 371 class AcceptanceLetterUpload Manage(FileUpload):375 class AcceptanceLetterUpload(FileUpload): 372 376 """AcceptanceLetter upload viewlet. 373 377 """ 374 378 grok.order(2) 375 379 label = u'Acceptance Letter:' 380 title = u'Acceptance Letter Scan' 376 381 mus = 1024 * 150 377 382 download_name = u'acceptance_letter' 378 379 class BirthCertificateUploadEdit(BirthCertificateUploadManage):380 """Birth Certificate upload viewlet for student.381 """382 grok.require('waeup.handleStudent')383 384 class AcceptanceLetterUploadEdit(AcceptanceLetterUploadManage):385 """AcceptanceLetter upload viewlet for student.386 """387 grok.require('waeup.handleStudent')388 383 389 384 class Image(grok.View):
Note: See TracChangeset for help on using the changeset viewer.