Index: WAeUP_SRP/trunk/Students.py
===================================================================
--- WAeUP_SRP/trunk/Students.py	(revision 741)
+++ WAeUP_SRP/trunk/Students.py	(revision 742)
@@ -125,8 +125,5 @@
                 student_obj = getattr(self,sid)
                 access_code = "%d" % random.randint(1000000000,9999999999)
-                self.portal_registration.addMember(sid,
-                                                   access_code ,
-                                                   roles=('Member',
-                                                          'Student',))
+                student_obj.getContent().addMember(sid,access_code ,)
                 pwl_dict = {'student_id': sid,'access_code':access_code}
                 student_obj.invokeFactory('StudentApplication','application')
@@ -220,8 +217,189 @@
             pwlist.append(pwl_template.substitute(pwl_dict))
             wftool.doActionFor(student_obj,'clear_and_validate')
+            student_obj.manage_setLocalRoles(sid, ['Owner',])
             wftool.doActionFor(application,'close')
+            application.manage_setLocalRoles(sid, ['Owner',])
             wftool.doActionFor(clearance,'close')
+            clearance.manage_setLocalRoles(sid, ['Owner',])
             wftool.doActionFor(personal,'close')
+            personal.manage_setLocalRoles(sid, ['Owner',])
             wftool.doActionFor(studycourse,'close_for_edit')
