Index: WAeUP_SRP/trunk/skins/waeup_custom/logged_in.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_custom/logged_in.py	(revision 741)
+++ WAeUP_SRP/trunk/skins/waeup_custom/logged_in.py	(revision 742)
@@ -80,7 +80,6 @@
     member.setProperties(last_login_time=current,login_time=current)
     if info['review_state'] == "application_pin_entered":
-
         return response.redirect("%s/passport_entry_view" % student.absolute_url())
-    return response.redirect("%s" % student.absolute_url())
+    return response.redirect("%s/student_index" % info['url'])
 
 elif to_member_home:
Index: WAeUP_SRP/trunk/skins/waeup_student/getMaintainancePrefix.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/getMaintainancePrefix.py	(revision 742)
+++ WAeUP_SRP/trunk/skins/waeup_student/getMaintainancePrefix.py	(revision 742)
@@ -0,0 +1,23 @@
+## Script (Python) "cpsdocument_edit"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=
+##title=
+##
+# $Id: student_edit.py 486 2006-09-06 10:09:39Z joachim $
+"""
+return the Prefix for hostel maintainance scratchcards
+"""
+info = context.getStudentInfo()
+prefix = ""
+if not info['acco']:
+    return prefix
+bed = info['acco_doc'].bed
+hall,block,room,letter = bed.split('_')
+res = context.portal_catalog(portal_type="AccoHall",id=hall)
+if res and len(res) == 1:
+    prefix = res[0].getObject().getContent().maintainance_code
+return prefix
Index: WAeUP_SRP/trunk/skins/waeup_student/getStudentInfo.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/getStudentInfo.py	(revision 741)
+++ WAeUP_SRP/trunk/skins/waeup_student/getStudentInfo.py	(revision 742)
@@ -28,25 +28,15 @@
     if context.isManager() and 'students' in path_info:
         student_id = path_info[path_info.index('students')+1]
-##        if context.portal_type == 'Student':
-##            student_id = context.getId()
-##        elif context.aq_parent.portal_type == 'Student':
-##            student_id = context.aq_parent.getId()
-##        elif context.aq_parent.aq_parent.portal_type == 'Student':
-##            student_id = context.aq_parent.aq_parent.getId()
-##        elif context.aq_parent.aq_parent.aq_parent.portal_type == 'Student':
-##            student_id = context.aq_parent.aq_parent.aq_parent.getId()
-##        else:
-##            student_id = member_id
     else:
-        student_id = member_id
+        student_id = member_id 
 else:
     student_id = student.getId()
 res = context.portal_catalog(id = student_id,portal_type='Student')
-if not res or len(res) > 1:
+if not res:# or len(res) > 1:
     return None
 brain = res[-1]
 student = brain.getObject()
 student_path = brain.getPath()
-info['review_state'] = wf.getInfoFor(student,'review_state','keiner')
+info['review_state'] = wf.getInfoFor(student,'review_state',None)
 info['student'] = student
 info['id'] = student.getId()
@@ -66,4 +56,5 @@
     info['acco'] = acco
     info['acco_doc'] = acco.getContent()
+    info['acco_review_state'] = wf.getInfoFor(acco,'review_state',None) 
 else:
     info['acco'] = None
@@ -96,6 +87,8 @@
         row['s_edit_link'] = "%s/%s" % (student.absolute_url(),se_link)
     row['review_state'] = so.review_state
-    row['display'] = so.review_state in ('opened','closed')
+    row['display'] = so.review_state in ('opened','closed',) or so.portal_type == "StudentAccommodation"
     items.append(row)
 info['items'] = items
+request.set('student_id',student_id)
+request.set('student_url',info['url'])
 return info
