Changeset 15243


Ignore:
Timestamp:
15 Nov 2018, 07:43:48 (6 years ago)
Author:
Henrik Bettermann
Message:

Fix get_student_payment_stats. Department codes are not unique. Use its path instead.

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

Legend:

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

    r15206 r15243  
    441.6.1.dev0 (unreleased)
    55=======================
     6
     7* Fix get_student_payment_stats. Department codes are not
     8  unique. Use its path instead.
    69
    710* Implement study level 0 (Level Zero) option for storing
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r15213 r15243  
    32983298    def _searchCatalog(self, session):
    32993299        cat = queryUtility(ICatalog, name='coursetickets_catalog')
     3300        # Attention: Also tickets of previous studycourses are found
    33003301        coursetickets = cat.searchResults(
    33013302            session=(session, session),
     
    34423443    def data(self, session):
    34433444        cat = queryUtility(ICatalog, name='coursetickets_catalog')
     3445        # Attention: Also tickets of previous studycourses are found
    34443446        coursetickets = cat.searchResults(
    34453447            session=(session, session),
  • main/waeup.kofa/trunk/src/waeup/kofa/students/reports/student_payment_statistics.py

    r15081 r15243  
    6262    payment_cats = tuple(sorted(payment_cats_dict.keys())) + ('Total',)
    6363    if breakdown == 'faccode':
    64         codes = tuple(sorted([x for x in site['faculties'].keys()],
     64        paths = tuple(sorted([x for x in site['faculties'].keys()],
    6565                                 key=lambda x: x.lower()))
    66         paths = codes
    6766    elif breakdown == 'depcode':
    6867        faculties = site['faculties']
    69         depcodes = []
    7068        deppaths = []
    7169        for fac in faculties.values():
    7270            for dep in fac.values():
    73                 depcodes.append(dep.code)
    7471                deppaths.append('%s/%s' % (fac.code, dep.code))
    75         codes = tuple(sorted([x for x in depcodes],
    76                                  key=lambda x: x.lower()))
    7772        paths = tuple(sorted([x for x in deppaths],
    7873                                 key=lambda x: x.lower()))
     
    8782        result = cat.searchResults(current_session=(session, session))
    8883    table = [[0 for x in xrange(2*len(payment_cats))]
    89                 for y in xrange(len(codes)+1)]
     84                for y in xrange(len(paths)+1)]
    9085    mode_groups = getUtility(IKofaUtils).MODE_GROUPS
    9186    for stud in result:
     
    9792        if entry_session != 0 and  stud.entry_session != entry_session:
    9893            continue
    99         if getattr(stud, breakdown) not in codes:
    100             # studs can have a faccode ``None``
    101             continue
    102         row = codes.index(getattr(stud, breakdown))
     94        if breakdown == 'faccode':
     95            if getattr(stud, 'faccode') not in paths:
     96                # studs can have a faccode ``None``
     97                continue
     98        # Dep codes are not unique.
     99        if breakdown == 'depcode':
     100            row = paths.index(
     101                '%s/%s' % (getattr(stud, 'faccode'), getattr(stud, 'depcode')))
     102        else:
     103            row = paths.index(getattr(stud, breakdown))
    103104        for key in stud['payments'].keys():
    104105            ticket = stud['payments'][key]
  • main/waeup.kofa/trunk/src/waeup/kofa/students/reports/tests/test_student_payment_statistics.py

    r14513 r15243  
    5353        return
    5454
    55     def test_create_pdf(self):
     55    def test_create_pdf_1(self):
    5656        report = StudentPaymentStatisticsReport(
    5757            2010, 'Undergraduate Full-Time', 0, 0, 0, 'faccode')
    5858        result = report.create_pdf('JOB_ID')
    5959        self.assertTrue(result.startswith('%PDF-'))
    60         path = os.path.join(samples_dir(), 'student_payment_statistics.pdf')
     60        path = os.path.join(samples_dir(), 'student_payment_statistics_faccode.pdf')
    6161        open(path, 'wb').write(result)
    62         print "Sample PDF student_statistics.pdf written to %s" % path
     62        print "Sample PDF student_statistics_faccode.pdf written to %s" % path
     63        return
     64
     65    def test_create_pdf_2(self):
     66        report = StudentPaymentStatisticsReport(
     67            2010, 'Undergraduate Full-Time', 0, 0, 0, 'depcode')
     68        result = report.create_pdf('JOB_ID')
     69        self.assertTrue(result.startswith('%PDF-'))
     70        path = os.path.join(samples_dir(), 'student_payment_statistics_depcode.pdf')
     71        open(path, 'wb').write(result)
     72        print "Sample PDF student_statistics_depcode.pdf written to %s" % path
    6373        return
    6474
Note: See TracChangeset for help on using the changeset viewer.