Changeset 12619 for main


Ignore:
Timestamp:
15 Feb 2015, 08:06:25 (10 years ago)
Author:
Henrik Bettermann
Message:

Show department paths. Department codes are not unique!

Location:
main/waeup.kofa/trunk/src/waeup/kofa/students/reports
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/reports/student_payment_statistics.py

    r12564 r12619  
    5959        codes = tuple(sorted([x for x in site['faculties'].keys()],
    6060                                 key=lambda x: x.lower()))
     61        paths = codes
    6162    elif breakdown == 'depcode':
    6263        faculties = site['faculties']
    6364        depcodes = []
     65        deppaths = []
    6466        for fac in faculties.values():
    6567            for dep in fac.values():
    6668                depcodes.append(dep.code)
     69                deppaths.append('%s/%s' % (fac.code, dep.code))
    6770        codes = tuple(sorted([x for x in depcodes],
    6871                                 key=lambda x: x.lower()))
    69     codes = codes + (u'Total',)
     72        paths = tuple(sorted([x for x in deppaths],
     73                                 key=lambda x: x.lower()))
    7074    # XXX: Here we do _one_ query and then examine the single
    7175    #   students. One could also do multiple queries and just look for
     
    7478    cat = queryUtility(ICatalog, name="students_catalog")
    7579    result = cat.searchResults(current_session=(session, session))
    76     table = [[0 for x in xrange(2*len(payment_cats))] for y in xrange(len(codes))]
     80    table = [[0 for x in xrange(2*len(payment_cats))] for y in xrange(len(codes)+1)]
    7781    mode_groups = getUtility(IKofaUtils).MODE_GROUPS
    7882    for stud in result:
     
    115119    # Turn lists into tuples
    116120    table = tuple([tuple(row) for row in table])
    117     return (codes, table_header, table)
     121
     122    paths = paths + (u'Total',)
     123    return (paths, table_header, table)
    118124
    119125from reportlab.lib import colors
  • main/waeup.kofa/trunk/src/waeup/kofa/students/reports/student_statistics.py

    r12515 r12619  
    5757        codes = tuple(sorted([x for x in site['faculties'].keys()],
    5858                                 key=lambda x: x.lower()))
     59        paths = codes
    5960    elif breakdown == 'depcode':
    6061        faculties = site['faculties']
    6162        depcodes = []
     63        deppaths = []
    6264        for fac in faculties.values():
    6365            for dep in fac.values():
    6466                depcodes.append(dep.code)
     67                deppaths.append('%s/%s' % (fac.code, dep.code))
    6568        codes = tuple(sorted([x for x in depcodes],
    6669                                 key=lambda x: x.lower()))
    67     codes = codes + (u'Total',)
     70        paths = tuple(sorted([x for x in deppaths],
     71                                 key=lambda x: x.lower()))
    6872    # XXX: Here we do _one_ query and then examine the single
    6973    #   students. One could also do multiple queries and just look for
     
    7276    cat = queryUtility(ICatalog, name="students_catalog")
    7377    result = cat.searchResults(current_session=(session, session))
    74     table = [[0 for x in xrange(len(states))] for y in xrange(len(codes))]
     78    table = [[0 for x in xrange(len(states))] for y in xrange(len(codes)+1)]
    7579    mode_groups = getUtility(IKofaUtils).MODE_GROUPS
    7680    for stud in result:
     
    8892    # turn lists into tuples
    8993    table = tuple([tuple(row) for row in table])
    90     return (codes, states, table)
     94
     95    paths = paths + (u'Total',)
     96    return (paths, states, table)
    9197
    9298from reportlab.lib import colors
  • main/waeup.kofa/trunk/src/waeup/kofa/students/reports/tests/test_student_statistics.py

    r12515 r12619  
    7676        self.assertEqual(
    7777            result1,
    78             ((u'dep1', u'dep2', u'Total'),
     78            ((u'fac1/dep1', u'fac2/dep2', u'Total'),
    7979             self.states,
    8080             ((1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1),
     
    8383        self.assertEqual(
    8484            result2,
    85             ((u'dep1', u'dep2', u'Total'),
     85            ((u'fac1/dep1', u'fac2/dep2', u'Total'),
    8686             self.states,
    8787             ((0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
Note: See TracChangeset for help on using the changeset viewer.