Ignore:
Timestamp:
21 Sep 2012, 08:19:35 (12 years ago)
Author:
uli
Message:

Rollback r9209. Looks like multiple merges from trunk confuse svn when merging back into trunk.

Location:
main/waeup.kofa/branches/uli-zc-async
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/branches/uli-zc-async

  • main/waeup.kofa/branches/uli-zc-async/src/waeup/kofa/hostels/hostel.py

    r9209 r9211  
    2222from zope.event import notify
    2323from zope.component import getUtility
    24 from zope.component.interfaces import IFactory
    2524from datetime import datetime
    2625from waeup.kofa.utils.helpers import attrs_to_fields
     
    4140        target = self.__name__
    4241        return grok.getSite()['hostels'].logger_info(ob_class,target,comment)
    43 
    44     @property
    45     def bed_statistics(self):
    46         total = len(self.keys())
    47         booked = 0
    48         for value in self.values():
    49             if value.owner != NOT_OCCUPIED:
    50                 booked += 1
    51         return {'booked':booked, 'total':total}
    52 
    53     def clearHostel(self):
    54         """Remove all beds
    55         """
    56         keys = [i for i in self.keys()] # create deep copy
    57         for bed in keys:
    58             del self[bed]
    59         return
    6042
    6143    def addBed(self, bed):
     
    146128    grok.provides(IBed)
    147129
    148     @property
    149     def coordinates(self):
     130    def getBedCoordinates(self):
    150131        """Determine the coordinates from the bed_id.
    151132        """
    152133        return self.bed_id.split('_')
    153 
    154     # The following property attributes are only needed
    155     # for the exporter to ease evaluation with  Excel.
    156 
    157     @property
    158     def hall(self):
    159         return self.coordinates[0]
    160 
    161     @property
    162     def block(self):
    163         return self.coordinates[1]
    164 
    165     @property
    166     def room(self):
    167         return self.coordinates[2]
    168 
    169     @property
    170     def bed(self):
    171         return self.coordinates[3]
    172 
    173     @property
    174     def special_handling(self):
    175         return self.bed_type.split('_')[0]
    176 
    177     @property
    178     def sex(self):
    179         return self.bed_type.split('_')[1]
    180 
    181     @property
    182     def bt(self):
    183         return self.bed_type.split('_')[2]
    184 
    185134
    186135    def bookBed(self, student_id):
     
    196145        """
    197146        sh, sex, bt = self.bed_type.split('_')
    198         hostel_id, block, room_nr, bed = self.coordinates
     147        hostel_id, block, room_nr, bed = self.getBedCoordinates()
    199148        hostel = self.__parent__
    200149        beds_for_fresh = getattr(hostel,'beds_for_fresh',[])
     
    272221Bed = attrs_to_fields(Bed)
    273222
    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 
    291223@grok.subscribe(IBedTicket, grok.IObjectRemovedEvent)
    292224def handle_bedticket_removed(bedticket, event):
     
    297229        bedticket.bed.owner = NOT_OCCUPIED
    298230        notify(grok.ObjectModifiedEvent(bedticket.bed))
    299 
Note: See TracChangeset for help on using the changeset viewer.