Changeset 8700


Ignore:
Timestamp:
12 Jun 2012, 21:01:17 (12 years ago)
Author:
Henrik Bettermann
Message:

Catalogue all kinds of payments not only student payments.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_catalog.py

    r7811 r8700  
    2121import shutil
    2222import tempfile
     23import grok
     24from zope.component import getUtility, createObject
    2325from hurry.query import Eq
    2426from hurry.query.interfaces import IQuery
     
    8688        self.assertTrue(isinstance(result_applicant, Applicant))
    8789        self.assertEqual(result_applicant.applicant_id, self.applicant.applicant_id)
     90
     91    def test_get_payment(self):
     92        self.create_applicant()
     93        q = getUtility(IQuery)
     94        subquery = Eq(('applicants_catalog', 'applicant_id'),
     95            self.applicant.applicant_id)
     96        results = list(q.searchResults(subquery))
     97        self.assertEqual(len(results), 1)
     98        result_applicant = results[0]
     99        payment = createObject('waeup.ApplicantOnlinePayment')
     100        payment.p_id = 'p1234567890'
     101        payment.p_item = u'Payment Item'
     102        payment.p_session = 2011
     103        payment.p_category = 'application'
     104        result_applicant[payment.p_id] = payment
     105        # We can find a payment ticket by the payment session ...
     106        cat = getUtility(ICatalog, name='payments_catalog')
     107        results = cat.searchResults(p_session=(2011, 2011))
     108        results = [x for x in results] # Turn results generator into list
     109        assert len(results) == 1
     110        assert results[0] is result_applicant['p1234567890']
     111        # ... and by the payment id
     112        results = cat.searchResults(p_id=('p1234567890', 'p1234567890'))
     113        assert len(results) == 1
     114        # If we remove the applicant also the payment disappears
     115        del self.app['applicants']['mystuff'][result_applicant.application_number]
     116        results = cat.searchResults(p_id=('p1234567890', 'p1234567890'))
     117        assert len(results) == 0
  • main/waeup.kofa/trunk/src/waeup/kofa/students/catalog.py

    r8404 r8700  
    2626from waeup.kofa.interfaces import (
    2727    IUniversity, IQueryResultItem, academic_sessions_vocab)
    28 from waeup.kofa.students.interfaces import (IStudent, ICourseTicket,
    29     IStudentOnlinePayment)
     28from waeup.kofa.students.interfaces import IStudent, ICourseTicket
    3029from waeup.kofa.university.vocabularies import course_levels
    3130
     
    129128    session = index.Field(attribute='getLevelSession')
    130129    code = index.Field(attribute='code')
    131 
    132 class StudentPaymentIndexes(grok.Indexes):
    133     """A catalog for payments.
    134     """
    135     grok.site(IUniversity)
    136     grok.name('payments_catalog')
    137     grok.context(IStudentOnlinePayment)
    138 
    139     p_session = index.Field(attribute='p_session')
    140     p_category = index.Field(attribute='p_category')
    141     p_item = index.Field(attribute='p_item')
    142     p_state = index.Field(attribute='p_state')
Note: See TracChangeset for help on using the changeset viewer.