Index: /main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py	(revision 15708)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py	(revision 15709)
@@ -2333,5 +2333,5 @@
     grok.name('add')
     grok.require('waeup.handleAccommodation')
-    grok.template('enterpin')
+    #grok.template('enterpin')
     ac_prefix = 'HOS'
     label = _('Add bed ticket')
@@ -2342,17 +2342,28 @@
     with_bedselection = True
 
-    def getAvailableBeds(self, acc_details, desired_hostel):
+    @property
+    def getAvailableBeds(self):
         """Get a list of all available beds.
         """
         cat = queryUtility(ICatalog, name='beds_catalog', default=None)
         entries = cat.searchResults(
-            bed_type=(acc_details['bt'],acc_details['bt']))
+            bed_type=(self.acc_details['bt'],self.acc_details['bt']))
         available_beds = [
             entry for entry in entries if entry.owner == NOT_OCCUPIED]
+        desired_hostel = self.context.desired_hostel
+        # Filter desired hostel beds
         if desired_hostel and desired_hostel != 'no':
-            # Filter desired hostel beds
             filtered_beds = [bed for bed in available_beds
                              if bed.bed_id.startswith(desired_hostel)]
-            return filtered_beds
+            available_beds = filtered_beds
+        # Add legible bed coordinates
+        for bed in available_beds:
+            hall_title = bed.__parent__.hostel_name
+            coordinates = bed.coordinates[1:]
+            block, room_nr, bed_nr = coordinates
+            bed.temp_bed_coordinates = _(
+                '${a}, Block ${b}, Room ${c}, Bed ${d}', mapping = {
+                'a':hall_title, 'b':block,
+                'c':room_nr, 'd':bed_nr})
         return available_beds
 
@@ -2360,7 +2371,11 @@
         student = self.context.student
         students_utils = getUtility(IStudentsUtils)
-        acc_details  = students_utils.getAccommodationDetails(student)
+        self.acc_details  = students_utils.getAccommodationDetails(student)
         error_message = students_utils.checkAccommodationRequirements(
-            student, acc_details)
+            student, self.acc_details)
+        cat = queryUtility(ICatalog, name='beds_catalog', default=None)
+        entries = cat.searchResults(
+            owner=(student.student_id,student.student_id))
+        self.show_available_beds = False
         if error_message:
             self.flash(error_message, type="warning")
@@ -2370,5 +2385,8 @@
             self.ac_series = self.request.form.get('ac_series', None)
             self.ac_number = self.request.form.get('ac_number', None)
+        available_beds = self.getAvailableBeds
         if SUBMIT is None:
+            if self.with_bedselection and available_beds and not len(entries):
+                self.show_available_beds = True
             return
         if self.with_ac:
@@ -2379,41 +2397,26 @@
                 return
         # Search and book bed
-        cat = queryUtility(ICatalog, name='beds_catalog', default=None)
-        entries = cat.searchResults(
-            owner=(student.student_id,student.student_id))
         if len(entries):
-            # If bed space has been manually allocated use this bed
+            # If bed space has been manually allocated use this bed ...
             manual = True
-            bed = [entry for entry in entries][0]
-            # Safety belt for paranoids: Does this bed really exist on portal?
-            # XXX: Can be remove if nobody complains.
-            if bed.__parent__.__parent__ is None:
-                self.flash(_('System error: Please contact the adminsitrator.'),
-                           type="danger")
-                self.context.writeLogMessage(
-                    self, 'fatal error: %s' % bed.bed_id)
-                return
-        else:
-            # else search for other available beds
+            bed = liest(entries)[0]
+        else:
+            # ... else search for available beds
             manual = False
-            available_beds = self.getAvailableBeds(
-                acc_details, self.context.desired_hostel)
-            if available_beds:
+            selected_bed = self.request.form.get('bed', None)
+            if selected_bed:
+                # Use selected bed
+                beds = cat.searchResults(
+                    bed_id=(selected_bed,selected_bed))
+                bed = list(beds)[0]
+                bed.bookBed(student.student_id)
+            elif available_beds:
+                # Select bed according to selectBed method
                 students_utils = getUtility(IStudentsUtils)
                 bed = students_utils.selectBed(available_beds)
-                # Safety belt for paranoids: Does this bed really exist
-                # in portal?
-                # XXX: Can be remove if nobody complains.
-                if bed.__parent__.__parent__ is None:
-                    self.flash(_(
-                        'System error: Please contact the administrator.'),
-                        type="warning")
-                    self.context.writeLogMessage(
-                        self, 'fatal error: %s' % bed.bed_id)
-                    return
                 bed.bookBed(student.student_id)
             else:
                 self.flash(_('There is no free bed in your category ${a}.',
-                    mapping = {'a':acc_details['bt']}), type="warning")
+                    mapping = {'a':self.acc_details['bt']}), type="warning")
                 self.redirect(self.url(self.context))
                 return
