Changeset 9199


Ignore:
Timestamp:
18 Sep 2012, 21:07:02 (12 years ago)
Author:
Henrik Bettermann
Message:

Add hostels and beds exporter (tests will follow).

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
1 added
4 edited

Legend:

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

    r9197 r9199  
    9393
    9494    def title(self):
    95         co = self.context.getBedCoordinates()
     95        co = self.context.coordinates
    9696        return _('Block ${a}, Room ${b}, Bed ${c}',
    9797            mapping = {'a':co[1], 'b':co[2], 'c':co[3]})
     
    354354    grok.require('waeup.manageHostels')
    355355    form_fields = grok.AutoFields(IBedAllocateStudent).omit(
    356         'bed_id').omit('bed_number').omit('bed_type')
     356        'bed_id', 'bed_number', 'bed_type')
    357357    label = _('Allocate student')
    358358    pnav = 5
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/hostel.py

    r9197 r9199  
    145145    grok.provides(IBed)
    146146
    147     def getBedCoordinates(self):
     147    @property
     148    def coordinates(self):
    148149        """Determine the coordinates from the bed_id.
    149150        """
    150151        return self.bed_id.split('_')
     152
     153    # The following property attributes are only needed
     154    # for the exporter to ease evaluation with  Excel.
     155
     156    @property
     157    def hall(self):
     158        return self.coordinates[0]
     159
     160    @property
     161    def block(self):
     162        return self.coordinates[1]
     163
     164    @property
     165    def room(self):
     166        return self.coordinates[2]
     167
     168    @property
     169    def bed(self):
     170        return self.coordinates[3]
     171
     172    @property
     173    def special_handling(self):
     174        return self.bed_type.split('_')[0]
     175
     176    @property
     177    def sex(self):
     178        return self.bed_type.split('_')[1]
     179
     180    @property
     181    def bt(self):
     182        return self.bed_type.split('_')[2]
     183
    151184
    152185    def bookBed(self, student_id):
     
    162195        """
    163196        sh, sex, bt = self.bed_type.split('_')
    164         hostel_id, block, room_nr, bed = self.getBedCoordinates()
     197        hostel_id, block, room_nr, bed = self.coordinates
    165198        hostel = self.__parent__
    166199        beds_for_fresh = getattr(hostel,'beds_for_fresh',[])
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/interfaces.py

    r9197 r9199  
    199199    """
    200200
     201    coordinates = Attribute('The coordinates of the bed from bed_id')
     202
    201203    def loggerInfo(ob_class, comment):
    202204        """Adds an INFO message to the log file
    203205        """
    204206
    205     def getBedCoordinates():
    206         """Determine the coordinates from bed_id.
    207         """
    208207    def bookBed(student_id):
    209208        """Book a bed for a student.
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r9191 r9199  
    15241524        bedticket.bed = bed
    15251525        hall_title = bed.__parent__.hostel_name
    1526         coordinates = bed.getBedCoordinates()[1:]
     1526        coordinates = bed.coordinates[1:]
    15271527        block, room_nr, bed_nr = coordinates
    15281528        bc = _('${a}, Block ${b}, Room ${c}, Bed ${d} (${e})', mapping = {
     
    16401640        self.context.bed = new_bed
    16411641        hall_title = new_bed.__parent__.hostel_name
    1642         coordinates = new_bed.getBedCoordinates()[1:]
     1642        coordinates = new_bed.coordinates[1:]
    16431643        block, room_nr, bed_nr = coordinates
    16441644        bc = _('${a}, Block ${b}, Room ${c}, Bed ${d} (${e})', mapping = {
Note: See TracChangeset for help on using the changeset viewer.