Index: /WAeUP_SRP/base/skins/waeup_accommodation/change_bed.py
===================================================================
--- /WAeUP_SRP/base/skins/waeup_accommodation/change_bed.py	(revision 3150)
+++ /WAeUP_SRP/base/skins/waeup_accommodation/change_bed.py	(revision 3151)
@@ -35,5 +35,5 @@
     if info['acco'] is None:
         logger.info('No accommodation object for %s' % (student_id))
-        return redirect("%s/%s" % (students.absolute_url(),student_id))
+        return redirect("%s/%s/no_booking_allowed" % (students.absolute_url(),student_id))
     res = beds(student=student_id)
     status = info['student_status']
@@ -43,13 +43,14 @@
     else:
         allocated_bed = res[0]
-        #student = student_id
-        if allocated_bed.bed_type == status:
-            logger.info('Status %s of %s has not changed' % (status,student_id))
-            return redirect("%s/%s/%s" % (students.absolute_url(),student,info['acco_id']))
-        logger.info('Bed status %s of %s has changed to %s' % (allocated_bed.bed_type,student_id,status))
-        beds.modifyRecord(bed=allocated_bed.bed,student=beds.not_occupied)
-        logger.info('Bed %s released' % (allocated_bed.bed))
     code,bed = beds.searchAndReserveBed(student_id,status)
     if code > 0:
+        if res:
+            if allocated_bed.bed_type == status:
+                logger.info('Status %s of %s has not changed' % (status,student_id))
+                psm='Student status has not changed!'
+                return redirect("%s/%s/%s/waeup_document_view?portal_status_message=%s" % (students.absolute_url(),student_id,info['acco_id'],psm))
+            logger.info('Bed status %s of %s has changed to %s' % (allocated_bed.bed_type,student_id,status))
+            beds.modifyRecord(bed=allocated_bed.bed,student=beds.not_occupied)
+            logger.info('Bed %s released' % (allocated_bed.bed))    
         d = {}
         d['bed'] = bed
@@ -61,17 +62,12 @@
         acco_doc.edit(mapping=d)
         logger.info('Bed %s allocated to %s' % (bed,student_id))
-        return redirect("%s/%s/%s" % (students.absolute_url(),student_id,info['acco_id']))
-    # student_obj = getattr(students,student_id)
-    # acco_id = "accommodation_%s" % context.getSessionId()[0]
-    # if acco_id in student_obj.objectIds():
-    #     acco_doc = getattr(student_obj, acco_id).getContent()
-    #     if acco_doc.bed == bed:
-    #         acco_doc.edit(mapping={'bed':"-- cancelled by officer due to failed bed change request --"})
-    acco_doc = info['acco_doc']
-    if acco_doc.bed == bed:
-        acco_doc.edit(mapping={'bed':"-- cancelled by officer due to failed bed change request --"})
+        psm='Bed changed!'
+        return redirect("%s/%s/%s/waeup_document_view?portal_status_message=%s" % (students.absolute_url(),student_id,info['acco_id'],psm))
+    #acco_doc = info['acco_doc']
+    #acco_doc.edit(mapping={'bed':"-- cancelled by officer due to failed bed change request --"})
     logger.info('New bed allocation for %s failed, code = %s' % (student_id,code))
-    logger.info('%s cancelled booking of bed %s by %s' % (member,bed,student_id))
-    return redirect("%s/%s/%s" % (students.absolute_url(),student_id,info['acco_id']))
+    #logger.info('%s cancelled booking of bed %s by %s' % (member,bed,student_id))
+    psm='Bed change failed!'
+    return redirect("%s/%s/%s/waeup_document_view?portal_status_message=%s" % (students.absolute_url(),student_id,info['acco_id'],psm))
 
 info = {}