+            studycourse.manage_setLocalRoles(sid, ['Owner',])
+        open("%s/import/pwlist-%s.csv" % (i_home,name),"w+").write('\n'.join(pwlist))
+        return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1'))
+    ###)
+
+    security.declareProtected(ModifyPortalContent,"loadPumeResultsFromCSV")###(
+    def loadPumeResultsFromCSV(self):
+        """load Fulltime Studentdata from CSV values"""
+        import transaction
+        import random
+        tr_count = 0
+        name = 'pume_results'
+        no_import = False
+        if not no_import:
+            no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w")
+            no_import.write('"MatricNo","EntryRegNo","CurrentSession","StudentLevel","fullname","FirstName","MiddleName","Lastname","FormerSurname","Sex","Nationality","State","LGA","PermanentAddress","PermanentAddressCity","CampusAddress","PhoneNumber","Emailaddress","Mode","CourseMajor","Faculty","Dept"\n')
+        logger = logging.getLogger('%s_import' % name)
+        logger.info('Start loading from %s.csv' % name)
+        pwlist  = []
+        pwlist.append('"student_id","firstname","middlename","lastname","jamb_reg_no","access_code"')
+        pwl_template = Template('"$student_id","$firstname","$middlename","$lastname","$jamb_reg_no","$access_code"')
+        students_folder = self.portal_catalog({'meta_type': 'StudentsFolder'})[-1].getObject()
+        try:
+            students = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb"))
+        except:
+            logger.error('Error reading %s.csv' % name)
+            return
+        l = self.portal_catalog({'meta_type': "StudentClearance",})
+        matrics = []
+        for s in l:
+            matrics.append(s.getObject().getContent().matric_no)
+        print matrics
+        l = self.portal_catalog({'meta_type': "Certificate"})
+        certs = {}
+        for c in l:
+            ca,ac,fa,dep_id,co,certcode = c.relative_path.split('/')
+            cid = "%(dep_id)s_%(certcode)s" % vars()
+            certs[cid] = c.getObject()
+        for student in students:
+            logger.info('processing "%(MatricNo)s","%(EntryRegNo)s","%(CurrentSession)s","%(StudentLevel)s","%(fullname)s","%(FirstName)s","%(MiddleName)s","%(Lastname)s","%(FormerSurname)s","%(Sex)s","%(Nationality)s","%(State)s","%(LGA)s","%(PermanentAddress)s","%(PermanentAddressCity)s","%(CampusAddress)s","%(PhoneNumber)s","%(Emailaddress)s","%(Mode)s","%(CourseMajor)s","%(Faculty)s","%(Dept)s"\n' % student)
+            sid = student.get('MatricNo')
+            if sid == "":
+                em = 'Empty MatricNo\n'
+                logger.info(em)
+                no_import.write(em)
+                no_import.write('"%(MatricNo)s","%(EntryRegNo)s","%(CurrentSession)s","%(StudentLevel)s","%(fullname)s","%(FirstName)s","%(MiddleName)s","%(Lastname)s","%(FormerSurname)s","%(Sex)s","%(Nationality)s","%(State)s","%(LGA)s","%(PermanentAddress)s","%(PermanentAddressCity)s","%(CampusAddress)s","%(PhoneNumber)s","%(Emailaddress)s","%(Mode)s","%(CourseMajor)s","%(Faculty)s","%(Dept)s"\n' % student)
+                continue
+            certcode = makeCertificateCode(student.get('CourseMajor'))
+            dep_id = student.get('Dept')
+            fac_id = student.get('Faculty')
+            cid = "%(dep_id)s_%(certcode)s" % vars()
+            if cid not in certs.keys():
+                em = 'Certificate with ID %s %s not found\n' % (certcode, student.get('CourseMajor'))
+                logger.info(em)
+                no_import.write(em)
+                no_import.write('"%(MatricNo)s","%(EntryRegNo)s","%(CurrentSession)s","%(StudentLevel)s","%(fullname)s","%(FirstName)s","%(MiddleName)s","%(Lastname)s","%(FormerSurname)s","%(Sex)s","%(Nationality)s","%(State)s","%(LGA)s","%(PermanentAddress)s","%(PermanentAddressCity)s","%(CampusAddress)s","%(PhoneNumber)s","%(Emailaddress)s","%(Mode)s","%(CourseMajor)s","%(Faculty)s","%(Dept)s"\n' % student)
+                continue
+            certificate_doc = certs[cid].getContent()
+            level = student.get('StudentLevel')
+            try:
+                int(level)
+            except:
+                em = 'Student with ID %(MatricNo)s StudentLevel is empty\n' % student
+                logger.info(em)
+                no_import.write(em)
+                no_import.write('"%(MatricNo)s","%(EntryRegNo)s","%(CurrentSession)s","%(StudentLevel)s","%(fullname)s","%(FirstName)s","%(MiddleName)s","%(Lastname)s","%(FormerSurname)s","%(Sex)s","%(Nationality)s","%(State)s","%(LGA)s","%(PermanentAddress)s","%(PermanentAddressCity)s","%(CampusAddress)s","%(PhoneNumber)s","%(Emailaddress)s","%(Mode)s","%(CourseMajor)s","%(Faculty)s","%(Dept)s"\n' % student)
+                continue
+            matric_no = student.get('MatricNo')
+            if matric_no not in matrics:
+                matrics.append(matric_no)
+                sid = self.generateStudentId(student.get('Lastname')[0])
+                #self.log('Creating Faculty %(id)s = %(Title)s' % faculty)
+                students_folder.invokeFactory('Student', sid)
+                logger.info('%(tr_count)s: Creating Student with ID %(sid)s Matric_no %(matric_no)s ' % vars())
+                student_obj = getattr(self,sid)
+                access_code = "%d" % random.randint(1000000000,9999999999)
+                student_obj.getContent().addMember(sid,access_code ,)
+                pwl_dict = {'student_id': sid,'access_code':access_code}
+                student_obj.invokeFactory('StudentApplication','application')
+                application = student_obj.application
+                da = {'Title': 'Application Data'}
+                student_obj.invokeFactory('StudentPersonal','personal')
+                da['jamb_reg_no'] = student.get('EntryRegNo')
+                personal = student_obj.personal
+                dp = {'Title': 'Personal Data'}
+                student_obj.invokeFactory('StudentClearance','clearance')
+                clearance = student_obj.clearance
+                dc = {'Title': 'Clearance Data'}
+                dc['matric_no'] = matric_no
+                state = student.get('State')
+                lga = student.get('LGA')
+                if state and lga:
+                    lga =  state + ' / ' + lga
+                else:
+                    lga = "None"
+                dc['lga'] = lga
+                dc['nationality'] = student.get('Nationality')
+                dc['email'] = student.get('Emailaddress')
+                dp['firstname'] = student.get('FirstName')
+                dp['middlename'] = student.get('MiddleName')
+                dp['lastname'] = student.get('Lastname')
+                dp['former_surname'] = student.get('FormerSurname')
+                dp['sex'] = student.get('Sex') == 'F'
+                dp['perm_address'] = student.get('PermanentAddress')
+                dp['perm_city'] = student.get('PermanentAddressCity')
+                dp['campus_address'] = student.get('CampusAddress')
+                dp['phone'] = student.get('PhoneNumber')
+                application.getContent().edit(mapping=da)
+                personal.getContent().edit(mapping=dp)
+                clearance.getContent().edit(mapping=dc)
+                #
+                # Study Course
+                #
+                student_obj.invokeFactory('StudentStudyCourse','study_course')
+                studycourse = student_obj.study_course
+                dsc = {}
+                from_certificate = ['title',
+                                   'max_elect',
+                                   'max_pass',
+                                   'n_core',
+                                   'nr_years',
+                                   'probation_credits',
+                                   'promotion_credits',
+                                   'start_level',
+                                  ]
+                for f in from_certificate:
+                    dsc[f] = getattr(certificate_doc,f)
+                dsc['faculty'] = fac_id
+                dsc['department'] = dep_id
+                dsc['study_course'] = certcode
+                css = student.get('CurrentSession') or '2004-2005'
+                cs = int(css.split('-')[0]) - 2000
+                cl = int(student.get('StudentLevel') or '100')/100
+                dsc['entry_session'] = "200%s" % (cs - cl)
+                dsc['clr_ac_pin'] = access_code
+                studycourse.getContent().edit(mapping=dsc)
+                #
+                # Level
+                #
+##                l = getattr(studycourse,level,None)
+##                if 0 and l is None:
+##                    #self.log('Creating Department %(DeptCode)s = %(Description)s' % dep)
+##                    logger.info('Creating Level %(StudentLevel)s for %(fullname)s' % student)
+##                    studycourse.invokeFactory('StudentStudyLevel', level)
+##                    l = getattr(studycourse, level)
+##                    certificate = certs[certcode]
+##                    cert_level = getattr(certificate,level,None)
+##                    if cert_level is None:
+##                        logger.info('Level %(level)s not in %(certcode)s' % vars())
+##                    l.getContent().edit(mapping={'Title': "Level %s" % level})
+            else:
+                em = 'Student with ID %(MatricNo)s %(fullname)s already exists\n' % student
+                logger.info(em)
+                no_import.write(em)
+                no_import.write('"%(MatricNo)s","%(EntryRegNo)s","%(CurrentSession)s","%(StudentLevel)s","%(fullname)s","%(FirstName)s","%(MiddleName)s","%(Lastname)s","%(FormerSurname)s","%(Sex)s","%(Nationality)s","%(State)s","%(LGA)s","%(PermanentAddress)s","%(PermanentAddressCity)s","%(CampusAddress)s","%(PhoneNumber)s","%(Emailaddress)s","%(Mode)s","%(CourseMajor)s","%(Faculty)s","%(Dept)s"\n' % student)
+                continue
+            if tr_count > MAX_TRANS:
+                transaction.commit()
+                em = 'Transaction commited\n' % student
+                logger.info(em)
+                tr_count = 0
+            tr_count += 1
+            pwl_dict.update(dc)
+            pwl_dict.update(da)
+            pwl_dict.update(dp)
+            wftool = self.portal_workflow
+            pwlist.append(pwl_template.substitute(pwl_dict))
+            wftool.doActionFor(student_obj,'clear_and_validate')
+            student_obj.manage_setLocalRoles(sid, ['Owner',])
+            wftool.doActionFor(application,'close')
+            application.manage_setLocalRoles(sid, ['Owner',])
+            wftool.doActionFor(clearance,'close')
+            clearance.manage_setLocalRoles(sid, ['Owner',])
+            wftool.doActionFor(personal,'close')
+            personal.manage_setLocalRoles(sid, ['Owner',])
+            wftool.doActionFor(studycourse,'close_for_edit')
+            studycourse.manage_setLocalRoles(sid, ['Owner',])
         open("%s/import/pwlist-%s.csv" % (i_home,name),"w+").write('\n'.join(pwlist))
         return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1'))
