Changeset 6996 for main/waeup.sirp/trunk/src
- Timestamp:
- 4 Nov 2011, 14:36:44 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/hostels/browser.py
r6988 r6996 35 35 from waeup.sirp.authentication import get_principal_role_manager 36 36 from waeup.sirp.hostels.container import HostelsContainer 37 from waeup.sirp.hostels.hostel import Hostel 37 from waeup.sirp.hostels.hostel import Hostel, NOT_OCCUPIED 38 38 from waeup.sirp.hostels.interfaces import IHostelsContainer, IHostel 39 39 … … 204 204 'Switch reservation of selected beds', 205 205 'Release selected beds'] 206 not_occupied = NOT_OCCUPIED 206 207 207 208 @property 208 209 def title(self): 209 210 return self.context.hostel_name 211 212 @property 213 def students_url(self): 214 return self.url(grok.getSite(),'students') 210 215 211 216 def update(self): -
main/waeup.sirp/trunk/src/waeup/sirp/hostels/browser_templates/hostelmanagepage.pt
r6971 r6996 79 79 tal:attributes="value value/__name__" /> 80 80 </td> 81 <td> <a tal:attributes="href value/__name__"> 82 <span tal:content="value/bed_id">Id</span> 83 </a></td> 81 <td tal:content="value/bed_id">Id</td> 84 82 <td tal:content="value/bed_type">Type</td> 85 83 <td tal:content="value/bed_number">Number</td> 86 <td tal:content="value/owner">Owner</td> 84 <td> 85 <a tal:condition="python: value.owner != view.not_occupied" 86 tal:attributes="href python: '%s/%s' % (view.students_url,value.owner)"> 87 <span tal:content="value/owner">Owner</span> 88 </a> 89 </td> 87 90 </tr> 88 91 </tbody> -
main/waeup.sirp/trunk/src/waeup/sirp/hostels/hostel.py
r6991 r6996 121 121 return self.bed_id.split('_') 122 122 123 def bookBed(self, student_id): 124 self.owner = student_id 125 return 126 123 127 def switchReservation(self): 124 128 """Reserves a bed or unreserve bed respectively. -
main/waeup.sirp/trunk/src/waeup/sirp/hostels/interfaces.py
r6981 r6996 142 142 """Determine the coordinates from bed_id. 143 143 """ 144 def bookBed(student_id): 145 """Book a bed for a student. 146 """ 144 147 145 148 def switchReservation(): -
main/waeup.sirp/trunk/src/waeup/sirp/students/accommodation.py
r6994 r6996 60 60 super(BedTicket, self).__init__() 61 61 self.booking_date = datetime.now() 62 self.bed = None 62 63 return 63 64 -
main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py
r6994 r6996 19 19 from time import time 20 20 from datetime import date, datetime 21 from zope.catalog.interfaces import ICatalog 22 from zope.component import queryUtility 21 23 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState 22 24 from zope.component import createObject … … 47 49 from waeup.sirp.students.studylevel import StudentStudyLevel, CourseTicket 48 50 from waeup.sirp.students.vocabularies import StudyLevelSource 49 from waeup.sirp.students.utils import getPaymentDetails50 from waeup.sirp.students.utils import getAccommodationDetails 51 from waeup.sirp.students.utils import ( 52 getPaymentDetails, getAccommodationDetails,) 51 53 from waeup.sirp.browser.resources import toggleall 52 54 from waeup.sirp.authentication import get_principal_role_manager … … 1089 1091 1090 1092 def update(self, SUBMIT=None): 1091 acc_details = self.getAccommodationDetails(self.context.__parent__) 1092 if not self.context.getStudent().state in acc_details['allowed_states']: 1093 student = self.context.getStudent() 1094 acc_details = self.getAccommodationDetails(student) 1095 if not student.state in acc_details['allowed_states']: 1093 1096 self.flash("Wrong state.") 1094 1097 self.redirect(self.url(self.context)) … … 1119 1122 bedticket.booking_code = pin 1120 1123 bedticket.booking_session = acc_details['booking_session'] 1121 bedticket.bed = u'Test Bed' 1122 self.context[str(acc_details['booking_session'])] = bedticket 1123 self.flash('Bed ticket created.') 1124 bedticket.bed_type = acc_details['bt'] 1125 # Search and book bed 1126 cat = queryUtility(ICatalog, name='beds_catalog', default=None) 1127 entries = cat.searchResults( 1128 bed_type=(bedticket.bed_type,bedticket.bed_type)) 1129 bed = [entry for entry in entries if entry.owner == NOT_OCCUPIED][0] # first bed found 1130 bed.bookBed(student.student_id) 1131 bedticket.bed = bed # maybe wo don't need the bed object itself 1132 hall_title = bed.__parent__.hostel_name 1133 coordinates = bed.getBedCoordinates()[1:] 1134 block, room_nr, bed_nr = coordinates 1135 bedticket.bed_coordinates = '%s, Block %s, Room %s, Bed %s' % ( 1136 hall_title, block, room_nr, bed_nr) 1137 key = str(acc_details['booking_session']) 1138 self.context[key] = bedticket 1139 self.flash('Bed ticket created and bed booked: %s' 1140 % bedticket.bed_coordinates) 1124 1141 self.redirect(self.url(self.context)) 1125 1142 return -
main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py
r6994 r6996 1 1 ## 2 2 ## interfaces.py 3 from datetime import datetime 3 4 from zope.interface import Attribute, invariant 4 5 from zope.interface.exceptions import Invalid … … 9 10 from waeup.sirp.students.vocabularies import ( 10 11 CertificateSource, academic_sessions_vocab, verdicts, StudyLevelSource, 11 contextual_reg_num_source, contextual_mat_num_source, 12 contextual_reg_num_source, contextual_mat_num_source, GenderSource, 12 13 ) 13 14 from waeup.sirp.payments.interfaces import IPaymentsContainer, IOnlinePayment … … 110 111 ) 111 112 113 sex = schema.Choice( 114 title = u'Sex', 115 source = GenderSource(), 116 default = u'm', 117 required = True, 118 ) 119 112 120 reg_number = TextLineChoice( 113 121 title = u'Registration Number', … … 132 140 readonly = True, 133 141 ) 142 143 class IStudentClearance(IWAeUPObject): 144 """Representation of student clearance data. 145 """ 146 147 date_of_birth = schema.Date( 148 title = u'Date of Birth', 149 required = True, 150 ) 151 152 clearance_locked = schema.Bool( 153 title = u'Clearance form locked', 154 default = False, 155 ) 156 157 clr_code = schema.TextLine( 158 title = u'CLR Activation Code', 159 default = u'', 160 required = False, 161 readonly = True, 162 ) 163 164 class IStudentPersonal(IWAeUPObject): 165 """Representation of student personal data. 166 """ 167 168 perm_address = schema.Text( 169 title = u'Permanent Address', 170 required = False, 171 ) 172 173 class IStudent(IStudentBase,IStudentClearance,IStudentPersonal): 174 """Representation of a student. 175 """ 176 177 class IStudentUpdateByRegNo(IStudent): 178 """Representation of a student. Skip regular reg_number validation. 179 """ 180 181 reg_number = schema.TextLine( 182 title = u'Registration Number', 183 default = None, 184 required = False, 185 ) 186 187 class IStudentUpdateByMatricNo(IStudent): 188 """Representation of a student. Skip regular matric_number validation. 189 """ 190 191 matric_number = schema.TextLine( 192 title = u'Matriculation Number', 193 default = None, 194 required = False, 195 ) 196 197 class IStudentStudyCourse(IWAeUPObject): 198 """A container for student study levels. 199 200 """ 201 202 certificate = schema.Choice( 203 title = u'Certificate', 204 source = CertificateSource(), 205 default = None, 206 required = True, 207 ) 208 134 209 135 210 entry_mode = schema.Choice( … … 141 216 ) 142 217 143 class IStudentClearance(IWAeUPObject): 144 """Representation of student clearance data. 145 """ 146 147 date_of_birth = schema.Date( 148 title = u'Date of Birth', 149 required = True, 150 ) 151 152 clearance_locked = schema.Bool( 153 title = u'Clearance form locked', 154 default = False, 155 ) 156 157 clr_code = schema.TextLine( 158 title = u'CLR Activation Code', 159 default = u'', 160 required = False, 161 readonly = True, 162 ) 163 164 class IStudentPersonal(IWAeUPObject): 165 """Representation of student personal data. 166 """ 167 168 perm_address = schema.Text( 169 title = u'Permanent Address', 170 required = False, 171 ) 172 173 class IStudent(IStudentBase,IStudentClearance,IStudentPersonal): 174 """Representation of a student. 175 """ 176 177 class IStudentUpdateByRegNo(IStudent): 178 """Representation of a student. Skip regular reg_number validation. 179 """ 180 181 reg_number = schema.TextLine( 182 title = u'Registration Number', 183 default = None, 184 required = False, 185 ) 186 187 class IStudentUpdateByMatricNo(IStudent): 188 """Representation of a student. Skip regular matric_number validation. 189 """ 190 191 matric_number = schema.TextLine( 192 title = u'Matriculation Number', 193 default = None, 194 required = False, 195 ) 196 197 class IStudentStudyCourse(IWAeUPObject): 198 """A container for student study levels. 199 200 """ 201 202 certificate = schema.Choice( 203 title = u'Certificate', 204 source = CertificateSource(), 205 default = None, 206 required = True, 218 entry_session = schema.Choice( 219 title = u'Entry Session', 220 source = academic_sessions_vocab, 221 default = datetime.now().year, 222 required = True, 223 readonly = False, 207 224 ) 208 225 … … 212 229 default = None, 213 230 required = True, 231 readonly = False, 214 232 ) 215 233 … … 219 237 default = None, 220 238 required = False, 239 readonly = False, 221 240 ) 222 241 … … 320 339 """ 321 340 322 bed = schema.TextLine( 323 title = u'Bed', 341 bed = Attribute('The bed object.') 342 343 bed_coordinates = schema.TextLine( 344 title = u'Bed Coordinates', 345 default = None, 346 required = False, 347 ) 348 349 bed_type = schema.TextLine( 350 title = u'Bed Type', 324 351 default = None, 325 352 required = False, -
main/waeup.sirp/trunk/src/waeup/sirp/students/utils.py
r6994 r6996 45 45 d['amount'] = academic_session.fee_2 46 46 elif category == 'bed_allocation': 47 #d['p_item'] = student['studycourse'].certificate.code47 d['p_item'] = getBedType(student) 48 48 d['amount'] = academic_session.booking_fee 49 49 return d … … 53 53 def getAccommodationDetails(student): 54 54 d = {} 55 d['bookin_fee'] = d['maint_fee'] = 056 55 d['error'] = u'' 57 56 site_confoguration = getSite()['configuration'] … … 59 58 d['allowed_states'] = site_confoguration.accommodation_states 60 59 session = str(d['booking_session']) 60 # Determine bed type 61 studycourse = student['studycourse'] 62 entry_session = studycourse.entry_session 63 current_level = studycourse.current_level 64 end_level = studycourse.certificate.end_level 65 if entry_session == getSite()['configuration'].accommodation_session: 66 bt = 'fr' 67 elif current_level >= end_level: 68 bt = 'fi' 69 else: 70 bt = 're' 71 if student.sex == 'f': 72 sex = 'female' 73 else: 74 sex = 'male' 75 special_handling = 'regular' 76 d['bt'] = u'%s_%s_%s' % (special_handling,sex,bt) 61 77 return d
Note: See TracChangeset for help on using the changeset viewer.