Index: WAeUP_SRP/trunk/WAeUPImport.py
===================================================================
--- WAeUP_SRP/trunk/WAeUPImport.py	(revision 3983)
+++ WAeUP_SRP/trunk/WAeUPImport.py	(revision 3984)
@@ -75,4 +75,5 @@
         self.courses_catalog = waeup_tool.courses_catalog
         self.course_results = waeup_tool.course_results
+        self.payments_catalog = waeup_tool.payments_catalog
         self.applicants_catalog = waeup_tool.applicants_catalog
         #self.mode = mode
@@ -826,5 +827,5 @@
             d = {}
             transition = mapping.get('reg_transition','admit')
-            if transition not in ('admit','return','pay_school_fee','validate_courses'):
+            if transition not in ('admit','return','pay_school_fee','validate_courses','graduate'):
                 msg = "no valid transition provided"
                 break
@@ -871,17 +872,42 @@
         msg = ''
         export_file = "%s/export/students_removed.csv" % (i_home)
+        reimport_file = "%s/export/students_for_reimport.csv" % (i_home)
         
-        #toexport = {
-        #
-        #            'personal': ('firstname',
-        #                         'middlename',
-        #                         'lastname',
-        #                         'perm_address',
-        #                         ),
-        #            'clearance': ('lga',
-        #                          'birthday',
-        #                         )
-        #
-        #           }
+        toexport_for_reimport = {
+        
+                    'personal':  
+                             ('firstname',
+                              'middlename',
+                              'lastname',
+                              'sex',
+                              'email',
+                              'phone',
+                              'perm_address',
+                              ),
+                    'clearance': 
+                              ('matric_no',
+                              'nationality',
+                              'lga',
+                              'birthday',
+                              ),
+                    'application':
+                             ('jamb_reg_no',
+                              'entry_mode',
+                              'entry_session',
+                              'jamb_score',
+                              'app_email',
+                              'jamb_age',
+                              'jamb_state',
+                              'jamb_lga',
+                              'jamb_sex',
+                              ),
+                    'study_course':
+                              ('study_course',
+                              'current_level',
+                              'current_session',
+                              'current_verdict',
+                              'previous_verdict',
+                              )
+                   }
 
         sub_types = ['StudentApplication','StudentClearance','StudentPersonal','StudentStudyCourse']
@@ -903,21 +929,28 @@
                 # begin export
                 line = []
-                fields = []
-                for f in self.students_catalog.schema():
-                    fields.append(f)                
+                fields = ['student_id','reg_state','password']
+                line_for_reimport = []
+                fields_for_reimport = ['student_id','reg_state','password','import_mode']                
+                #fields = []
+                #for f in self.students_catalog.schema():
+                #    fields.append(f)                
                 for k in toexport.keys():
                     for f in toexport[k]:
                         fields.append(f)
+                for k in toexport_for_reimport.keys():
+                    for f in toexport_for_reimport[k]:
+                        fields_for_reimport.append(f)                        
                 if True:    #not os.path.exists(export_file):        
-                    #headline = ','.join(fields).replace('level','current_level')
                     headline = ','.join(fields)
-                    headline = headline + ',password'
                     open(export_file,"a").write(headline +'\n')
+                    headline_for_reimport = ','.join(fields_for_reimport)                    
+                    open(reimport_file,"a").write(headline_for_reimport +'\n')                    
                 format = '"%(' + ')s","%('.join(fields) + ')s"'
-                format = format + ',"%(password)s"'
+                format_for_reimport = '"%(' + ')s","%('.join(fields_for_reimport) + ')s"'
                 res = self.students_catalog(id = student_id)
                 student = res[0]
                 student_obj = getattr(students_folder,student_id)
-                d = student.getFormattedStudentEntry(student)
+                #d = student.getFormattedStudentEntry(student)
+                d = {'student_id':student_id,'reg_state':student.review_state,'import_mode':'create'}
                 for k in toexport.keys()[0:]:
                     try:
@@ -934,5 +967,11 @@
                 line.append(format % d)
                 open(export_file,"a").write('\n'.join(line) +'\n')
+                line_for_reimport.append(format_for_reimport % d)
+                open(reimport_file,"a").write('\n'.join(line_for_reimport) +'\n')                
                 self.course_results.getExportRemoveAllCourses(student_id = student_id, export = True, remove = True)