@@ -294,5 +472,6 @@
             course_doc = courses[course].getContent()
             temp_level = result.get('Level')
-            result['StudentId'] = sf.getId()
+            student_id = sf.getId()
+            result['StudentId'] = student_id
             if temp_level != level:
                 try:
@@ -313,4 +492,5 @@
                     sc.invokeFactory('StudentStudyLevel', level)
                     l = getattr(sc, level)
+                    l.manage_setLocalRoles(student_id, ['Owner',])
             else:
                 level_changed = False
@@ -341,4 +521,5 @@
             dlev['imported_gpa'] = getFloat(gpa)
             cr.getContent().edit(mapping = dcr)
+            cr.manage_setLocalRoles(student_id, ['Owner',])
             l.getContent().edit(mapping = dlev)
             if tr_count > MAX_TRANS:
Index: WAeUP_SRP/trunk/Widgets.py
===================================================================
--- WAeUP_SRP/trunk/Widgets.py	(revision 741)
+++ WAeUP_SRP/trunk/Widgets.py	(revision 742)
@@ -340,5 +340,4 @@
     prefix = ''
     reference = ''
-    
     def prepare(self, datastructure, **kw): ###(
         """Prepare datastructure from datamodel."""
@@ -346,13 +345,20 @@
         v = datamodel[self.fields[0]]
         widget_id = self.getWidgetId()
