Index: /WAeUP_SRP/trunk/ScratchCards.py
===================================================================
--- /WAeUP_SRP/trunk/ScratchCards.py	(revision 685)
+++ /WAeUP_SRP/trunk/ScratchCards.py	(revision 686)
@@ -91,12 +91,18 @@
         pins_cat = self.portal_pins
         doc = self.getContent()
-        l = [{'pin': p.pin,
+        unused = [{'pin': p.pin,
               'serial': p.serial,
               } for p in pins_cat.searchResults(prefix_batch = "%s%d"
                                                % (doc.prefix,doc.batch_no),
-                                               ) if p.student == '']
-        if len (l) <= max_pins:
-            return l
-        return l[:max_pins]
+                                               ) if not p.student]
+        used = [{'pin': p.pin,
+              'serial': p.serial,
+              'student': p.student,
+              } for p in pins_cat.searchResults(prefix_batch = "%s%d"
+                                               % (doc.prefix,doc.batch_no),
+                                               ) if p.student]
+        if len (unused) <= max_pins:
+            return unused,used
+        return unused[:max_pins],used
 
 InitializeClass(ScratchCardBatch)
Index: /WAeUP_SRP/trunk/WAeUPTables.py
===================================================================
--- /WAeUP_SRP/trunk/WAeUPTables.py	(revision 685)
+++ /WAeUP_SRP/trunk/WAeUPTables.py	(revision 686)
@@ -80,5 +80,4 @@
 
     def searchAndReserveBed(self, student_id,bed_type):
-        #import pdb;pdb.set_trace()
         records = self.searchResults({'student' : student_id})
         if len(records) > 0:
@@ -86,4 +85,5 @@
             
         records = [r for r in self.searchResults({'bed_type' : bed_type}) if not r.student]
+        #import pdb;pdb.set_trace()
         if len(records) == 0:
             return -1,"no bed of this type available"
Index: /WAeUP_SRP/trunk/profiles/default/layouts/student_accommodation.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/layouts/student_accommodation.xml	(revision 685)
+++ /WAeUP_SRP/trunk/profiles/default/layouts/student_accommodation.xml	(revision 686)
@@ -1,8 +1,8 @@
 <?xml version="1.0"?>
 <object name="student_accommodation" meta_type="CPS Layout">
- <property name="layout_create_method"></property>
- <property name="layout_edit_method"></property>
+ <property name="layout_create_method">layout_application_create</property>
+ <property name="layout_edit_method">layout_application_edit</property>
  <property name="layout_view_method"></property>
- <property name="style_prefix">layout_waeup_</property>
+ <property name="style_prefix">layout_accommodation_</property>
  <property name="flexible_widgets"/>
  <property name="validate_values_expr"></property>
@@ -15,10 +15,12 @@
   <property name="label_edit">Maintainance Fee Date</property>
   <property name="readonly_layout_modes"/>
-  <property name="hidden_layout_modes"/>
+  <property name="hidden_layout_modes">
+    <element value="create"/>
+  </property>
   <property name="hidden_readonly_layout_modes"/>
   <property name="view_format">iso8601_medium_easy</property>
   <property name="hidden_empty"></property>
  </widget>
- <widget name="acco_maint_sc_pin" meta_type="String Widget">
+ <widget name="acco_maint_sc_pin" meta_type="Scratchcard Pin Widget">
   <property name="title">Maintainance Fee Access Code</property>
   <property name="fields">
@@ -27,10 +29,25 @@
   <property name="label">Maintainance Fee Access Code</property>
   <property name="label_edit">Maintainance Fee Access Code</property>
+  <property name="hidden_layout_modes">
+    <element value="create"/>
+  </property>
   <property name="readonly_layout_modes"/>
-  <property name="hidden_layout_modes"/>
   <property name="hidden_readonly_layout_modes"/>
 <property name="hidden_empty"></property>
- </widget>
- <widget name="acco_res_date" meta_type="DateTime Widget">
+  <property name="prefix">HMU</property>
+  </widget>
+<widget name="student_status" meta_type="Select Widget">
+ <property name="title">Status</property>
+ <property name="fields">
+  <element value="student_status"/>
+ </property>
+ <property name="label">Status</property>
+ <property name="label_edit">Status</property>
+ <property name="readonly_layout_modes"/>
+ <property name="hidden_layout_modes"/>
+ <property name="hidden_readonly_layout_modes"/>
+ <property name="vocabulary">student_status_voc</property>
+</widget> 
+  <widget name="acco_res_date" meta_type="DateTime Widget">
   <property name="title">Reservation Date</property>
   <property name="fields">
