Index: /WAeUP_SRP/trunk/WAeUPImport.py
===================================================================
--- /WAeUP_SRP/trunk/WAeUPImport.py	(revision 5182)
+++ /WAeUP_SRP/trunk/WAeUPImport.py	(revision 5183)
@@ -1127,4 +1127,5 @@
             current_level = mapping.get('current_level','')
             transition = mapping.get('reg_transition',None)
+            change_reg_state = mapping.get('change_reg_state',None)  # for brute force method
             # the validate_courses import transition is not really useful because it does not execute validate_courses.py
             if transition and transition not in ('admit','return','graduate','pay_school_fee','validate_courses'):
@@ -1181,8 +1182,12 @@
                             pass
             if transition:
+                #import pdb;pdb.set_trace()
                 try:
                     self.portal_workflow.doActionFor(student_obj,transition)
                 except:
                     msg = "reg_transition not allowed"
+            elif change_reg_state:
+                msg = self.waeup_tool.changeStudentState(student_obj, change_reg_state)
+             
             if password:
                 self.waeup_tool.editPassword(student_id,password)
@@ -1441,5 +1446,6 @@
             level_review_state = wftool.getInfoFor(level_obj,'review_state',None)
             if level_review_state != "closed":
-                wftool.doActionFor(level_obj,'close')
+                #wftool.doActionFor(level_obj,'close')
+                self.waeup_tool.changeWorkflowState(level_obj, 'closed')
                 # msg = 'student %s: level %s is not closed' % (student_id,
                 #                                                      current_level)
@@ -1448,5 +1454,6 @@
             level_obj.getContent().edit(mapping = d)
             if student_review_state != "returning":
-                wftool.doActionFor(student_obj,'return')
+                #wftool.doActionFor(student_obj,'return')
+                self.waeup_tool.changeStudentState(student_obj, 'returning')
             # try:
             #     wftool.doActionFor(level_obj,'close')
Index: /WAeUP_SRP/trunk/WAeUPTool.py
===================================================================
--- /WAeUP_SRP/trunk/WAeUPTool.py	(revision 5182)
+++ /WAeUP_SRP/trunk/WAeUPTool.py	(revision 5183)
@@ -1929,3 +1929,119 @@
 
 
+    security.declareProtected(ModifyPortalContent,"changeWorkflowState")
+    def changeWorkflowState(self, content, state_id, acquire_permissions=False,
+                            portal_workflow=None, **kw):
+        """Change the workflow state of an object
+        @param content: Content obj which state will be changed
+        @param state_id: name of the state to put on content
+        @param acquire_permissions: True->All permissions unchecked and on riles and
+                                    acquired
+                                    False->Applies new state security map
+        @param portal_workflow: Provide workflow tool (optimisation) if known
+        @param kw: change the values of same name of the state mapping
+        @return: None
+        """
+    
+        if portal_workflow is None:
+            portal_workflow = getToolByName(content, 'portal_workflow')
+    
+        # Might raise IndexError if no workflow is associated to this type
+
+        wf_def = portal_workflow.getWorkflowsFor(content)[0]
+        wf_id= wf_def.getId()
+    
+        wf_state = {
+            'action': None,
+            'actor': None,
+            'comments': "Setting state to %s" % state_id,
+            'review_state': state_id,
+            'time': DateTime.DateTime(),
+            }
+    
+        # Updating wf_state from keyword args
+        for k in kw.keys():
+            # Remove unknown items
+            if not wf_state.has_key(k):
+                del kw[k]
+        if kw.has_key('review_state'):
+            del kw['review_state']
+        wf_state.update(kw)
+    
+        portal_workflow.setStatusOf(wf_id, content, wf_state)
+    
+        if acquire_permissions:
+            # Acquire all permissions
+            for permission in content.possible_permissions():
+                content.manage_permission(permission, acquire=1)
+        else:
+            # Setting new state permissions
+            wf_def.updateRoleMappingsFor(content)
+    
+        # Map changes to the catalogs
+        content.reindexObject(idxs=['allowedRolesAndUsers', 'review_state'])
+        return
+        
+        
+        
+    security.declareProtected(ModifyPortalContent,"changeStudentState")
+    def changeStudentState(self, content, state_id, acquire_permissions=False,
+                            portal_workflow=None, **kw):
+        """Change the student state of an object
+        
+        ChangeWorkflowState + indexing students_catalog and check for registration state
+
+        """
+    
+        if portal_workflow is None:
+            portal_workflow = getToolByName(content, 'portal_workflow')
+    
+        # Might raise IndexError if no workflow is associated to this type
+
+        wf_def = portal_workflow.getWorkflowsFor(content)[0]
+        wf_id= wf_def.getId()
+        wf = portal_workflow.getWorkflowById(wf_id)
+
+        if not wf.states.get(state_id):
+            return 'reg state does not exist'
+        
+        wf_state = {
+            'action': None,
+            'actor': None,
+            'comments': "Setting state to %s" % state_id,
+            'review_state': state_id,
+            'time': DateTime.DateTime(),
+            }
+    
+        # Updating wf_state from keyword args
+        for k in kw.keys():
+            # Remove unknown items
+            if not wf_state.has_key(k):
+                del kw[k]
+        if kw.has_key('review_state'):
+            del kw['review_state']
+        wf_state.update(kw)
+        
+        portal_workflow.setStatusOf(wf_id, content, wf_state)
+    
+        if acquire_permissions:
+            # Acquire all permissions
+            for permission in content.possible_permissions():
+                content.manage_permission(permission, acquire=1)
+        else:
+            # Setting new state permissions
+            wf_def.updateRoleMappingsFor(content)
+    
+        # Map changes to the catalogs
+        content.reindexObject(idxs=['allowedRolesAndUsers', 'review_state'])
+        data = {}
+        #import pdb;pdb.set_trace() 
+        student_id = content.getId()
+        res = self.students_catalog(id=student_id)
+        data['id'] = student_id
+        data['review_state'] = state_id
+        self.students_catalog.modifyRecord(**data)        
+        
+        return        
+
+
 InitializeClass(WAeUPTool)
Index: /WAeUP_SRP/trunk/profiles/default/layouts/import_student.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/layouts/import_student.xml	(revision 5182)
+++ /WAeUP_SRP/trunk/profiles/default/layouts/import_student.xml	(revision 5183)
@@ -31,4 +31,13 @@
   <property name="is_required">True</property>
  </widget>
+ 
+ <widget name="change_reg_state" meta_type="String Widget">
+  <property name="fields">
+   <element value="change_reg_state"/>
+  </property>
+  <property name="is_required">False</property>
+ </widget> 
+ 
+ 
  <widget name="email" meta_type="Email Widget">
   <property name="title">Email</property>
Index: /WAeUP_SRP/trunk/profiles/default/schemas/import_student.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/schemas/import_student.xml	(revision 5182)
+++ /WAeUP_SRP/trunk/profiles/default/schemas/import_student.xml	(revision 5183)
@@ -5,4 +5,5 @@
  <field name="import_mode" meta_type="CPS String Field"/>
  <field name="reg_transition" meta_type="CPS String Field"/>
+ <field name="change_reg_state" meta_type="CPS String Field"/>
  <field name="firstname" meta_type="CPS String Field"/>
  <field name="middlename" meta_type="CPS String Field"/>