-        if v and type(v) is StringType:
-            p,b,n = v.split('-')
-            v = ScratchCardPin(v,b,n)
+        #import pdb;pdb.set_trace()
+##        if v and type(v) is StringType:
+##            p,b,n = v.split('-')
+##            v = ScratchCardPin(v,b,n)
         if v:
+            p = '%s' % v.p
             b = '%s' % v.b
             n = '%s' % v.n
         else:
+            p = self.prefix
+            if p.startswith('@'):
+                p = getattr(self,self.prefix[1:])()
             b = n = ''
+            v = ScratchCardPin(p,b,n)
         datastructure[widget_id] = v
+        datastructure[widget_id+'_p'] = p
         datastructure[widget_id+'_b'] = b
         datastructure[widget_id+'_n'] = n
@@ -362,18 +368,20 @@
     def validate(self, datastructure, **kw):
         """Validate datastructure and update datamodel."""
+        #import pdb;pdb.set_trace()
         widget_id = self.getWidgetId()
         v = datastructure[widget_id]
         err = 0
-        p = self.prefix
+        prefix= self.prefix
+        if prefix.startswith('@'):
+            prefix= getattr(self,self.prefix[1:])()
         b = datastructure[widget_id+'_b'].strip()
         n = datastructure[widget_id+'_n'].strip()
         pins = self.portal_pins
-        pin = "%(p)s%(b)s%(n)s" % vars()
+        pin = "%(prefix)s%(b)s%(n)s" % vars()
         if self.reference == "":
             ref = str(self.portal_membership.getAuthenticatedMember())
         else:
             ref = datastructure[self.reference]
-        #import pdb;pdb.set_trace()
-        ok = pins.searchAndSetRecord(pin,ref,self.prefix)
+        ok = pins.searchAndSetRecord(pin,ref,prefix)
         while 1:
             if ok == -2:
@@ -406,10 +414,10 @@
         else:
             datamodel = datastructure.getDataModel()
-            datamodel[self.fields[0]] = ScratchCardPin(self.prefix,b,n)
-            datastructure[widget_id] = ScratchCardPin(self.prefix,b,n)
+            datamodel[self.fields[0]] = ScratchCardPin(prefix,b,n)
+            datastructure[widget_id] = ScratchCardPin(prefix,b,n)
+            datastructure[widget_id+'_p'] = prefix
             datastructure[widget_id+'_b'] = b
             datastructure[widget_id+'_n'] = n
             datastructure['s_id'] = s_id
-        #import pdb;pdb.set_trace()
         return not err
 
@@ -428,19 +436,23 @@
         v = datamodel[self.fields[0]]
         if v and type(v) is StringType:
-            p,b,n = v.split('-')
-            v = ScratchCardPin(p,b,n)
+            prefix,b,n = v.split('-')
+            v = ScratchCardPin(prefix,b,n)
         if v:
+            prefix= '%s' % v.p
             b = '%s' % v.b
             n = '%s' % v.n
         else:
