Changeset 9423


Ignore:
Timestamp:
26 Oct 2012, 07:55:45 (12 years ago)
Author:
Henrik Bettermann
Message:

Use addBedticket properly.

Implement maintenance fee payment in base package and ensure that maintenance (rent) can only be paid if bed has been booked in current session.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
7 edited

Legend:

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

    r9416 r9423  
    291291        # Release bed which has previously been booked
    292292        bedticket = BedTicket()
    293         bedticket.ticket_id = u'2004'
     293        bedticket.booking_session = 2004
    294294        bedticket.bed_coordinates = u'anything'
    295295        self.student['accommodation'].addBedTicket(bedticket)
  • main/waeup.kofa/trunk/src/waeup/kofa/interfaces.py

    r9243 r9423  
    606606        )
    607607
     608    maint_fee = schema.Float(
     609        title = _(u'Rent'),
     610        default = 0.0,
     611        required = False,
     612        )
     613
    608614    def getSessionString():
    609615        """Returns the session string from the vocabulary.
  • main/waeup.kofa/trunk/src/waeup/kofa/students/accommodation.py

    r8736 r9423  
    3030
    3131class StudentAccommodation(grok.Container):
    32     """This is a container for accommodation objects.
     32    """This is a container for bed tickets.
    3333    """
    3434    grok.implements(IStudentAccommodation, IStudentNavigation)
     
    4545            raise TypeError(
    4646                'StudentAccommodation containers contain only IBedTicket instances')
    47         self[bedticket.ticket_id] = bedticket
     47        self[str(bedticket.booking_session)] = bedticket
    4848        return
    4949
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r9422 r9423  
    13391339                self.redirect(self.url(self.context))
    13401340                return
     1341        if 'maintenance' in p_category:
     1342            current_session = str(student['studycourse'].current_session)
     1343            if not student['accommodation'].has_key(current_session):
     1344                self.flash(_('You have not yet booked a bed.'))
     1345                self.redirect(self.url(self.context))
     1346                return
    13411347        students_utils = getUtility(IStudentsUtils)
    13421348        error, payment = students_utils.setPaymentDetails(
     
    16271633        bedticket.bed_coordinates = translate(
    16281634            bc, 'waeup.kofa',target_language=portal_language)
    1629         key = str(acc_details['booking_session'])
    1630         self.context[key] = bedticket
     1635        self.context.addBedTicket(bedticket)
    16311636        self.context.writeLogMessage(self, 'booked: %s' % bed.bed_id)
    16321637        self.flash(_('Bed ticket created and bed booked: ${a}',
  • main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py

    r9420 r9423  
    590590    """
    591591
     592    def addBedTicket(bedticket):
     593        """Add a bed ticket object.
     594        """
     595
     596
    592597class IBedTicket(IKofaObject):
    593598    """A ticket for accommodation booking.
     
    598603    bed_coordinates = schema.TextLine(
    599604        title = _(u'Bed Coordinates'),
    600         required = False,
     605        required = True,
    601606        readonly = False,
    602607        )
     
    604609    bed_type = schema.TextLine(
    605610        title = _(u'Bed Type'),
    606         required = False,
     611        required = True,
    607612        readonly = False,
    608613        )
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r9420 r9423  
    186186        configuration.clearance_fee = 3456.0
    187187        configuration.booking_fee = 123.4
     188        configuration.maint_fee = 987.0
    188189        self.app['configuration'].addSessionConfiguration(configuration)
    189190
     
    18891890                           self.browser.contents)
    18901891
    1891     def test_student_payments(self):
     1892    def test_student_clearance_payment(self):
    18921893        # Login
    18931894        self.browser.open(self.login_path)
     
    19651966                           self.browser.contents)
    19661967
     1968    def test_student_schoolfee_payment(self):
     1969        # Login
     1970        self.browser.open(self.login_path)
     1971        self.browser.getControl(name="form.login").value = self.student_id
     1972        self.browser.getControl(name="form.password").value = 'spwd'
     1973        self.browser.getControl("Login").click()
     1974
    19671975        # Students can add online school fee payment tickets.
    19681976        IWorkflowState(self.student).setState('returning')
    19691977        self.browser.open(self.payments_path)
     1978        self.assertRaises(
     1979            LookupError, self.browser.getControl, name='val_id')
    19701980        self.browser.getControl("Add online payment ticket").click()
    19711981        self.browser.getControl(name="form.p_category").value = ['schoolfee']
     
    19972007        self.assertMatches('...Payment approved...',
    19982008                          self.browser.contents)
    1999 
    2000         # Students can remove only online payment tickets which have
    2001         # not received a valid callback
    2002         self.browser.open(self.payments_path)
    2003         self.assertRaises(
    2004             LookupError, self.browser.getControl, name='val_id')
    2005         self.browser.open(self.payments_path + '/addop')
    2006         self.browser.getControl(name="form.p_category").value = ['bed_allocation']
    2007         self.browser.getControl("Create ticket").click()
    2008         self.browser.open(self.payments_path)
    2009         ctrl = self.browser.getControl(name='val_id')
    2010         value = ctrl.options[0]
    2011         ctrl.getControl(value=value).selected = True
    2012         self.browser.getControl("Remove selected", index=0).click()
    2013         self.assertTrue('Successfully removed' in self.browser.contents)
    20142009
    20152010        # The new SFE-0 pin can be used for starting new session
     
    20262021        self.assertTrue(self.student.state == 'school fee paid')
    20272022        return
     2023
     2024    def test_student_bedallocation_payment(self):
     2025        # Login
     2026        self.browser.open(self.login_path)
     2027        self.browser.getControl(name="form.login").value = self.student_id
     2028        self.browser.getControl(name="form.password").value = 'spwd'
     2029        self.browser.getControl("Login").click()
     2030        self.browser.open(self.payments_path)
     2031        self.browser.open(self.payments_path + '/addop')
     2032        self.browser.getControl(name="form.p_category").value = ['bed_allocation']
     2033        self.browser.getControl("Create ticket").click()
     2034        self.assertMatches('...ticket created...',
     2035                           self.browser.contents)
     2036        # Students can remove only online payment tickets which have
     2037        # not received a valid callback
     2038        self.browser.open(self.payments_path)
     2039        ctrl = self.browser.getControl(name='val_id')
     2040        value = ctrl.options[0]
     2041        ctrl.getControl(value=value).selected = True
     2042        self.browser.getControl("Remove selected", index=0).click()
     2043        self.assertTrue('Successfully removed' in self.browser.contents)
     2044
     2045    def test_student_maintenance_payment(self):
     2046        # Login
     2047        self.browser.open(self.login_path)
     2048        self.browser.getControl(name="form.login").value = self.student_id
     2049        self.browser.getControl(name="form.password").value = 'spwd'
     2050        self.browser.getControl("Login").click()
     2051        self.browser.open(self.payments_path)
     2052        self.browser.open(self.payments_path + '/addop')
     2053        self.browser.getControl(name="form.p_category").value = ['hostel_maintenance']
     2054        self.browser.getControl("Create ticket").click()
     2055        self.assertMatches('...You have not yet booked a bed...',
     2056                           self.browser.contents)
     2057        # We continue this test in test_student_accommodation
    20282058
    20292059    def test_student_previous_payments(self):
     
    22852315        self.assertFalse('Remove' in self.browser.contents)
    22862316        self.assertFalse('val_id' in self.browser.contents)
     2317
     2318        # Students can pay maintenance fee now
     2319        self.browser.open(self.payments_path)
     2320        self.browser.open(self.payments_path + '/addop')
     2321        self.browser.getControl(name="form.p_category").value = ['hostel_maintenance']
     2322        self.browser.getControl("Create ticket").click()
     2323        self.assertMatches('...Payment ticket created...',
     2324                           self.browser.contents)
    22872325        return
    22882326
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r9219 r9423  
    360360            p_item = self.getAccommodationDetails(student)['bt']
    361361            amount = academic_session.booking_fee
     362        elif category == 'hostel_maintenance':
     363            amount = academic_session.maint_fee
    362364        if amount in (0.0, None):
    363365            return _('Amount could not be determined.' +
Note: See TracChangeset for help on using the changeset viewer.