@@ -2448,6 +2451,6 @@
         if self.with_ac:
             bedticket.booking_code = pin
-        bedticket.booking_session = acc_details['booking_session']
-        bedticket.bed_type = acc_details['bt']
+        bedticket.booking_session = self.acc_details['booking_session']
+        bedticket.bed_type = self.acc_details['bt']
         bedticket.bed = bed
         hall_title = bed.__parent__.hostel_name
Index: /main/waeup.kofa/trunk/src/waeup/kofa/students/browser_templates/accommodationmanagepage.pt
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/students/browser_templates/accommodationmanagepage.pt	(revision 15708)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/students/browser_templates/accommodationmanagepage.pt	(revision 15709)
@@ -5,6 +5,6 @@
     <br />
     <p i18n:translate="">
-    Select and <strong>save the desired hostel</strong> before booking acommodation.
-    Your choice cannot be changed afterwards.
+    Select and <strong>save the desired hostel</strong> before creating
+    a bed ticket. Your choice cannot be changed afterwards.
     </p>
     <div class="form-inline">
Index: /main/waeup.kofa/trunk/src/waeup/kofa/students/browser_templates/bedticketaddpage.pt
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/students/browser_templates/bedticketaddpage.pt	(revision 15709)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/students/browser_templates/bedticketaddpage.pt	(revision 15709)
@@ -0,0 +1,56 @@
+<form method="POST" i18n:domain="waeup.kofa">
+  <table class="form-table">
+    <tbody>
+      <tal:show_available_beds condition="view/show_available_beds">
+        <tr>
+          <td i18n:translate="" colspan="2">
+            Select your bed before booking acommodation.
+            Your choice cannot be changed afterwards.
+          </td>
+        </tr>
+        <tr>
+          <td i18n:translate="">
+            Desired Bed Space:
+          </td>
+          <td>
+          <span class="form-inline">
+            <select class="form-control" id="bed" name="bed">
+              <option tal:repeat="bed view/getAvailableBeds"
+                      tal:attributes="value bed/bed_id">
+              <span tal:replace="bed/temp_bed_coordinates">BED</span>
+              </option>
+            </select>
+          </span>
+          </td>
+        </tr>
+      </tal:show_available_beds>
+      <tal:with_ac condition="view/with_ac">
+        <tr>
+          <td i18n:translate="">
+          Activation Code:
+          </td>
+          <td>
+          <span tal:replace="view/ac_prefix">PIN Prefix</span> -
+          <input name="ac_series" type="text" maxlength="3"
+                 class="ac-input ac-series"
+                 value="" tal:attributes="value view/ac_series"/> -
+          <input name="ac_number" type="text" maxlength="10"
+                 class="ac-input ac-number"
+                 value="" tal:attributes="value view/ac_number" />
+          <font color="red"><span tal:replace="view/notice">Notice</span>
+          </font>
+          </td>
+        </tr>
+        <tr>
+          <td>&nbsp;</td>
+          <td i18n:translate="">
+          The activation code can be found on the payment slip.
+          </td>
+        </tr>
+      </tal:with_ac>
+    </tbody>
+  </table>
+  <br />
+  <input type="submit" name="SUBMIT" class="btn btn-primary"
+         tal:attributes="value view/buttonname" />
+</form>
Index: /main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py	(revision 15708)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py	(revision 15709)
@@ -3358,4 +3358,7 @@
         self.browser.getControl(name="ac_series").value = sfeseries
         self.browser.getControl(name="ac_number").value = sfenumber
+        # There is no free bed space and the bed selector does not appear
+        self.assertFalse('<option value="hall-1_A_101_A">'
+            in self.browser.contents)
         self.browser.getControl("Create bed ticket").click()
         # Hostel 2 has only a bed for women.
@@ -3375,9 +3378,12 @@
         self.assertTrue(bed.owner == NOT_OCCUPIED)
         ac.owner = self.student_id
+        self.browser.open(self.acco_path + '/add')
         self.browser.getControl(name="ac_series").value = sfeseries
         self.browser.getControl(name="ac_number").value = sfenumber
+        # Bed can be selected
+        self.browser.getControl(name="bed").value = ['hall-1_A_101_A']
         self.browser.getControl("Create bed ticket").click()
-        self.assertMatches('...Hall 1, Block A, Room 101, Bed A...',
-                           self.browser.contents)
+        self.assertTrue('Bed ticket created and bed booked'
+            in self.browser.contents)
         # Bed has been allocated.
         self.assertTrue(bed.owner == self.student_id)