+            prefix= self.prefix
+            if prefix.startswith('@'):
+                prefix= getattr(self,self.prefix[1:])()
             b = n = ''
-        if mode in ['edit', 'create']:
-            widget_id = self.getWidgetId()
-            datastructure[widget_id] = v
-            datastructure[widget_id+'_b'] = b
-            datastructure[widget_id+'_n'] = n
+            v = ScratchCardPin(prefix,b,n)
+        widget_id = self.getWidgetId()
+        datastructure[widget_id] = v
+        datastructure[widget_id+'_p'] = prefix
+        datastructure[widget_id+'_b'] = b
+        datastructure[widget_id+'_n'] = n
         return meth(mode=mode, 
                     datastructure=datastructure, 
-                    prefix=self.prefix,
                     )
     ###)
Index: WAeUP_SRP/trunk/profiles/default/layouts/student_accommodation_fe.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/layouts/student_accommodation_fe.xml	(revision 741)
+++ WAeUP_SRP/trunk/profiles/default/layouts/student_accommodation_fe.xml	(revision 742)
@@ -4,33 +4,7 @@
  <property name="layout_edit_method"></property>
  <property name="layout_view_method"></property>
- <property name="style_prefix">layout_accommodation_</property>
+ <property name="style_prefix">layout_student_acco_</property>
  <property name="flexible_widgets"/>
  <property name="validate_values_expr"></property>
- <widget name="acco_res_sc_pin" meta_type="Scratchcard Pin Widget">
-  <property name="title">Hostel Application PIN</property>
-  <property name="fields">
-   <element value="acco_res_sc_pin"/>
-  </property>
-  <property name="is_required">True</property>
-  <property name="label">Hostel Application PIN</property>
-  <property name="label_edit">Hostel Application PIN</property>
-  <property name="readonly_layout_modes"/>
-  <property name="hidden_layout_modes"/>
-  <property name="hidden_readonly_layout_modes"/>
-  <property name="prefix">HOS</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_maint_date" meta_type="DateTime Widget">
   <property name="title">Maintainance Payment Date</property>
@@ -41,8 +15,10 @@
   <property name="label_edit">Maintainance Payment Date</property>
   <property name="readonly_layout_modes"/>
-  <property name="hidden_layout_modes"/>
+  <property name="hidden_layout_modes">
+   <element value="create"/>
+   <element value="edit"/>
+  </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="Scratchcard Pin Widget">
@@ -54,10 +30,10 @@
   <property name="label_edit">Maintainance Payment PIN</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="hidden_empty"></property>
+  <property name="prefix">@getMaintainancePrefix</property>
  </widget>
-
-
  <widget name="acco_res_date" meta_type="DateTime Widget">
   <property name="title">Hostel Application Date</property>
@@ -67,22 +43,42 @@
   <property name="label">Hostel Application Date</property>
   <property name="label_edit">Hostel Application Date</property>
-  <property name="readonly_layout_modes"/>
-  <property name="hidden_layout_modes"/>
+  <property name="readonly_layout_modes">
+   <element value="edit"/>
+  </property>
+  <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="Scratchcard Pin Widget">
+  <property name="title">Hostel Application PIN</property>
+  <property name="fields">
+   <element value="acco_res_sc_pin"/>
+  </property>
+  <property name="is_required">True</property>
+  <property name="label">Hostel Application PIN</property>
+  <property name="label_edit">Hostel Application PIN</property>
+  <property name="readonly_layout_modes">
+   <element value="edit"/>
+  </property>
+  <property name="hidden_layout_modes"/>
+  <property name="hidden_readonly_layout_modes"/>
+  <property name="prefix">HOS</property>
+ </widget>
  <widget name="bed" meta_type="Method Widget">
- <property name="title">Bed</property>
- <property name="fields">
-  <element value="bed"/>
- </property>
- <property name="label">Bed</property>
- <property name="label_edit">Bed</property>
- <property name="readonly_layout_modes"/>
- <property name="hidden_layout_modes"/>
- <property name="hidden_readonly_layout_modes"/>
- <property name="render_method">formatBed</property>
-</widget>
+  <property name="title">Bed</property>
+  <property name="fields">
+   <element value="bed"/>
+  </property>
+  <property name="label">Bed</property>
+  <property name="label_edit">Bed</property>
+  <property name="readonly_layout_modes">
+   <element value="edit"/>
+  </property>
+  <property name="hidden_layout_modes"/>
+  <property name="hidden_readonly_layout_modes"/>
+  <property name="render_method">formatBed</property>
+ </widget>
  <widget name="session" meta_type="String Widget">
   <property name="title">Session</property>