@@ -40,9 +57,11 @@
   <property name="label_edit">Reservation Date</property>
   <property name="readonly_layout_modes"/>
-  <property name="hidden_layout_modes"/>
+  <property name="hidden_layout_modes">
+    <element value="create"/>
+  </property>
   <property name="hidden_readonly_layout_modes"/>
   <property name="view_format">iso8601_medium_easy</property>
  </widget>
- <widget name="acco_res_sc_pin" meta_type="String Widget">
+ <widget name="acco_res_sc_pin" meta_type="Scratchcard Pin Widget">
   <property name="title">Reservation Access Code</property>
   <property name="fields">
@@ -51,4 +70,5 @@
   <property name="label">Reservation Access Code</property>
   <property name="label_edit">Reservation Access Code</property>
+  <property name="prefix">HOS</property>
   <property name="readonly_layout_modes"/>
   <property name="hidden_layout_modes"/>
@@ -63,5 +83,7 @@
  <property name="label_edit">Bed</property>
  <property name="readonly_layout_modes"/>
- <property name="hidden_layout_modes"/>
+  <property name="hidden_layout_modes">
+    <element value="create"/>
+  </property>
  <property name="hidden_readonly_layout_modes"/>
  <property name="render_method">formatBed</property>
@@ -75,5 +97,7 @@
   <property name="label_edit">Session</property>
   <property name="readonly_layout_modes">edit</property>
-  <property name="hidden_layout_modes"/>
+  <property name="hidden_layout_modes">
+    <element value="create"/>
+  </property>
   <property name="hidden_readonly_layout_modes"/>
  </widget>
@@ -84,4 +108,7 @@
   <row>
    <cell name="bed"/>
+  </row>
+  <row>
+   <cell name="student_status"/>
   </row>
   <row>
Index: /WAeUP_SRP/trunk/skins/waeup_accommodation/formatBed.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_accommodation/formatBed.py	(revision 685)
+++ /WAeUP_SRP/trunk/skins/waeup_accommodation/formatBed.py	(revision 686)
@@ -7,4 +7,6 @@
 if datastructure is not None:
     bed = datastructure.get('bed')
+if not bed:
+    return ''
 hall,block,room,letter = bed.split('_')
 res = context.portal_catalog(portal_type="AccoHall",id=hall)
Index: /WAeUP_SRP/trunk/skins/waeup_default/layout_waeup_edit.pt
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_default/layout_waeup_edit.pt	(revision 685)
+++ /WAeUP_SRP/trunk/skins/waeup_default/layout_waeup_edit.pt	(revision 686)
@@ -1,138 +1,179 @@
 <!-- a layout_lib macro -->
 <!-- $Id$ -->
-
 <metal:block define-macro="default_edit"
   tal:define="layout options/layout;