Index: WAeUP_SRP/trunk/skins/waeup_student/layout_accommodation_view_slip.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/layout_accommodation_view_slip.pt	(revision 741)
+++ 	(revision )
@@ -1,36 +1,0 @@
-<!-- a layout_lib macro -->
-<!-- $Id: layout_lib_default_view.pt 34052 2006-03-06 14:59:24Z atchertchian $ -->
-<metal:block define-macro="default_view"
-  tal:define="layout options/layout;
-              dm options/datastructure/getDataModel;
-              widgets python:context.getRenderedWidgets(layout);
-              fields python:('session',
-                                 'bed',
-                                 'student_status',
-                                 'acco_res_sc_pin',
-                                 'acco_res_date',
-                                 'acco_maint_sc_pin', 
-                                 'acco_maint_date',
-                                 )"
-                                 >
-  <table width="" cellpadding="2" cellspacing="0" summary="Form layout">
-    <tr tal:repeat="field fields">
-      <tal:block tal:define="cell python: widgets[field]">
-        <tal:block define="widget cell/widget">
-          <div tal:attributes="class cell/widget_css_class|string:label;
-            id python:widget.getHtmlWidgetId()+'_widget';">
-            <td width="180px">
-             <span class="dlabel"
-                    tal:condition="widget/label"
-                    tal:content="widget/label">label</span>:
-            </td>
-            <td> 
-               <span tal:condition="cell" tal:content="structure cell/widget_rendered"></span>
-               <span tal:condition="not:cell/widget_rendered"> none </span>
-            </td>
-          </div>
-        </tal:block>
-      </tal:block>
-    </tr>
-  </table>
-</metal:block>
Index: WAeUP_SRP/trunk/skins/waeup_student/layout_student_acco_create.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/layout_student_acco_create.pt	(revision 742)
+++ WAeUP_SRP/trunk/skins/waeup_student/layout_student_acco_create.pt	(revision 742)
@@ -0,0 +1,138 @@
+<tal:block define="global creation python:1;
+                   global formaction string:apply_admission" />
+<!-- a layout_lib macro -->
+<!-- $Id: layout_application_edit.pt 672 2006-10-12 18:23:28Z joachim $ -->
+
+<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;
+  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">
+              <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>
+        </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 />
+  <input type="submit" class="standalone" name="cpsdocument_edit_button"
+         value="Save" 
+         id="cpsdocument_edit_button"
+         tal:condition="not:creation" />
+  <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" />
+
+</form>
+</metal:block>
Index: WAeUP_SRP/trunk/skins/waeup_student/layout_student_acco_edit.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/layout_student_acco_edit.pt	(revision 742)
+++ WAeUP_SRP/trunk/skins/waeup_student/layout_student_acco_edit.pt	(revision 742)
@@ -0,0 +1,138 @@
+<tal:block define="global creation python:0;
+                   global formaction string:apply_admission" />
+<!-- a layout_lib macro -->
+<!-- $Id: layout_application_edit.pt 672 2006-10-12 18:23:28Z joachim $ -->
+
+<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;
+  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">
+              <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>
+        </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 />
+  <input type="submit" class="standalone" name="cpsdocument_edit_button"
+         value="Save" 
+         id="cpsdocument_edit_button"
+         tal:condition="not:creation" />
+  <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" />
+
+</form>
+</metal:block>
Index: WAeUP_SRP/trunk/skins/waeup_student/layout_student_acco_view.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/layout_student_acco_view.pt	(revision 742)
+++ WAeUP_SRP/trunk/skins/waeup_student/layout_student_acco_view.pt	(revision 742)
@@ -0,0 +1,1 @@
+<metal:block use-macro="here/layout_waeup_lib/macros/table_view" />
Index: WAeUP_SRP/trunk/skins/waeup_student/layout_student_acco_view_slip.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/layout_student_acco_view_slip.pt	(revision 742)
+++ WAeUP_SRP/trunk/skins/waeup_student/layout_student_acco_view_slip.pt	(revision 742)
@@ -0,0 +1,36 @@
+<!-- a layout_lib macro -->
+<!-- $Id: layout_lib_default_view.pt 34052 2006-03-06 14:59:24Z atchertchian $ -->
+<metal:block define-macro="default_view"
+  tal:define="layout options/layout;
+              dm options/datastructure/getDataModel;
+              widgets python:context.getRenderedWidgets(layout);
+              fields python:('session',
+                                 'bed',
+                                 'student_status',
+                                 'acco_res_sc_pin',
+                                 'acco_res_date',
+                                 'acco_maint_sc_pin', 
+                                 'acco_maint_date',
+                                 )"
+                                 >
+  <table width="" cellpadding="2" cellspacing="0" summary="Form layout">
+    <tr tal:repeat="field fields">
+      <tal:block tal:define="cell python: widgets[field]">
+        <tal:block define="widget cell/widget">
+          <div tal:attributes="class cell/widget_css_class|string:label;
+            id python:widget.getHtmlWidgetId()+'_widget';">
+            <td width="180px">
+             <span class="dlabel"
+                    tal:condition="widget/label"
+                    tal:content="widget/label">label</span>:
+            </td>
+            <td> 
+               <span tal:condition="cell" tal:content="structure cell/widget_rendered"></span>
+               <span tal:condition="not:cell/widget_rendered"> none </span>
+            </td>
+          </div>
+        </tal:block>
+      </tal:block>
+    </tr>
+  </table>
+</metal:block>
Index: WAeUP_SRP/trunk/skins/waeup_student/reserve_accommodation.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/reserve_accommodation.py	(revision 741)
+++ WAeUP_SRP/trunk/skins/waeup_student/reserve_accommodation.py	(revision 742)
@@ -11,5 +11,6 @@
 
 info = context.getStudentInfo()
