- Timestamp:
- 21 Sep 2012, 08:19:35 (12 years ago)
- Location:
- main/waeup.kofa/branches/uli-zc-async
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/branches/uli-zc-async
- Property svn:mergeinfo changed
/main/waeup.kofa/branches/uli-async-update removed /main/waeup.kofa/branches/uli-autoinclude-less removed /main/waeup.kofa/trunk removed
- Property svn:mergeinfo changed
-
main/waeup.kofa/branches/uli-zc-async/src/waeup/kofa/hostels/hostel.py
r9209 r9211 22 22 from zope.event import notify 23 23 from zope.component import getUtility 24 from zope.component.interfaces import IFactory25 24 from datetime import datetime 26 25 from waeup.kofa.utils.helpers import attrs_to_fields … … 41 40 target = self.__name__ 42 41 return grok.getSite()['hostels'].logger_info(ob_class,target,comment) 43 44 @property45 def bed_statistics(self):46 total = len(self.keys())47 booked = 048 for value in self.values():49 if value.owner != NOT_OCCUPIED:50 booked += 151 return {'booked':booked, 'total':total}52 53 def clearHostel(self):54 """Remove all beds55 """56 keys = [i for i in self.keys()] # create deep copy57 for bed in keys:58 del self[bed]59 return60 42 61 43 def addBed(self, bed): … … 146 128 grok.provides(IBed) 147 129 148 @property 149 def coordinates(self): 130 def getBedCoordinates(self): 150 131 """Determine the coordinates from the bed_id. 151 132 """ 152 133 return self.bed_id.split('_') 153 154 # The following property attributes are only needed155 # for the exporter to ease evaluation with Excel.156 157 @property158 def hall(self):159 return self.coordinates[0]160 161 @property162 def block(self):163 return self.coordinates[1]164 165 @property166 def room(self):167 return self.coordinates[2]168 169 @property170 def bed(self):171 return self.coordinates[3]172 173 @property174 def special_handling(self):175 return self.bed_type.split('_')[0]176 177 @property178 def sex(self):179 return self.bed_type.split('_')[1]180 181 @property182 def bt(self):183 return self.bed_type.split('_')[2]184 185 134 186 135 def bookBed(self, student_id): … … 196 145 """ 197 146 sh, sex, bt = self.bed_type.split('_') 198 hostel_id, block, room_nr, bed = self. coordinates147 hostel_id, block, room_nr, bed = self.getBedCoordinates() 199 148 hostel = self.__parent__ 200 149 beds_for_fresh = getattr(hostel,'beds_for_fresh',[]) … … 272 221 Bed = attrs_to_fields(Bed) 273 222 274 class HostelFactory(grok.GlobalUtility):275 """A factory for hostels.276 277 We need this factory for the hostel processor.278 """279 grok.implements(IFactory)280 grok.name(u'waeup.Hostel')281 title = u"Create a new hostel.",282 description = u"This factory instantiates new hostel instances."283 284 def __call__(self, *args, **kw):285 return Hostel()286 287 def getInterfaces(self):288 return implementedBy(Hostel)289 290 291 223 @grok.subscribe(IBedTicket, grok.IObjectRemovedEvent) 292 224 def handle_bedticket_removed(bedticket, event): … … 297 229 bedticket.bed.owner = NOT_OCCUPIED 298 230 notify(grok.ObjectModifiedEvent(bedticket.bed)) 299
Note: See TracChangeset for help on using the changeset viewer.