-  ds options/datastructure;
-  dm ds/getDataModel;
-  formaction options/formaction|string:student_edit;
-  creation creation|nothing;
-  external python:request.URL0.endswith('external_edit_form');
-  save_button python:not (creation or external);
-  metadata metadata|nothing;
-  type_name request/type_name|nothing;
-  ti python:type_name and getattr(here.portal_types,type_name,None) or getattr(here.portal_types,here.portal_type,None);
-  cpsmcat nocall:here/translation_service;
-  apply request/apply_button|nothing;
-  widgets python:context.getRenderedWidgets(layout);
-  ">
-  <form action="" id="editForm" method="post" 
-        enctype="multipart/form-data" class="workflow"
-        tal:attributes="action formaction"
-        >
-  <table class="layoutDefault" summary="Form layout"
-         tal:condition="layout/rows">
-    <span tal:repeat="row python: layout['rows']" valign="top" >
-      <span tal:repeat="cell row">
-        <tr tal:define="widget cell/widget;
-              wid widget/getWidgetId;
-              err python:ds.getError(wid);
-              err_mapping python:ds.getErrorMapping(wid);
-              is_required python: widget.is_required and creation and ('create' not in widget.readonly_layout_modes);
-              tooltip_id python:wid + '_help';
-              widget_css_class cell/widget_css_class|nothing;
-              css_class python:test(err, 'row error','row')"
-              tal:condition="python: wid != 'passport'"
-              >
-          <div tal:attributes="class widget_css_class;
-          id python:widget.getHtmlWidgetId()+'_widget';"
-          >
-            <td>
-            <div class="label" tal:condition="widget/label_edit"
-                 tal:attributes="class python:test(is_required, 'label required','label')">
-              <label tal:content="widget/label_edit"
-                     tal:attributes="for cell/widget_input_area_id|nothing;">label</label>:
-            </div>
-            <button type="button" class="tooltipControl"
-                    tal:condition="widget/help"
-                    tal:attributes="onclick python:'toggleElementVisibility(\'%s\')' % tooltip_id;"> ? </button>
-            </td>
-            <td>
-            <span class="field">
-              <div tal:replace="structure cell/widget_rendered"/>
-            </span>
-            <div class="tooltipArea" style="visibility: hidden;"
-                 tal:condition="widget/help"
-                 tal:attributes="id tooltip_id;
-                 onclick python:'showElement(false, \'%s\')' % tooltip_id;"
-                 >
-              <tal:block tal:content="widget/help">This is the help for this field
-              </tal:block>
-            </div>
-            <tal:block condition="err">
+              ds options/datastructure;
+              dm ds/getDataModel;
+              creation creation|nothing;
+              metadata metadata|nothing;
+              type_name request/type_name|nothing;
+              ti python:type_name and getattr(here.portal_types,type_name,None) or getattr(here.portal_types,here.portal_type,None);
+              creation_form python:ti and ti.getActionById('create', 'cpsdocument_create_form') or 'cpsdocument_create_form' ;
+              edit_form     python:ti and ti.getActionById('edit',   'cpsdocument_edit_form') or  'cpsdocument_edit_form';
+              metadata_form python:ti and ti.getActionById('metadata', 'cpsdocument_metadata') or 'cpsdocument_metadata';
+              formaction formaction|python: test(creation, creation_form,
+                                 test(metadata, metadata_form,
+                                                edit_form));
+              first_layout options/first_layout|python:0;
+              last_layout options/last_layout|python:0;
+              is_flexible options/is_flexible;
+              cpsmcat nocall:here/translation_service;
+              ">
+<tal:block condition="python:first_layout">
+  <tal:block
+  content="structure string:<form id='editForm' action='${formaction}' method='post'
+  enctype='multipart/form-data' class='workflow'>
+  <div class='group'><div class='documentFields'>" />
+  <input type="hidden" name="type_name" value="."
+    tal:condition="creation" tal:attributes="value request/type_name" />
+</tal:block>
+
+<table width="100%" cellpadding="2" cellspacing="2" summary="Form layout"
+       tal:condition="layout/rows">
+  <tr tal:repeat="row layout/rows" valign="top">
+    <td tal:repeat="cell row"
+      tal:attributes="colspan cell/ncols">
+      <tal:block define="widget cell/widget;
+                         wid widget/getWidgetId;
+                         err python:ds.getError(wid);
+                         err_mapping python:ds.getErrorMapping(wid);
+                         is_required widget/is_required|nothing;
+                         tooltip_id python:wid + '_help';
+                         widget_css_class cell/widget_css_class|nothing;
+                         widget_css_class python:test(is_flexible, 'group', widget_css_class);
+                         css_class python:test(err, 'row error',
+                                               test(is_flexible, 'group', 'row'))">
+        <div tal:attributes="class widget_css_class;
+                             id python:widget.getHtmlWidgetId()+'_widget';
+                            ">
+          <div class="label" tal:condition="widget/label_edit"
+            tal:attributes="class python:test(is_required, 'label required',
+                                              'label')">
+            <label i18n:translate="" tal:condition="widget/is_i18n"
+              tal:content="widget/label_edit"
+              tal:attributes="for cell/widget_input_area_id|nothing;">label</label>
+            <label tal:condition="not:widget/is_i18n"
+              tal:content="widget/label_edit"
+              tal:attributes="for cell/widget_input_area_id|nothing;">label</label>
+          </div>
+          <button type="button" class="tooltipControl"
+                  tal:condition="widget/help"
+                  tal:attributes="onclick python:'toggleElementVisibility(\'%s\')' % tooltip_id;"> ? </button>
+          <div class="field">
+            <div tal:replace="structure cell/widget_rendered"/>
+          </div>
+          <div class="tooltipArea" style="visibility: hidden;"
+               tal:condition="widget/help"
+               tal:attributes="id tooltip_id;
+                               onclick python:'showElement(false, \'%s\')' % tooltip_id;">
+            <tal:block i18n:translate="" tal:condition="widget/is_i18n"
+              tal:content="widget/help">i18_key-help_for_this_field</tal:block>
+            <tal:block tal:condition="not:widget/is_i18n"
+              tal:content="widget/help">This is the help for this field</tal:block>
+          </div>
+          <tal:block condition="err">
               <tal:block define="msg python:cpsmcat(err, mapping=err_mapping)">
                 <br /><em style="color: red"
