Ignore:
Timestamp:
3 Nov 2012, 18:47:31 (12 years ago)
Author:
Henrik Bettermann
Message:

Clearly separate current and previous session payment browser components.

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

Legend:

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

    r9516 r9517  
    13381338        return
    13391339
    1340     @action(_('Add online payment ticket'))
    1341     def addPaymentTicket(self, **data):
    1342         self.redirect(self.url(self.context, '@@addop'))
     1340    #@action(_('Add online payment ticket'))
     1341    #def addPaymentTicket(self, **data):
     1342    #    self.redirect(self.url(self.context, '@@addop'))
    13431343
    13441344class OnlinePaymentAddFormPage(KofaAddFormPage):
     
    13781378        if error is not None:
    13791379            self.flash(error)
    1380             if 'previous session' in error or 'Would you like' in error:
    1381                 self.redirect(self.url(self.context) + '/@@addpp')
    1382                 return
    1383             self.redirect(self.url(self.context))
    13841380            return
    13851381        self.context[payment.p_id] = payment
     
    14021398    label = _('Add previous session online payment')
    14031399    pnav = 4
     1400
     1401    def update(self):
     1402        if self.context.student.is_fresh:
     1403            self.flash(_("You can't pay for a session below your entry session."))
     1404            self.redirect(self.url(self.context))
     1405        super(PreviousPaymentAddFormPage, self).update()
     1406        return
    14041407
    14051408class OnlinePaymentDisplayFormPage(KofaDisplayFormPage):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/student.py

    r9334 r9517  
    3636from waeup.kofa.interfaces import (
    3737    IObjectHistory, IUserAccount, IFileStoreNameChooser, IFileStoreHandler,
    38     IKofaUtils, CLEARANCE, registration_states_vocab, IExtFileStore,)
     38    IKofaUtils, registration_states_vocab, IExtFileStore,
     39    CLEARANCE)
    3940from waeup.kofa.students.accommodation import StudentAccommodation
    4041from waeup.kofa.students.export import EXPORTER_NAMES
     
    190191            self.get('studycourse', None), 'is_postgrad', False)
    191192        return is_postgrad
     193
     194    @property
     195    def is_fresh(self):
     196        entry_session = getattr(
     197            self.get('studycourse', None), 'entry_session', None)
     198        if self.current_session == entry_session:
     199            return True
     200        return False
    192201
    193202    def transfer(self, certificate, current_session=None,
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r9516 r9517  
    760760        self.browser.open(self.payments_path)
    761761        IWorkflowState(self.student).setState('cleared')
    762         self.browser.getControl("Add online payment ticket").click()
     762        self.browser.getLink("Add current session payment ticket").click()
    763763        self.browser.getControl(name="form.p_category").value = ['schoolfee']
    764764        self.browser.getControl("Create ticket").click()
     
    781781        # can be initialized a second time if the former ticket is not yet paid.
    782782        self.browser.open(self.payments_path)
    783         self.browser.getControl("Add online payment ticket").click()
     783        self.browser.getLink("Add current session payment ticket").click()
    784784        self.browser.getControl(name="form.p_category").value = ['schoolfee']
    785785        self.browser.getControl("Create ticket").click()
     
    827827        # (with same p_item, p_session and p_category) can be added
    828828        self.browser.open(self.payments_path)
    829         self.browser.getControl("Add online payment ticket").click()
     829        self.browser.getLink("Add current session payment ticket").click()
    830830        self.browser.getControl(name="form.p_category").value = ['schoolfee']
    831831        self.browser.getControl("Create ticket").click()
     
    833833            '...This type of payment has already been made...',
    834834            self.browser.contents)
    835         # The PreviousPaymentAddFormPage opens
    836         self.assertEqual(self.browser.url, self.payments_path + '/@@addpp')
    837835
    838836        # Managers can open the pdf payment slip
     
    887885        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    888886        self.browser.open(self.payments_path)
    889         self.browser.getControl("Add online payment ticket").click()
     887        self.browser.getLink("Add current session payment ticket").click()
    890888        self.browser.getControl(name="form.p_category").value = ['bed_allocation']
    891889        # If student is not in accommodation session, payment cannot be processed
     
    895893                           self.browser.contents)
    896894        self.app['hostels'].accommodation_session = 2004
    897         self.browser.getControl("Add online payment ticket").click()
     895        self.browser.getLink("Add current session payment ticket").click()
    898896        self.browser.getControl(name="form.p_category").value = ['bed_allocation']
    899897        self.browser.getControl("Create ticket").click()
     
    20462044        self.assertRaises(
    20472045            LookupError, self.browser.getControl, name='val_id')
    2048         self.browser.getControl("Add online payment ticket").click()
     2046        self.browser.getLink("Add current session payment ticket").click()
    20492047        self.browser.getControl(name="form.p_category").value = ['schoolfee']
    20502048        self.browser.getControl("Create ticket").click()
     
    21362134        configuration2.booking_fee = 123.4
    21372135        self.app['configuration'].addSessionConfiguration(configuration2)
    2138 
     2136        configuration3 = createObject('waeup.SessionConfiguration')
     2137        configuration3.academic_session = 2005
     2138        configuration3.clearance_fee = 3456.0
     2139        configuration3.booking_fee = 123.4
     2140        self.app['configuration'].addSessionConfiguration(configuration3)
    21392141        self.student['studycourse'].entry_session = 2002
    21402142
     
    21482150        IWorkflowState(self.student).setState('courses registered')
    21492151        self.browser.open(self.payments_path)
    2150         self.browser.getControl("Add online payment ticket").click()
    2151         self.browser.getControl(name="form.p_category").value = ['schoolfee']
    2152         self.browser.getControl("Create ticket").click()
    2153 
    2154         # Amount cannot be determined since the state is not
    2155         # 'cleared' or 'returning'
    2156         self.assertMatches('...Amount could not be determined...',
    2157                            self.browser.contents)
    2158         self.assertMatches('...Would you like to pay for a previous session?...',
    2159                            self.browser.contents)
     2152        self.browser.getLink("Add previous session payment ticket").click()
    21602153
    21612154        # Previous session payment form is provided
     2155        self.assertEqual(self.student.current_session, 2004)
    21622156        self.browser.getControl(name="form.p_category").value = ['schoolfee']
    21632157        self.browser.getControl(name="form.p_session").value = ['2000']
     
    21672161                           self.browser.contents)
    21682162        self.browser.getControl(name="form.p_category").value = ['schoolfee']
    2169         self.browser.getControl(name="form.p_session").value = ['2004']
     2163        self.browser.getControl(name="form.p_session").value = ['2005']
    21702164        self.browser.getControl(name="form.p_level").value = ['300']
    21712165        self.browser.getControl("Create ticket").click()
    21722166        self.assertMatches('...This is not a previous session...',
    21732167                           self.browser.contents)
     2168        # Students can pay current session school fee.
    21742169        self.browser.getControl(name="form.p_category").value = ['schoolfee']
    2175         self.browser.getControl(name="form.p_session").value = ['2003']
     2170        self.browser.getControl(name="form.p_session").value = ['2004']
    21762171        self.browser.getControl(name="form.p_level").value = ['300']
    21772172        self.browser.getControl("Create ticket").click()
     
    21862181
    21872182        # Payment session is properly set
    2188         self.assertEqual(self.student['payments'][value].p_session, 2003)
     2183        self.assertEqual(self.student['payments'][value].p_session, 2004)
    21892184        self.assertEqual(self.student['payments'][value].p_level, 300)
    21902185
     
    22002195        # Current payment flag is set False
    22012196        self.assertFalse(self.student['payments'][value].p_current)
     2197
     2198        # Button and form are not available for fresh students
     2199        self.student['studycourse'].entry_session = 2004
     2200        self.browser.open(self.payments_path)
     2201        self.assertFalse(
     2202            "Add previous session payment ticket" in self.browser.contents)
     2203        self.browser.open(self.payments_path + '/addpp')
     2204        self.assertTrue(
     2205            "You can't pay for a session below your entry session" in
     2206            self.browser.contents)
    22022207        return
    22032208
     
    22152220        IWorkflowState(self.student).setState('cleared')
    22162221        self.browser.open(self.payments_path)
    2217         self.browser.getControl("Add online payment ticket").click()
     2222        self.browser.getLink("Add current session payment ticket").click()
    22182223        self.browser.getControl(name="form.p_category").value = ['schoolfee']
    22192224        self.browser.getControl("Create ticket").click()
     
    22552260        # Remove first payment to be sure that we access the right ticket
    22562261        del self.student['payments'][value]
    2257         self.browser.getControl("Add online payment ticket").click()
     2262        self.browser.getLink("Add current session payment ticket").click()
    22582263        self.browser.getControl(name="form.p_category").value = ['schoolfee']
    22592264        self.browser.getControl("Create ticket").click()
     
    23012306        # callback view (see test_manage_payments)
    23022307        self.browser.getLink("Payments").click()
    2303         self.browser.getControl("Add online payment ticket").click()
     2308        self.browser.getLink("Add current session payment ticket").click()
    23042309        self.browser.getControl(name="form.p_category").value = ['bed_allocation']
    23052310        self.browser.getControl("Create ticket").click()
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r9516 r9517  
    309309        amount = 0.0
    310310        if previous_session:
     311            if previous_session < student['studycourse'].entry_session:
     312                return _('The previous session must not fall below '
     313                         'your entry session.'), None
     314            if category == 'schoolfee':
     315                # School fee is always paid for the following session
     316                if previous_session > student['studycourse'].current_session:
     317                    return _('This is not a previous session.'), None
     318            else:
     319                if previous_session > student['studycourse'].current_session - 1:
     320                    return _('This is not a previous session.'), None
    311321            p_session = previous_session
    312322            p_level = previous_level
     
    328338                return _('Study course data are incomplete.'), None
    329339            if previous_session:
    330                 if previous_session < student['studycourse'].entry_session:
    331                     return _('The previous session must not fall below '
    332                              'your entry session.'), None
    333                 if previous_session > student['studycourse'].current_session - 1:
    334                     return _('This is not a previous session.'), None
     340                # Students can pay for previous sessions in all workflow states.
     341                # Fresh students are excluded by the update method of the
     342                # PreviousPaymentAddFormPage.
    335343                if previous_level == 100:
    336344                    amount = getattr(certificate, 'school_fee_1', 0.0)
     
    343351                    # In case of returning school fee payment the payment session
    344352                    # and level contain the values of the session the student
    345                     # has paid for.
     353                    # has paid for. Payment session is always next session.
    346354                    p_session, p_level = self.getReturningData(student)
    347355                    amount = getattr(certificate, 'school_fee_2', 0.0)
     
    372380                p_item = trans(_('no bed allocated'), portal_language)
    373381        if amount in (0.0, None):
    374             return _('Amount could not be determined.' +
    375                      ' Would you like to pay for a previous session?'), None
     382            return _('Amount could not be determined.'), None
    376383        for key in student['payments'].keys():
    377384            ticket = student['payments'][key]
     
    380387               ticket.p_item == p_item and \
    381388               ticket.p_session == p_session:
    382                   return _('This type of payment has already been made.' +
    383                            ' Would you like to pay for another session?'), None
     389                  return _('This type of payment has already been made.'), None
    384390        payment = createObject(u'waeup.StudentOnlinePayment')
    385391        timestamp = ("%d" % int(time()*10000))[1:]
  • main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py

    r9452 r9517  
    4343    CourseTicketDisplayFormPage, OnlinePaymentDisplayFormPage,
    4444    AccommodationManageFormPage, BedTicketDisplayFormPage,
    45     StudentClearanceEditFormPage, StudentPersonalEditFormPage)
     45    StudentClearanceEditFormPage, StudentPersonalEditFormPage,
     46    PaymentsManageFormPage)
    4647from waeup.kofa.students.interfaces import (
    4748    IStudentsContainer, IStudent, IStudentStudyCourse, IStudentAccommodation,
    4849    IStudentStudyLevel, ICourseTicket, IStudentOnlinePayment, IBedTicket,
     50    IStudentPaymentsContainer,
    4951    )
    5052from waeup.kofa.utils.helpers import get_fileformat
     
    589591            return self.view.url(self.view.context, self.target)
    590592        return ''
     593
     594class AddPaymentActionButton(AddActionButton):
     595    grok.order(1)
     596    grok.context(IStudentPaymentsContainer)
     597    grok.view(PaymentsManageFormPage)
     598    grok.require('waeup.payStudent')
     599    text = _('Add current session payment ticket')
     600    target = 'addop'
     601
     602class AddPreviousPaymentActionButton(AddActionButton):
     603    grok.order(2)
     604    grok.context(IStudentPaymentsContainer)
     605    grok.view(PaymentsManageFormPage)
     606    grok.require('waeup.payStudent')
     607    text = _('Add previous session payment ticket')
     608    target = 'addpp'
     609
     610    @property
     611    def target_url(self):
     612        student = self.view.context.student
     613        if student.is_fresh:
     614            return ''
     615        return self.view.url(self.view.context, self.target)
    591616
    592617class StudentsTab(PrimaryNavTab):
Note: See TracChangeset for help on using the changeset viewer.