Ignore:
Timestamp:
26 Feb 2015, 07:35:00 (10 years ago)
Author:
Henrik Bettermann
Message:

Add components to configure a student export jobs in faculties.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/tests/test_browser.py

    r12518 r12632  
    347347        self.assertTrue(
    348348            'zope.mgr - students.browser.DatacenterExportJobContainerJobConfig '
    349             '- exported: students (None, None, None, None, None, None, None), '
     349            '- exported: students (None, None, None, None, None, None, None, None), '
    350350            'job_id=%s'
    351351            % job_id in logcontent)
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/viewlets.py

    r11862 r12632  
    444444    target = 'find_students'
    445445
     446class ExportFacultyStudentsActionButton(ManageActionButton):
     447    """ 'Export student data' button for faculties.
     448    """
     449    grok.order(3)
     450    grok.context(IFaculty)
     451    grok.view(FacultyPage)
     452    grok.name('exportfacultystudents')
     453    grok.require('waeup.showStudents')
     454    icon = 'actionicon_down.png'
     455    text = _('Export student data')
     456    target = 'exports'
     457
    446458class ManageDepartmentActionButton(ManageActionButton):
    447459    """ 'Manage settings' button for departments.
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r12518 r12632  
    5353from waeup.kofa.university.interfaces import (
    5454    IDepartment, ICertificate, ICourse)
    55 from waeup.kofa.university.department import (
    56     VirtualDepartmentExportJobContainer,)
     55from waeup.kofa.university.faculty import VirtualFacultyExportJobContainer
     56from waeup.kofa.university.department import VirtualDepartmentExportJobContainer
    5757from waeup.kofa.university.facultiescontainer import (
    5858    VirtualFacultiesExportJobContainer, FacultiesContainer)
     
    31923192
    31933193    @property
     3194    def faccode(self):
     3195        return None
     3196
     3197    @property
    31943198    def depcode(self):
    31953199        return None
     
    32273231        if payments_end == '':
    32283232            payments_end = None
    3229         if (mode, level, session,
    3230             self.depcode, self.certcode) == (None, None, None, None, None):
     3233        if (mode,
     3234            level,
     3235            session,
     3236            self.faccode,
     3237            self.depcode,
     3238            self.certcode) == (None, None, None, None, None, None):
    32313239            # Export all students including those without certificate
    32323240            if payments_start:
     
    32453253                                              current_level=level,
    32463254                                              current_mode=mode,
     3255                                              faccode=self.faccode,
    32473256                                              depcode=self.depcode,
    32483257                                              certcode=self.certcode,
     
    32553264                                              current_level=level,
    32563265                                              current_mode=mode,
     3266                                              faccode=self.faccode,
    32573267                                              depcode=self.depcode,
    32583268                                              certcode=self.certcode)
    32593269        ob_class = self.__implemented__.__name__.replace('waeup.kofa.','')
    32603270        self.context.logger.info(
    3261             '%s - exported: %s (%s, %s, %s, %s, %s, %s, %s), job_id=%s'
    3262             % (ob_class, exporter, session, level, mode, self.depcode,
    3263             self.certcode, payments_start, payments_end, job_id))
     3271            '%s - exported: %s (%s, %s, %s, %s, %s, %s, %s, %s), job_id=%s'
     3272            % (ob_class, exporter, session, level, mode, self.faccode,
     3273            self.depcode, self.certcode, payments_start, payments_end, job_id))
    32643274        self.flash(_('Export started for students with') +
    32653275                   ' current_session=%s, current_level=%s, study_mode=%s' % (
     
    33173327    """
    33183328    grok.context(VirtualFacultiesExportJobContainer)
     3329
     3330
     3331class FacultyExportJobContainerJobConfig(ExportJobContainerJobConfig):
     3332    """Page that configures a students export job in faculties.
     3333
     3334    """
     3335    grok.context(VirtualFacultyExportJobContainer)
     3336
     3337    @property
     3338    def faccode(self):
     3339        return self.context.__parent__.code
    33193340
    33203341class DepartmentExportJobContainerJobConfig(ExportJobContainerJobConfig):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r12518 r12632  
    32993299        self.assertTrue(
    33003300            'zope.mgr - students.browser.DatacenterExportJobContainerJobConfig '
    3301             '- exported: bursary (2004, 100, ug_ft, None, None, '
     3301            '- exported: bursary (2004, 100, ug_ft, None, None, None, '
    33023302            '13/12/2012, 14/12/2012), job_id=%s'
    33033303            % job_id in logcontent
     
    33893389        self.assertTrue(
    33903390            'zope.mgr - students.browser.FacultiesExportJobContainerJobConfig '
    3391             '- exported: bursary (2004, 100, ug_ft, None, None, '
     3391            '- exported: bursary (2004, 100, ug_ft, None, None, None, '
    33923392            '13/12/2012, 14/12/2012), job_id=%s'
    33933393            % job_id in logcontent
     
    33963396            'zope.mgr - students.browser.ExportJobContainerDownload '
    33973397            '- downloaded: WAeUP.Kofa_bursary_%s.csv, job_id=%s'
     3398            % (job_id, job_id) in logcontent
     3399            )
     3400        self.assertTrue(
     3401            'zope.mgr - students.browser.ExportJobContainerOverview '
     3402            '- discarded: job_id=%s' % job_id in logcontent
     3403            )
     3404
     3405    def test_faculty_export(self):
     3406        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     3407        fac1_path = 'http://localhost/app/faculties/fac1'
     3408        self.browser.open(fac1_path)
     3409        self.browser.getLink("Export student data").click()
     3410        self.browser.getControl("Configure new export").click()
     3411        self.browser.getControl(name="exporter").value = ['students']
     3412        self.browser.getControl(name="session").value = ['2004']
     3413        self.browser.getControl(name="level").value = ['100']
     3414        self.browser.getControl(name="mode").value = ['ug_ft']
     3415        # The testbrowser does not hide the payment period fields, but
     3416        # values are ignored when using the students exporter.
     3417        self.browser.getControl(name="payments_start").value = '13/12/2012'
     3418        self.browser.getControl(name="payments_end").value = '14/12/2012'
     3419        self.browser.getControl("Create CSV file").click()
     3420
     3421        # When the job is finished and we reload the page...
     3422        job_id = self.wait_for_export_job_completed()
     3423        self.browser.open(fac1_path + '/exports')
     3424        # ... the csv file can be downloaded ...
     3425        self.browser.getLink("Download").click()
     3426        self.assertEqual(self.browser.headers['content-type'],
     3427            'text/csv; charset=UTF-8')
     3428        self.assertTrue(
     3429            'filename="WAeUP.Kofa_students_%s.csv' % job_id in
     3430            self.browser.headers['content-disposition'])
     3431        self.assertTrue(
     3432            'adm_code,clearance_locked,clr_code,date_of_birth,email,employer,'
     3433            'firstname,lastname,matric_number,middlename,nationality,'
     3434            'officer_comment,perm_address,personal_updated,phone,reg_number,'
     3435            'sex,student_id,suspended,suspended_comment,transcript_comment,'
     3436            'password,state,history,certcode,is_postgrad,current_level,'
     3437            'current_session\r\n'
     3438            ',1,,1981-02-04#,aa@aa.ng,,Anna,Tester,234,,,,,,'
     3439            '1234#,123,m,K1000000,0,,,{SSHA}' in self.browser.contents)
     3440        self.assertEqual(len(self.app['datacenter'].running_exports), 1)
     3441        job_id = self.app['datacenter'].running_exports[0][0]
     3442        # ... and discarded
     3443        self.browser.open(fac1_path + '/exports')
     3444        self.browser.getControl("Discard").click()
     3445        self.assertEqual(len(self.app['datacenter'].running_exports), 0)
     3446        # Creation, downloading and discarding is logged
     3447        logfile = os.path.join(
     3448            self.app['datacenter'].storage, 'logs', 'datacenter.log')
     3449        logcontent = open(logfile).read()
     3450        self.assertTrue(
     3451            'zope.mgr - students.browser.FacultyExportJobContainerJobConfig '
     3452            '- exported: students (2004, 100, ug_ft, fac1, None, None, '
     3453            '13/12/2012, 14/12/2012), job_id=%s'
     3454            % job_id in logcontent
     3455            )
     3456        self.assertTrue(
     3457            'zope.mgr - students.browser.ExportJobContainerDownload '
     3458            '- downloaded: WAeUP.Kofa_students_%s.csv, job_id=%s'
    33983459            % (job_id, job_id) in logcontent
    33993460            )
     
    34413502        self.assertTrue(
    34423503            'zope.mgr - students.browser.DepartmentExportJobContainerJobConfig '
    3443             '- exported: students (2004, 100, ug_ft, dep1, None, '
     3504            '- exported: students (2004, 100, ug_ft, None, dep1, None, '
    34443505            '13/12/2012, 14/12/2012), job_id=%s'
    34453506            % job_id in logcontent
     
    34883549        self.assertTrue(
    34893550            'zope.mgr - students.browser.CertificateExportJobContainerJobConfig '
    3490             '- exported: students (2004, 100, None, None, CERT1, None, None), '
     3551            '- exported: students (2004, 100, None, None, None, CERT1, None, None), '
    34913552            'job_id=%s'
    34923553            % job_id in logcontent
  • main/waeup.kofa/trunk/src/waeup/kofa/university/faculty.py

    r10684 r12632  
    2020
    2121import grok
     22import zope.location.location
    2223from zope.component.interfaces import IFactory
    2324from zope.interface import implementedBy
    2425from zope.component import getUtility
    2526from waeup.kofa.interfaces import IKofaUtils
     27from waeup.kofa.utils.batching import VirtualExportJobContainer
    2628from waeup.kofa.university.interfaces import (
    2729    IFaculty, IDepartment)
     
    3436        insttypes_dict[inst.title_prefix],
    3537        inst.title, inst.code)
     38
     39class VirtualFacultyExportJobContainer(VirtualExportJobContainer):
     40    """A virtual export job container for facultiess.
     41    """
    3642
    3743class Faculty(grok.Container):
     
    6773        self.code = code
    6874
     75    def traverse(self, name):
     76        """Deliver appropriate containers.
     77        """
     78        if name == 'exports':
     79            # create a virtual exports container and return it
     80            container = VirtualFacultyExportJobContainer()
     81            zope.location.location.located(container, self, 'exports')
     82            return container
     83        return None
     84
    6985    def addDepartment(self, department):
    7086        """Add a department to the faculty.
Note: See TracChangeset for help on using the changeset viewer.