- Timestamp:
- 30 Oct 2013, 19:43:48 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/utils.py
r10672 r10675 20 20 from time import time 21 21 from zope.component import createObject, getUtility 22 from zope.catalog.interfaces import ICatalog 22 23 from waeup.kofa.interfaces import CLEARED, RETURNING, PAID 23 24 from kofacustom.nigeria.students.utils import NigeriaStudentsUtils … … 25 26 from waeup.kofa.interfaces import CLEARED, RETURNING, IKofaUtils 26 27 from waeup.kofa.fees import FeeTable 28 from waeup.kofa.hostels.hostel import NOT_OCCUPIED 27 29 from waeup.kwarapoly.interfaces import MessageFactory as _ 28 30 … … 124 126 new_session = student['studycourse'].current_session + 1 125 127 return new_session, new_level 128 129 def _maintPaymentMade(self, student, session): 130 if len(student['payments']): 131 for ticket in student['payments'].values(): 132 if ticket.p_category == 'hostel_maintenance' and \ 133 ticket.p_session == session and ticket.p_state == 'paid': 134 return True 135 return False 136 137 def _bedAvailable(self, student): 138 acc_details = self.getAccommodationDetails(student) 139 cat = getUtility(ICatalog, name='beds_catalog') 140 entries = cat.searchResults( 141 owner=(student.student_id,student.student_id)) 142 if len(entries): 143 # Bed has already been booked. 144 return True 145 entries = cat.searchResults( 146 bed_type=(acc_details['bt'],acc_details['bt'])) 147 available_beds = [ 148 entry for entry in entries if entry.owner == NOT_OCCUPIED] 149 if available_beds: 150 # Bed has not yet been booked but beds are available. 151 return True 152 return False 126 153 127 154 def setPaymentDetails(self, category, student, … … 170 197 if academic_session == None: 171 198 return _(u'Session configuration object is not available.'), None 199 if student.state == CLEARED: 200 # Fresh students must have booked and paid for accommodation. 201 if self._bedAvailable(student): 202 if not self._maintPaymentMade(student, p_session): 203 return _('Book and pay for accommodation first ' 204 'before making school fee payments.'), None 172 205 if student.state in (RETURNING, CLEARED): 173 206 if p_level in PAYMENT_LEVELS:
Note: See TracChangeset for help on using the changeset viewer.