-                          tal:content="msg">err</em>
+                  tal:content="msg">err</em>
               </tal:block>
-            </tal:block>
-            </td>
+          </tal:block>
+          <div style="float: right;" tal:condition="is_flexible">
+            <input type="button" value="button_move_up"
+              tal:condition="not:repeat/row/start"
+              tal:attributes="name string:uprow_${repeat/row/index};
+                              onclick python:'CPSFlexibleEdit.buttonClick(this, \'\')'"
+              class="context moveUp" i18n:attributes="value" />
+            <input type="button" value="button_move_down"
+              tal:condition="not:repeat/row/end"
+              tal:attributes="name string:downrow_${repeat/row/index};
+                              onclick python:'CPSFlexibleEdit.buttonClick(this, \'\')'"
+              class="context moveDown" i18n:attributes="value" />
+            <input type="button" value="button_delete"
+              class="destructive" i18n:attributes="value"
+              tal:attributes="name string:deleterow_${repeat/row/index};
+                              onclick python:'CPSFlexibleEdit.buttonClick(this, \'%s\')' %
+                                (cpsmcat('description_confirm_delete'), )" />
           </div>
-        </tr>
-      </span>
-    </span>
-    <tr tal:condition="widgets/passport|nothing" 
-        tal:define="cell widgets/passport|nothing;">
-      <tal:block tal:define="widget cell/widget;
-      wid widget/getWidgetId;
-      err python:ds.getError(wid);
-      err_mapping python:ds.getErrorMapping(wid);
-      is_required python: widget.is_required and creation and ('create' not in widget.readonly_layout_modes);
-      tooltip_id python:wid + '_help';
-      widget_css_class widget/widget_css_class|nothing;
-      css_class python:test(err, 'row error','row')"
-      >
-        <div tal:attributes="class widget_css_class;
-        id python:widget.getHtmlWidgetId()+'_widget';"
-        >
-          <td>
-            <div class="label" tal:condition="widget/label_edit"
-                 tal:attributes="class python:test(is_required, 'label required','label')">
-              <label tal:content="widget/label_edit"
-                     tal:attributes="for cell/widget_input_area_id|nothing;">label</label>:
-            </div>
-            <button type="button" class="tooltipControl"
-                    tal:condition="widget/help"
-                    tal:attributes="onclick python:'toggleElementVisibility(\'%s\')' % tooltip_id;"> ? </button>
-          </td>
-          <td>
-            <span class="field">
-              <div tal:replace="structure cell/widget_rendered"/>
-            </span>
-            <div class="tooltipArea" style="visibility: hidden;"
-                 tal:condition="widget/help"
-                 tal:attributes="id tooltip_id;
-                 onclick python:'showElement(false, \'%s\')' % tooltip_id;"
-                 >
-              <tal:block tal:content="widget/help">This is the help for this field
-              </tal:block>
-            </div>
-            <tal:block condition="err">
-              <tal:block define="msg python:cpsmcat(err, mapping=err_mapping)">
-                <br /><em style="color: red"
-                          tal:content="msg">err</em>
-              </tal:block>
-            </tal:block>
-          </td>
         </div>
       </tal:block>