-validate = REQUEST.has_key("cpsdocument_create_button")
+validate = REQUEST.has_key("cpsdocument_create_button") or\
+           REQUEST.has_key("cpsdocument_edit_button")
 
 lt = context.portal_layouts
@@ -19,12 +20,23 @@
 info = context.getStudentInfo()
 student = info['student']
-if info['acco']:
-    return context.REQUEST.RESPONSE.redirect("%s/accommodation_view" % info['acco'].absolute_url())
-res,psm,ds = lt.renderLayout(layout_id= 'student_accommodation',
+mode = 'create'
+if info.has_key('acco') and info['acco']:
+    if info['acco_review_state'] == "maintainance_fee_payed":
+        return context.REQUEST.RESPONSE.redirect("%s/accommodation_view" % info['acco'].absolute_url())
+    else:
+        mode = 'edit'
+d = {}
+if mode == 'edit':
+    info = context.getStudentInfo()
+    d['acco_res_date'] = info['acco_doc'].acco_res_date
+    d['acco_res_sc_pin'] = info['acco_doc'].acco_res_sc_pin
+    d['bed'] = info['acco_doc'].bed
+    d['session'] = info['acco_doc'].session
+res,psm,ds = lt.renderLayout(layout_id= 'student_accommodation_fe',
                       schema_id= 'student_accommodation',
                       context=context,
                       mapping=validate and REQUEST,
-                      ob={},
-                      layout_mode='create',
+                      ob=d,
+                      layout_mode=mode,
                       formaction = "reserve_accommodation",
                       button = "Book",
@@ -47,10 +59,10 @@
 elif psm == 'valid':
     s_id = ds.get('s_id')
-    pin = str(ds.get('acco_res_ac_pin'))
-
-    pa = context.portal_accommodation
-    code,bed = pa.searchAndReserveBed(s_id,"%s_%s" % (info['sex'],ds.get('student_status')))
-    if code < 0:
-        return context.accommodation_pin_form(rendered = res,
+    if mode == 'create':
+        pin = str(ds.get('acco_res_sc_pin'))
+        pa = context.portal_accommodation
+        code,bed = pa.searchAndReserveBed(s_id,"%s_%s" % (info['sex'],ds.get('student_status')))
+        if code < 0:
+            return context.accommodation_pin_form(rendered = res,
                                  psm = bed,
                                  firstlayout = True,
@@ -58,12 +70,20 @@
                                  ds = ds,
                                  )
-student.invokeFactory('StudentAccommodation',acco_id)
+        student.invokeFactory('StudentAccommodation',acco_id)
+        acco = getattr(student,acco_id)
+        ds.set('acco_res_date', current)
+        ds.set('bed', bed)
+        ds.set('session', session)
+        acco.getContent().edit(mapping=ds)
+        #wftool.doActionFor(acco,'pay_maintainance_fee',dest_container=acco)
+        return context.REQUEST.RESPONSE.redirect("%s/accommodation_view" % student.absolute_url())
+pin = str(ds.get('acco_main_sc_pin'))
+pp = context.portal_pins
 acco = getattr(student,acco_id)
-wftool.doActionFor(acco,'open',dest_container=acco)
-ds.set('acco_res_date', current)
-ds.set('bed', bed)
-ds.set('session', session)
+ds.set('acco_maint_date', current)
 acco.getContent().edit(mapping=ds)
+wftool.doActionFor(acco,'pay_maintainance_fee',dest_container=acco)
 return context.REQUEST.RESPONSE.redirect("%s/accommodation_view" % student.absolute_url())
+
 ##return context.accommodation_pin_form(rendered = res,
 ##                                 psm = "successfully reserved bed %s" % bed,
Index: WAeUP_SRP/trunk/skins/waeup_student/student_index.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/student_index.py	(revision 741)
+++ WAeUP_SRP/trunk/skins/waeup_student/student_index.py	(revision 742)
@@ -34,4 +34,5 @@
     elif state == 'application_pin_entered':
         return redirect("%s/passport_entry_view" % student.absolute_url())
+    return redirect("%s/student_view" % student.absolute_url())
 
 
Index: WAeUP_SRP/trunk/skins/waeup_student/widget_scratch_card_pin_render.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/widget_scratch_card_pin_render.pt	(revision 741)
+++ WAeUP_SRP/trunk/skins/waeup_student/widget_scratch_card_pin_render.pt	(revision 742)
@@ -1,7 +1,8 @@
 <tal:block define="mode options/mode;
                    id here/getWidgetId;
+                   id_p string:${id}_p;
                    id_b string:${id}_b;
                    id_n string:${id}_n;
-                   prefix options/prefix;
+                   prefix options/datastructure/?id_p;
                    batch options/datastructure/?id_b;
                    nr options/datastructure/?id_n;
