Changeset 12514


Ignore:
Timestamp:
24 Jan 2015, 13:26:53 (10 years ago)
Author:
Henrik Bettermann
Message:

Add temporary view which helps to find students with faked payment tickets.

This view is untested.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.uniben/trunk/src/waeup/uniben/browser/pages.py

    r10202 r12514  
    1717##
    1818import grok
     19from zope.component import getUtility
     20from zope.catalog.interfaces import ICatalog
    1921from waeup.kofa.browser.pages import (
    2022    SessionConfigurationAddFormPage, SessionConfigurationManageFormPage,
    2123    LoginPage, CertificatePage, CertificateManageFormPage)
    2224from waeup.kofa.university.interfaces import ICertificate
     25from waeup.kofa.interfaces import IUniversity
    2326from waeup.uniben.interfaces import (
    2427    ICustomSessionConfiguration, ICustomSessionConfigurationAdd)
     28
     29
     30class ShowDuplicatePayments(grok.View):
     31    """List (in plain text format) payment ids which have been
     32    imported several times for different students.
     33    """
     34
     35    grok.context(IUniversity)
     36    grok.name('replicated_payments')
     37    grok.require('waeup.managePortal')
     38
     39    def search_replicated_payments(self):
     40        cat = getUtility(ICatalog, name='payments_catalog')
     41        all = list(cat.searchResults(p_id=(None, None)))
     42        output = ''
     43        hitlist = []
     44        for item in all:
     45            if not getattr(item,'student', None) or item.p_id in hitlist:
     46                continue
     47            replicates = cat.searchResults(p_id=(item.p_id, item.p_id))
     48            if len(replicates) > 1:
     49                hitlist.append(item.p_id)
     50                replicates_line = ''
     51                for p in replicates:
     52                    student = getattr(p,'student', None)
     53                    if student is not None:
     54                        replicates_line += '%s (%s),' % (
     55                            student.student_id,
     56                            student.matric_number)
     57                output += "%s,%s\n" % (item.p_id, replicates_line)
     58        return output
     59
     60    def render(self):
     61        return self.search_replicated_payments()
     62
    2563
    2664class CustomSessionConfigurationAddFormPage(SessionConfigurationAddFormPage):
Note: See TracChangeset for help on using the changeset viewer.