-    </tr>
-  </table>
-  <br />
+    </td>
+  </tr>
+</table>
+
+<tal:block condition="is_flexible">
+<div tal:define="flexible_widgets options/flexible_widgets">
+  <input type="hidden" name="layout_id" value="."
+    tal:attributes="value layout/layout_id" />
+  <tal:select condition="python:len(flexible_widgets)>1">
+    <select name="widget_type">
+      <tal:block repeat="widget options/flexible_widgets">
+      <option value="."
+        tal:condition="widget/is_i18n"
+        i18n:translate=""
+        tal:attributes="value widget/getWidgetId"
+        tal:content="widget/title_or_id">Type</option>
+      <option value="."
+        tal:condition="not:widget/is_i18n"
+        tal:attributes="value widget/getWidgetId"
+        tal:content="widget/title_or_id">Type</option>
+      </tal:block>
+    </select>
+    <input type="button" id="addwidget_button"
+           name="addwidget_button" value="button_add"
+           class="context"
+           i18n:attributes="value"
+           tal:attributes="onclick python:'CPSFlexibleEdit.buttonClick(this, \'\')'" />
+  </tal:select>
+  <tal:button condition="python:len(flexible_widgets) == 1">
+    <tal:block define="widget python:flexible_widgets[0]">
+      <input type="hidden" name="widget_type"
+        tal:attributes="value widget/getWidgetId">
+      <input type="submit" name="addwidget_button"
+        id="addwidget_button"
+        tal:define="button_add python:cpsmcat('button_add');
+          widget_title python:cpsmcat(widget.title_or_id())"
+        tal:attributes="value string:${button_add} ${widget_title}"
+        class="context" />
+    </tal:block>
+  </tal:button>
+</div>
+</tal:block>
+
+<tal:block condition="python: last_layout">
+  <tal:block content="structure string:</div>" />
+  <metal:block define-slot="additional_content" />
+
+  <tal:block condition="not:creation">
+    <div class="tooltipArea" style="visibility: hidden;"
+      id="transition_comments_help"
+      onclick="showElement(false, 'transition_comments_help')"
+      i18n:translate="help_transition_comments_modification">
+      In this filed you can give the reason of the modification that you are doing on this document.
+      Your comments may be used to notify other users.
+    </div>
+    <dl>
+      <dt><label for="comments"
+          i18n:translate="transition_comments_modification">Reason of the modification</label>
+        <button type="button" class="tooltipControl"
+          onclick="toggleElementVisibility('transition_comments_help')"> ? </button>
+      </dt>
+      <dd>
+        <textarea name="comments" id="comments" cols="60" rows="3"
+          tal:content="nothing">
+        </textarea>
+      </dd>
+    </dl>
+  </tal:block>
   <input type="submit" class="standalone" name="cpsdocument_edit_button"
-         value="Save" 
-         id="cpsdocument_edit_button"
-         tal:condition="save_button" />
-  <input type="submit" class="standalone" name="apply_admission"
-         value="apply for admission"
-         id="cpsdocument_edit_and_view_button"
-         tal:condition="apply" 
-         tal:attributes="value apply"/>
-  <input type="submit" 
-         class="standalone" 
-         name="cpsdocument_create_button"
-         value="apply"
-         tal:attributes="value options/button"
-         tal:condition="creation" />
+    value="button_change" i18n:attributes="value" id="cpsdocument_edit_button"
+    tal:condition="not:creation" />
+  <input type="submit" class="standalone" name="cpsdocument_edit_and_view_button"
+    value="button_change_and_view" i18n:attributes="value"
+    id="cpsdocument_edit_and_view_button"
+    tal:condition="not:creation" />
+  <input type="submit" class="standalone" name="cpsdocument_create_button"
+    value="button_create" i18n:attributes="value" tal:condition="creation" />
+  <tal:block content="structure string:</div></form>" />
+</tal:block>
 
-</form>
 </metal:block>
Index: /WAeUP_SRP/trunk/skins/waeup_student/reserve_accommodation.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_student/reserve_accommodation.py	(revision 685)
+++ /WAeUP_SRP/trunk/skins/waeup_student/reserve_accommodation.py	(revision 686)
@@ -21,6 +21,6 @@
 if info['acco']:
     return context.REQUEST.RESPONSE.redirect("%s/accommodation_view" % info['acco'].absolute_url())
-res,psm,ds = lt.renderLayout(layout_id= 'student_accommodation_fe',
-                      schema_id= 'student_accommodation_fe',
+res,psm,ds = lt.renderLayout(layout_id= 'student_accommodation',
+                      schema_id= 'student_accommodation',
                       context=context,
                       mapping=validate and REQUEST,