+#                self.course_results.getExportRemoveAllCourses(student_id = student_id, export = True, remove = False)
+                self.payments_catalog.getExportRemoveAllPayments(student_id = student_id, export = True, remove = True)
+#                self.payments_catalog.getExportRemoveAllPayments(student_id = student_id, export = True, remove = False)
+                self.waeup_tool.exportAllStudyLevels(student_id = student_id)
                 # end export
                 students_folder.manage_delObjects((student_id),)         
Index: WAeUP_SRP/trunk/WAeUPTables.py
===================================================================
--- WAeUP_SRP/trunk/WAeUPTables.py	(revision 3983)
+++ WAeUP_SRP/trunk/WAeUPTables.py	(revision 3984)
@@ -1697,4 +1697,6 @@
         return courses
     ###)    
+    
+   
 
 InitializeClass(CourseResults)
@@ -1795,4 +1797,34 @@
 
 
+    def getExportRemoveAllPayments(self,student_id,export=False,remove=False): ###(
+        ""
+        query = Eq('student_id',student_id)
+        pm_catalog = self.payments_catalog
+        payments = pm_catalog.evalAdvancedQuery(query)
+        payments_dic = []
+        fields = self.schema()
+        format = '"%(' + ')s","%('.join(fields) + ')s"'
+        for brain in payments:
+            d = {}
+            for field in fields:
+                d[field] = getattr(brain,field,'')
+            payments_dic.append(format % d)
+                
+        if export:
+            export_file = "%s/export/payments_removed.csv" % (i_home)
+            file_handler = open(export_file,"a")
+            headline = ','.join(fields)
+            file_handler.write(headline +'\n')
+            for line in payments_dic: 
+                file_handler.write(line +'\n')
+
+        if remove:
+            for brain in payments:
+                order_id = getattr(brain,'order_id','')
+                pm_catalog.deleteRecord(order_id)
+        
+        return payments_dic
+    ###)    
+
 InitializeClass(PaymentsCatalog)
 
Index: WAeUP_SRP/trunk/WAeUPTool.py
===================================================================
--- WAeUP_SRP/trunk/WAeUPTool.py	(revision 3983)
+++ WAeUP_SRP/trunk/WAeUPTool.py	(revision 3984)
@@ -1181,4 +1181,42 @@
             l.getContent().edit(mapping={'Title': "Level %s" % level})
         ###)
+        
+        
+    security.declareProtected(ModifyPortalContent,'makeStudentLevel') ###(
+    def exportAllStudyLevels(self,student_id):
+        "export the StudyLevels for a student"
+        #import pdb;pdb.set_trace()
+        logger = logging.getLogger('WAeUPTool.exportAllStudyLevels')
+        students_folder = self.portal_url.getPortalObject().campus.students
+        res = self.students_catalog(id=student_id)
+        if res:
+            st = res[0]
+        course = st.course
+        matric_no = st.matric_no
+        level = st.level
+        student_obj = getattr(self.portal_url.getPortalObject().campus.students,student_id)
+        studycourse = getattr(student_obj,"study_course",None)
+        levels = studycourse.objectIds()
+        
+        stool = getToolByName(self, 'portal_schemas')
+        schema = stool._getOb('student_study_level')
+        fields = ['student_id','level']
+        fields.extend(schema.keys())
+        format = '"%(' + ')s","%('.join(fields) + ')s"'
+        export_file = "%s/export/study_levels_removed.csv" % (i_home)
+        file_handler = open(export_file,"a")
+        headline = ','.join(fields)
+        file_handler.write(headline +'\n')
+        
+        for level in levels:
+            level_object = getattr(studycourse,level)
+            level_content = level_object.getContent()
+            d = {'student_id':student_id,'level':level}
+            for field in schema.keys():
+                d[field] = getattr(level_content,field,'')    
+            line = format % d
+            file_handler.write(line +'\n')                
+            
+        ###)        
 
     security.declarePublic('getHallInfo') ###(
Index: WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_wf/definition.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_wf/definition.xml	(revision 3983)
+++ WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_wf/definition.xml	(revision 3984)
@@ -226,4 +226,5 @@
   <exit-transition transition_id="deactivate"/>
   <exit-transition transition_id="pay_school_fee"/>
+  <exit-transition transition_id="graduate"/>
   <permission-map name="Delete objects" acquired="False">
    <permission-role>Manager</permission-role>
