Changeset 13766


Ignore:
Timestamp:
8 Mar 2016, 06:22:12 (9 years ago)
Author:
Henrik Bettermann
Message:

Create new exporter for lecturers and further restrict the usage of
exporters at course level.

Location:
main/waeup.kofa/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/CHANGES.txt

    r13745 r13766  
    441.4.2.dev0 (unreleased)
    55=======================
     6
     7* Create new exporter for lecturers and further restrict the usage of
     8  exporters at course level.
    69
    710* Show certificate-specific p_level value on payment pages.
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r13764 r13766  
    34223422
    34233423    def _set_exporter_values(self):
    3424         # We provide only two exporters.
     3424        # We provide only the 'lecturer' exporter but can add more.
    34253425        exporters = []
    3426         for name in ('students', 'coursetickets'):
     3426        for name in ('lecturer',):
    34273427            util = getUtility(ICSVExporter, name=name)
    34283428            exporters.append((util.title, name),)
    34293429        self.exporters = exporters
     3430
     3431    def _set_session_values(self):
     3432        # We allow only current academic session
     3433        academic_session = grok.getSite()['configuration'].current_academic_session
     3434        if not academic_session:
     3435            self.sessions = []
     3436            return
     3437        x = academic_sessions_vocab.getTerm(academic_session)
     3438        self.sessions = [(x.title, x.token)]
     3439        return
    34303440
    34313441    def update(self, START=None, session=None, level=None, mode=None,
     
    34353445        self._set_mode_values()
    34363446        self._set_exporter_values()
     3447        if not self.sessions:
     3448            self.flash(
     3449                _('Academic session not set. '
     3450                  'Please contact the administrator.'),
     3451                type='danger')
     3452            self.redirect(self.url(self.context))
     3453            return
    34373454        if START is None:
    34383455            return
  • main/waeup.kofa/trunk/src/waeup/kofa/students/export.py

    r13736 r13766  
    349349            value, name, context=context)
    350350
     351class DataForLecturerExporter(CourseTicketExporter):
     352    """
     353    """
     354    grok.name('lecturer')
     355
     356    fields = ('matric_number', 'reg_number', 'student_id', 'display_fullname',
     357              'level', 'code', 'level_session', 'score')
     358
     359    title = _(u'Data for Lecturer')
     360
     361    def mangle_value(self, value, name, context=None):
     362        """The mangler determines the student's id and fullname.
     363        """
     364        if context is not None:
     365            student = context.student
     366            if name in ('student_id', 'fullname') and student is not None:
     367                value = getattr(student, name, None)
     368        return super(
     369            CourseTicketExporter, self).mangle_value(
     370            value, name, context=context)
    351371
    352372class StudentPaymentExporter(grok.GlobalUtility, StudentExporterBase):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r13764 r13766  
    37553755            )
    37563756
    3757     def test_course_export_students(self):
     3757    def deprecated_test_course_export_students(self):
    37583758        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    37593759        course1_path = 'http://localhost/app/faculties/fac1/dep1/courses/COURSE1'
     
    38013801            )
    38023802
    3803     def test_course_export_coursetickets(self):
     3803    def test_course_export_lecturer(self):
    38043804        # We add study level 100 to the student's studycourse
    38053805        studylevel = StudentStudyLevel()
     
    38133813        self.browser.getLink("Export student data").click()
    38143814        self.browser.getControl("Configure new export").click()
    3815         self.browser.getControl(name="exporter").value = ['coursetickets']
     3815        self.assertTrue(
     3816            'Academic session not set. Please contact the administrator.'
     3817            in self.browser.contents)
     3818        self.app['configuration'].current_academic_session = 2004
     3819        self.browser.getControl("Configure new export").click()
     3820        self.browser.getControl(name="exporter").value = ['lecturer']
    38163821        self.browser.getControl(name="session").value = ['2004']
    38173822        self.browser.getControl(name="level").value = ['100']
     
    38253830            'text/csv; charset=UTF-8')
    38263831        self.assertTrue(
    3827             'filename="WAeUP.Kofa_coursetickets_%s.csv' % job_id in
     3832            'filename="WAeUP.Kofa_lecturer_%s.csv' % job_id in
    38283833            self.browser.headers['content-disposition'])
    38293834        # ... and contains the course ticket COURSE1
    38303835        self.assertEqual(self.browser.contents,
    3831             'automatic,carry_over,code,credits,dcode,fcode,level,'
    3832             'level_session,mandatory,passmark,score,semester,title,'
    3833             'student_id,certcode,display_fullname\r\n1,0,COURSE1,10,'
    3834             'dep1,fac1,100,2004,1,40,,1,'
    3835             'Unnamed Course,K1000000,CERT1,Anna Tester\r\n')
    3836 
     3836            'matric_number,reg_number,student_id,display_fullname,level,code,'
     3837            'level_session,score\r\n,,K1000000,,100,COURSE1,2004,\r\n')
    38373838        self.assertEqual(len(self.app['datacenter'].running_exports), 1)
    38383839        job_id = self.app['datacenter'].running_exports[0][0]
     
    38473848        self.assertTrue(
    38483849            'zope.mgr - students.browser.CourseExportJobContainerJobConfig '
    3849             '- exported: coursetickets (2004, 100, COURSE1), job_id=%s'
     3850            '- exported: lecturer (2004, 100, COURSE1), job_id=%s'
    38503851            % job_id in logcontent
    38513852            )
    38523853        self.assertTrue(
    38533854            'zope.mgr - students.browser.ExportJobContainerDownload '
    3854             '- downloaded: WAeUP.Kofa_coursetickets_%s.csv, job_id=%s'
     3855            '- downloaded: WAeUP.Kofa_lecturer_%s.csv, job_id=%s'
    38553856            % (job_id, job_id) in logcontent
    38563857            )
Note: See TracChangeset for help on using the changeset viewer.