@@ -92,10 +88,25 @@
   <property name="label">Session</property>
   <property name="label_edit">Session</property>
-  <property name="readonly_layout_modes">edit</property>
+  <property name="readonly_layout_modes">
+   <element value="edit"/>
+   <element value="create"/>
+  </property>
   <property name="hidden_layout_modes"/>
   <property name="hidden_readonly_layout_modes"/>
  </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">
+   <element value="edit"/>
+  </property>
+  <property name="hidden_layout_modes"/>
+  <property name="hidden_readonly_layout_modes"/>
+  <property name="vocabulary">student_status_voc</property>
+ </widget>
  <table>
   <row>
Index: WAeUP_SRP/trunk/profiles/default/workflows.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/workflows.xml	(revision 741)
+++ WAeUP_SRP/trunk/profiles/default/workflows.xml	(revision 742)
@@ -15,4 +15,5 @@
  <object name="waeup_section_wf" meta_type="CPS Workflow"/>
  <object name="waeup_student_wf" meta_type="CPS Workflow"/>
+ <object name="waeup_student_accommodation_wf" meta_type="CPS Workflow"/>
  <object name="waeup_student_subobject_wf" meta_type="CPS Workflow"/>
  <object name="waeup_workspace_wf" meta_type="CPS Workflow"/>
@@ -62,5 +63,5 @@
   </type>
   <type type_id="StudentAccommodation">
-   <bound-workflow workflow_id="waeup_student_subobject_wf"/>
+   <bound-workflow workflow_id="waeup_student_accommodation_wf"/>
   </type>
   <type type_id="StudentApplication">
Index: WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_accommodation_wf/definition.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_accommodation_wf/definition.xml	(revision 742)
+++ WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_accommodation_wf/definition.xml	(revision 742)
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<cps-workflow workflow_id="waeup_student_accommodation_wf"
+              title="CPS Workflow Definition"
+              state_variable="review_state"
+              meta_type="CPS Workflow">
+ <permission>Add portal content</permission>
+ <permission>Modify portal content</permission>
+ <permission>View</permission>
+ <state state_id="bed_reserved" title="">
+  <exit-transition transition_id="pay_maintainance_fee"/>
+  <exit-transition transition_id="remove"/>
+  <permission-map name="Add portal content" acquired="True">
+  </permission-map>
+  <permission-map name="Modify portal content"
+                  acquired="True">
+   <permission-role>Owner</permission-role>
+  </permission-map>
+  <permission-map name="View" acquired="True">
+   <permission-role>Owner</permission-role>
+  </permission-map>
+ </state>
+ <state state_id="maintainance_fee_payed" title="">
+  <exit-transition transition_id="remove"/>
+ </state>
+ <state state_id="removed" title="">
+ </state>
+ <transition transition_id="pay_maintainance_fee" title=""
+             new_state="maintainance_fee_payed"
+             trigger="USER" before_script="" after_script="">
+  
+  <guard>
+  </guard>
+ </transition>
+ <transition transition_id="remove" title=""
+             new_state="removed" trigger="USER"
+             before_script="" after_script="">
+  
+  <guard>
+  </guard>
+ </transition>
+ <transition transition_id="reserve_bed" title=""
+             new_state="bed_reserved" trigger="USER"
+             before_script="" after_script="">
+  
+  <guard>
+  </guard>
+  <transition-behavior behavior_id="initial-create"/>
+ </transition>
+</cps-workflow>
Index: WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_wf/definition.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_wf/definition.xml	(revision 741)
+++ WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_wf/definition.xml	(revision 742)
@@ -30,4 +30,5 @@
  </state>
  <state state_id="cleared_and_validated" title="">
+  <exit-transition transition_id="create_content"/>
  </state>
  <state state_id="clearence_requested" title="">
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;
