Changeset 9842 for main/waeup.kofa/trunk/src/waeup/kofa
- Timestamp:
- 8 Jan 2013, 07:52:55 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/browser/viewlets.py
r9819 r9842 472 472 text = _('Edit course') 473 473 474 class ManageCertificateActionButton(ManageActionButton):475 """ 'Manage settings' button for certificates.476 """477 grok.context(ICertificate)478 grok.view(CertificatePage)479 text = _('Manage certificate')480 481 474 class ShowCourseStudentsActionButton(ManageActionButton): 482 475 """ 'Show students' button in course. … … 489 482 target = 'students' 490 483 484 class ManageCertificateActionButton(ManageActionButton): 485 """ 'Manage settings' button for certificates. 486 """ 487 grok.context(ICertificate) 488 grok.view(CertificatePage) 489 text = _('Manage certificate') 490 grok.order(1) 491 491 492 class ShowCertificateStudentsActionButton(ManageActionButton): 492 493 """ 'Show students' button for certificates. … … 498 499 text = _('Show students') 499 500 target = 'students' 501 grok.order(2) 502 503 class ExportCertificateStudentsActionButton(ManageActionButton): 504 """ 'Export student data' button for certificates. 505 """ 506 grok.context(ICertificate) 507 grok.view(CertificatePage) 508 grok.require('waeup.showStudents') 509 icon = 'actionicon_down.png' 510 text = _('Export student data') 511 target = 'exports' 512 grok.order(3) 500 513 501 514 class ManageCertificateCourseActionButton(ManageActionButton): -
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r9838 r9842 56 56 from waeup.kofa.university.department import ( 57 57 VirtualDepartmentExportJobContainer,) 58 from waeup.kofa.university.certificate import ( 59 VirtualCertificateExportJobContainer,) 58 60 from waeup.kofa.university.vocabularies import course_levels 59 61 from waeup.kofa.utils.batching import VirtualExportJobContainer … … 2724 2726 return None 2725 2727 2728 @property 2729 def certcode(self): 2730 return None 2731 2726 2732 def update(self, START=None, session=None, level=None, mode=None, 2727 2733 exporter=None): … … 2743 2749 current_level=level, 2744 2750 current_mode=mode, 2745 depcode=self.depcode) 2751 depcode=self.depcode, 2752 certcode=self.certcode) 2746 2753 ob_class = self.__implemented__.__name__.replace('waeup.kofa.','') 2747 2754 self.context.logger.info( 2748 '%s - exported: %s (%s, %s, %s, %s), job_id=%s' 2749 % (ob_class, exporter, session, level, mode, self.depcode, job_id)) 2755 '%s - exported: %s (%s, %s, %s, %s, %s), job_id=%s' 2756 % (ob_class, exporter, session, level, mode, self.depcode, 2757 self.certcode, job_id)) 2750 2758 self.flash(_('Export started for students with') + 2751 2759 ' current_session=%s, current_level=%s, study_mode=%s' % ( … … 2777 2785 def depcode(self): 2778 2786 return self.context.__parent__.code 2787 2788 class CertificateExportJobContainerJobConfig(ExportJobContainerJobConfig): 2789 """Page that configures a students export job for certificates. 2790 2791 """ 2792 grok.context(VirtualCertificateExportJobContainer) 2793 2794 @property 2795 def certcode(self): 2796 return self.context.__parent__.code -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r9837 r9842 2776 2776 self.assertTrue( 2777 2777 'zope.mgr - students.browser.DepartmentExportJobContainerJobConfig ' 2778 '- exported: students (2004, 100, ug_ft, dep1), job_id=' 2778 '- exported: students (2004, 100, ug_ft, dep1, None), job_id=%s' 2779 % job_id in logcontent 2779 2780 ) 2780 2781 self.assertTrue( 2781 2782 'zope.mgr - students.browser.ExportJobContainerDownload ' 2782 2783 '- downloaded: WAeUP.Kofa_students_%s.csv, job_id=%s' 2783 % (job_id, job_id) 2784 % (job_id, job_id) in logcontent 2784 2785 ) 2785 2786 self.assertTrue( 2786 2787 'zope.mgr - students.browser.ExportJobContainerOverview ' 2787 '- discarded: job_id=%s' % job_id 2788 '- discarded: job_id=%s' % job_id in logcontent 2788 2789 ) 2790 2791 def test_certificate_export(self): 2792 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 2793 cert1_path = 'http://localhost/app/faculties/fac1/dep1/certificates/CERT1' 2794 self.browser.open(cert1_path) 2795 self.browser.getLink("Export student data").click() 2796 self.browser.getControl("Configure new export").click() 2797 self.browser.getControl(name="exporter").value = ['students'] 2798 self.browser.getControl(name="session").value = ['2004'] 2799 self.browser.getControl(name="level").value = ['100'] 2800 self.browser.getControl(name="mode").value = ['ug_ft'] 2801 self.browser.getControl("Create CSV file").click() 2802 2803 # When the job is finished and we reload the page... 2804 job_id = self.wait_for_export_job_completed() 2805 self.browser.open(cert1_path + '/exports') 2806 # ... the csv file can be downloaded ... 2807 self.browser.getLink("Download").click() 2808 self.assertEqual(self.browser.headers['content-type'], 2809 'text/csv; charset=UTF-8') 2810 self.assertTrue( 2811 'filename="WAeUP.Kofa_students_%s.csv' % job_id in 2812 self.browser.headers['content-disposition']) 2813 self.assertEqual(len(self.app['datacenter'].running_exports), 1) 2814 job_id = self.app['datacenter'].running_exports[0][0] 2815 # ... and discarded 2816 self.browser.open(cert1_path + '/exports') 2817 self.browser.getControl("Discard").click() 2818 self.assertEqual(len(self.app['datacenter'].running_exports), 0) 2819 # Creation, downloading and discarding is logged 2820 logfile = os.path.join( 2821 self.app['datacenter'].storage, 'logs', 'datacenter.log') 2822 logcontent = open(logfile).read() 2823 self.assertTrue( 2824 'zope.mgr - students.browser.CertificateExportJobContainerJobConfig ' 2825 '- exported: students (2004, 100, ug_ft, None, CERT1), job_id=%s' 2826 % job_id in logcontent 2827 ) 2828 self.assertTrue( 2829 'zope.mgr - students.browser.ExportJobContainerDownload ' 2830 '- downloaded: WAeUP.Kofa_students_%s.csv, job_id=%s' 2831 % (job_id, job_id) in logcontent 2832 ) 2833 self.assertTrue( 2834 'zope.mgr - students.browser.ExportJobContainerOverview ' 2835 '- discarded: job_id=%s' % job_id in logcontent 2836 ) -
main/waeup.kofa/trunk/src/waeup/kofa/university/certificate.py
r9826 r9842 19 19 """ 20 20 import grok 21 import zope.location.location 21 22 from zope.event import notify 22 23 from zope.catalog.interfaces import ICatalog … … 30 31 ICertificate, ICertificateAdd, ICertificateCourse) 31 32 from waeup.kofa.university.vocabularies import course_levels 33 from waeup.kofa.utils.batching import VirtualExportJobContainer 34 35 class VirtualCertificateExportJobContainer(VirtualExportJobContainer): 36 """A virtual export job container for certificates. 37 """ 32 38 33 39 class Certificate(grok.Container): … … 61 67 self.school_fee_3 = school_fee_3 62 68 self.school_fee_4 = school_fee_4 69 70 def traverse(self, name): 71 """Deliver appropriate containers. 72 """ 73 if name == 'exports': 74 # create a virtual exports container and return it 75 container = VirtualCertificateExportJobContainer() 76 zope.location.location.located(container, self, 'exports') 77 return container 78 return None 63 79 64 80 def longtitle(self):
Note: See TracChangeset for help on using the changeset viewer.