Ignore:
Timestamp:
26 Oct 2015, 08:57:30 (9 years ago)
Author:
Henrik Bettermann
Message:

Remove beds_reserved attribute from hostels. Hostels do no longer
contain information about reserved bed spaces.

Use default values for list attributes. Otherwise the hostel manage page cannot be opened after import of hostels.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/hostels
Files:
7 edited

Legend:

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

    r13320 r13346  
    265265        return
    266266
    267     @action(_('Update all beds'), style='primary')
     267    @action(_('Update all beds'), style='primary',
     268            warning=_('Attention: The updater removes all reservation flags of existing beds.'
     269                        ' You really want to update?'))
    268270    def updateBeds(self, **data):
    269271        removed, added, modified, modified_beds = self.context.updateBeds()
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/browser_templates/hostelmanagepage.pt

    r13302 r13346  
    2121      <tbody>
    2222        <tal:widgets content="structure provider:widgets" />
    23         <tr>
    24           <td class="fieldname" i18n:translate="" >
    25             Reserved Beds:
    26           </td>
    27           <td>
    28             <tal:repeat repeat="bed context/beds_reserved" >
    29                 <span tal:replace='bed'>BED</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    30             </tal:repeat>
    31           </td>
    32         </tr>
    3323      </tbody>
    3424      </table>
     
    7969      </table>
    8070      <input type="checkbox" onClick="toggle(this, 'val_id')" />
    81       <span  i18n:translate="">Select all</span>
     71      &nbsp;<span  i18n:translate="">Select all</span>
    8272      <br /><br />
    8373      <div tal:condition="view/availableActions">
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/browser_templates/hostelpage.pt

    r9534 r13346  
    22  <tbody>
    33    <tal:widgets content="structure provider:widgets" />
    4     <tr>
    5       <td class="fieldname" i18n:translate="" >
    6         Reserved Beds:
    7       </td>
    8       <td>
    9         <tal:repeat repeat="bed context/beds_reserved" >
    10             <span tal:replace='bed'>BED</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    11         </tal:repeat>
    12       </td>
    13     </tr>
    144  </tbody>
    155</table>
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/hostel.py

    r13318 r13346  
    9090        beds_for_final = getattr(self,'beds_for_final',[])
    9191        beds_for_all = getattr(self,'beds_for_all',[])
    92         beds_reserved = getattr(self,'beds_reserved',[])
    9392        all_blocks = blocks_for_female + blocks_for_male
    9493        all_beds = (beds_for_pre + beds_for_fresh +
     
    103102                        room_nr = floor*100 + room
    104103                        bt = 'all'
    105                         if '%s_%s_%s' % (block,room_nr,bed) in beds_reserved:
    106                             bt = "reserved"
    107                         elif bed in beds_for_fresh:
     104                        if bed in beds_for_fresh:
    108105                            bt = 'fr'
    109106                        elif bed in beds_for_pre:
     
    218215                bt = 're'
    219216            bt = u'%s_%s_%s' % (sh, sex, bt)
    220 
    221             # Comment of Martijn:
    222             # If you have a non-Persistent subobject (like a list) and
    223             # you change it, you need to manually flag the persistence
    224             # machinery on the object that its subobject changed, with
    225             # _p_changed. This is only necessary if some of the
    226             # objects are not sublclasses of Persistent. For common
    227             # built-in collections in Python such as list and
    228             # dictionary there are replacements (PersistentList,
    229             # PersistentMapping), and more advanced building blocks
    230             # for indexes (BTrees), that don't have this issue.
    231             #hostel._p_changed = True
    232 
    233             # Henrik: Unfortunately, this doesn't work in our case.
    234             # After restarting the portal,
    235             # added or removed list items are gone. The only way to ensure
    236             # persistance is to reassign the list attribute.
    237             br = hostel.beds_reserved
    238             br.remove(bed_string)
    239             hostel.beds_reserved = br
    240217            message = _(u'unreserved')
    241218        else:
    242219            bt = u'%s_%s_reserved' % (sh, sex)
    243             # See comment above
    244             br = hostel.beds_reserved
    245             br.append(bed_string)
    246             hostel.beds_reserved = br
    247220            message = _(u'reserved')
    248221        self.bed_type = bt
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/interfaces.py

    r13316 r13346  
    122122        )
    123123
    124     beds_reserved = schema.List(
    125         title = _(u'Reserved Beds'),
    126         value_type = schema.TextLine(
    127             default = u'',
    128             required = False,
    129         ),
    130         required = True,
    131         readonly = False,
    132         default = [],
    133         )
    134 
    135124    blocks_for_female = schema.List(
    136125        title = _(u'Blocks for Female Students'),
     
    138127            vocabulary = blocks
    139128            ),
     129        default = [],
    140130        )
    141131
     
    145135            vocabulary = blocks
    146136            ),
     137        default = [],
    147138        )
    148139
     
    152143            vocabulary = bed_letters
    153144            ),
     145        default = [],
    154146        )
    155147
     
    159151            vocabulary = bed_letters
    160152            ),
     153        default = [],
    161154        )
    162155
     
    166159            vocabulary = bed_letters
    167160            ),
     161        default = [],
    168162        )
    169163
     
    173167            vocabulary = bed_letters
    174168            ),
     169        default = [],
    175170        )
    176171
     
    180175            vocabulary = bed_letters
    181176            ),
     177        default = [],
    182178        )
    183179
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/sample_hostel_data.csv

    r9202 r13346  
    1 beds_for_all,beds_for_final,beds_for_fresh,beds_for_pre,beds_for_returning,beds_reserved,blocks_for_female,blocks_for_male,floors_per_block,hostel_id,hostel_name,rooms_per_floor,sort_id,special_handling
    2 [],"['A', 'B']","['E', 'F']",['G'],"['C', 'D']",[],['A'],[],1,block-a-upper-hostel,Block A Upper Hostel,32,20,regular
    3 [],"['A', 'B']","['E', 'F']",['G'],"['C', 'D']",[],['B'],[],1,block-b-upper-hostel,Block B Upper Hostel,32,30,regular
    4 [],"['A', 'B']","['E', 'F']",['G'],"['C', 'D']",[],['C'],[],1,block-c-upper-hostel,Block C Upper Hostel,32,40,regular
    5 [],"['A', 'B']","['E', 'F']",['G'],"['C', 'D']",[],['D'],[],1,block-d-upper-hostel,Block D Upper Hostel,32,50,regular
    6 [],"['A', 'B']","['E', 'F']",['G'],"['C', 'D']",[],['E'],[],1,block-e-down-hostel,Block E Down Hostel,32,60,regular
    7 [],"['A', 'B']","['E', 'F']",['G'],"['C', 'D']",[],['F'],[],1,block-f-down-hostel,Block F Down Hostel,32,70,regular
    8 [],"['A', 'B']","['E', 'F']",['G'],"['C', 'D']",[],['G'],[],1,block-g-down-hostel,Block G Down Hostel,32,80,regular
    9 [],"['A', 'B']","['D', 'E']",['F'],['C'],[],[],"['A', 'B']",1,hall-a,Hall A,44,90,regular
    10 [],"['A', 'B']","['D', 'E']",['F'],['C'],[],[],"['C', 'D']",1,hall-b,Hall B,44,100,regular
    11 [],[],[],[],[],[],[],['A'],1,stores-32,Stores 32,16,10,regular
     1beds_for_all,beds_for_final,beds_for_fresh,beds_for_pre,beds_for_returning,blocks_for_female,blocks_for_male,floors_per_block,hostel_id,hostel_name,rooms_per_floor,sort_id,special_handling
     2[],"['A', 'B']","['E', 'F']",['G'],"['C', 'D']",['A'],[],1,block-a-upper-hostel,Block A Upper Hostel,32,20,regular
     3[],"['A', 'B']","['E', 'F']",['G'],"['C', 'D']",['B'],[],1,block-b-upper-hostel,Block B Upper Hostel,32,30,regular
     4[],"['A', 'B']","['E', 'F']",['G'],"['C', 'D']",['C'],[],1,block-c-upper-hostel,Block C Upper Hostel,32,40,regular
     5[],"['A', 'B']","['E', 'F']",['G'],"['C', 'D']",['D'],[],1,block-d-upper-hostel,Block D Upper Hostel,32,50,regular
     6[],"['A', 'B']","['E', 'F']",['G'],"['C', 'D']",['E'],[],1,block-e-down-hostel,Block E Down Hostel,32,60,regular
     7[],"['A', 'B']","['E', 'F']",['G'],"['C', 'D']",['F'],[],1,block-f-down-hostel,Block F Down Hostel,32,70,regular
     8[],"['A', 'B']","['E', 'F']",['G'],"['C', 'D']",['G'],[],1,block-g-down-hostel,Block G Down Hostel,32,80,regular
     9[],"['A', 'B']","['D', 'E']",['F'],['C'],[],"['A', 'B']",1,hall-a,Hall A,44,90,regular
     10[],"['A', 'B']","['D', 'E']",['F'],['C'],[],"['C', 'D']",1,hall-b,Hall B,44,100,regular
     11[],[],[],[],[],[],['A'],1,stores-32,Stores 32,16,10,regular
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/tests.py

    r13319 r13346  
    311311        self.assertEqual(self.app['hostels']['hall-1'][
    312312            'hall-1_A_101_D'].bed_type, 'regular_female_reserved')
    313         self.assertTrue('A_101_A&nbsp;&nbsp;' in self.browser.contents)
    314313        # The catalog has been updated.
    315314        results = cat.searchResults(
     
    340339            bed_type=('regular_female_all', 'regular_female_all'))
    341340        results = [(x.bed_id, x.bed_type) for x in results]
     341        # The reservation of hall-1_A_101_D has been cancelled.
    342342        self.assertEqual(results,
    343             [(u'hall-1_B_101_D', u'regular_female_all'),])
    344         # Unreserve beds.
    345         ctrl = self.browser.getControl(name='val_id')
    346         ctrl.getControl(value='hall-1_A_101_A').selected = True
    347         ctrl.getControl(value='hall-1_A_101_B').selected = True
    348         ctrl.getControl(value='hall-1_A_101_C').selected = True
    349         ctrl.getControl(value='hall-1_A_101_D').selected = True
    350         self.browser.getControl("Switch reservation", index=0).click()
    351         assert self.app['hostels']['hall-1'][
    352             'hall-1_A_101_D'].bed_type == 'regular_female_all'
    353         self.assertFalse(expected in self.browser.contents)
     343            [(u'hall-1_A_101_D', u'regular_female_all'),
     344             (u'hall-1_B_101_D', u'regular_female_all')])
    354345        # Release bed which has previously been booked.
    355346        bedticket = BedTicket()
     
    508499            result,
    509500            'beds_for_all,beds_for_final,beds_for_fresh,beds_for_pre,'
    510             'beds_for_returning,beds_reserved,blocks_for_female,'
     501            'beds_for_returning,blocks_for_female,'
    511502            'blocks_for_male,floors_per_block,hostel_id,hostel_name,maint_fee,'
    512             'rooms_per_floor,sort_id,special_handling\r\n,,,,,[],,,1,'
    513             'hall-x,Hall 1,0.0,2,10,regular\r\n'
     503            'rooms_per_floor,sort_id,special_handling\r\n[],[],[],[],[],[],[],'
     504            '1,hall-x,Hall 1,0.0,2,10,regular\r\n'
    514505            )
    515506        return
     
    554545            "updated: "
    555546            "beds_for_pre=['G'], floors_per_block=1, "
     547            "special_handling=regular, "
    556548            "beds_for_final=['A', 'B'], rooms_per_floor=32, "
    557549            "hostel_id=block-a-upper-hostel, "
     
    562554        shutil.rmtree(os.path.dirname(fin_file))
    563555        shutil.rmtree(self.workdir)
     556        # The manage page can be opened.
     557        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     558        self.browser.open(self.container_path + '/block-a-upper-hostel')
     559        self.browser.getLink("Manage").click()
     560        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    564561        return
    565562
     
    582579            "updated: "
    583580            "beds_for_pre=['G'], floors_per_block=1, "
     581            "special_handling=regular, "
    584582            "beds_for_final=['A', 'B'], rooms_per_floor=32, "
    585583            "hostel_id=block-a-upper-hostel, "
Note: See TracChangeset for help on using the changeset viewer.