Index: WAeUP_SRP/trunk/Students.py
===================================================================
--- WAeUP_SRP/trunk/Students.py	(revision 965)
+++ WAeUP_SRP/trunk/Students.py	(revision 966)
@@ -22,4 +22,5 @@
 i_home = Globals.INSTANCE_HOME
 MAX_TRANS = 100
+import DateTime
 
 def makeCertificateCode(code): ###(
@@ -245,4 +246,60 @@
     security.declareProtected(ModifyPortalContent,"loadPumeResultsFromCSV")###(
     def loadPumeResultsFromCSV(self):
+        """load Fulltime Studentdata from CSV values into pumeresults catalog"""
+        import transaction
+        import random
+        from pdb import set_trace
+        csv_d = {'jamb_reg_no': "RegNumber",
+                 'status': "Admission Status",
+                 'name': "Name",
+                 'score': "Score",
+                 'sex': "Sex",
+                 'faculty': "Faculty",
+                 'department': "Dept",
+                 'course': "Course",
+                 'course_code_org': "Course Code",
+                 }
+        csv_fields = [f[1] for f in csv_d.items()]
+        tr_count = 0
+        total = 0
+        #name = 'pume_results'
+        name = 'pup'
+        no_import = []
+        s = ','.join(['"(%s)"' % fn for fn in csv_fields])
+        no_import.append('%s' % s)
+        open("%s/import/%s_not_imported.csv" % (i_home,name),"w").write(
+                    '\n'.join(no_import))
+        no_import = []
+        logger = logging.getLogger('%s_import' % name)
+        starttime = DateTime.now()
+        logger.info('Start loading from %s.csv' % name)
+        try:
+            result = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb"))
+        except:
+            logger.error('Error reading %s.csv' % name)
+            return
+        pume = self.portal_pumeresults
+        format = ','.join(['"%%(%s)s"' % fn for fn in csv_fields])
+        eduplicate = '"dupplicate",%s' % format 
+        for jamb in result:
+            dict = {}
+            #set_trace()
+            for f,fn in csv_d.items():
+                dict[f] = jamb.get(csv_d[f])
+            try:
+                pume.addRecord(**dict)
+            except ValueError:
+                logger.info(eduplicate % jamb)
+                #em = 'Student with REG-NO %(jamb_reg_no)s already exists\n' % dict
+                #logger.info(em)
+                no_import.append(eduplicate % jamb)
+        logger.info('End loading from %s.csv' % name)
+        if len(no_import) > 1:
+            open("%s/import/%s_not_imported.csv" % (i_home,name),"w+").write(
+            '\n'.join(no_import))
+        return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1'))
+
+    security.declareProtected(ModifyPortalContent,"createNewStudents")###(
+    def createNewStudents(self):
         """load Fulltime Studentdata from CSV values"""
         import transaction
@@ -263,5 +320,5 @@
                  #'batch': "Batch",
                  #'serial': "SerialNo",
-                 #'jamb_score': "JambScore",
+                 'jamb_score': "Score",
                  #'omitted':"Omitted",
                  #'search_key': "SearchKey",
@@ -290,5 +347,8 @@
         no_import = []
         s = ','.join(['"(%s)"' % fn for fn in csv_fields])
-        no_import.append('%s\n' % s)
+        no_import.append('%s' % s)
+        open("%s/import/%s_not_imported.csv" % (i_home,name),"w").write(
+                    '\n'.join(no_import))
+        no_import = []
         logger = logging.getLogger('%s_import' % name)
         logger.info('Start loading from %s.csv' % name)
@@ -327,4 +387,5 @@
             jamb_name = jamb.get(csv_d['jamb_lastname'])
             jamb_name.replace('>','')
+            jamb_name.replace('<','')
             names = jamb_name.split()
             letter = names[-1][0].upper()
@@ -341,8 +402,4 @@
             student = getattr(self,sid)
             student.manage_setLocalRoles(sid, ['Owner',])
-            student.invokeFactory('StudentClearance','clearance')
-            #wftool.doActionFor(student.clearance,'open')
-            dp = {'Title': 'Clearance/Eligibility Record'}
-            student.clearance.manage_setLocalRoles(sid, ['Owner',])
             student.invokeFactory('StudentPume','pume')
             dp = {'Title': 'Pume Data'}
@@ -353,5 +410,5 @@
                          'jamb_sex',
                          #'jamb_state',
-                         #'jamb_score',
+                         'jamb_score',
                          'jamb_first_cos',
                          'jamb_sex',
@@ -376,5 +433,22 @@
             #wftool.doActionFor(pume,'close')
             pume.manage_setLocalRoles(sid, ['Owner',])
-            student.getContent().createSubObjects()
+            #student.getContent().createSubObjects()
+            names = jamb_name.split()
+            dp = {} 
+            if len(names) == 3:
+                dp['firstname'] = names[0].capitalize()
+                dp['middlename'] = names[1].capitalize()
+                dp['lastname'] = names[2].capitalize()
+            elif len(names) == 2:
+                dp['firstname'] = names[0].capitalize()
+                dp['lastname'] = names[1].capitalize()
+            else:
+                dp['lastname'] = jamb_name
+            dp['sex'] = jamb.get(csv_d['jamb_sex']) == 'F'
+            student.invokeFactory('StudentPersonal','personal')
+            per = student.personal
+            per_doc = per.getContent()
+            per_doc.edit(mapping = dp)
+            per.manage_setLocalRoles(sid, ['Owner',])
             if jamb.get(csv_d['stud_status']) == "Admitted":
                 wftool.doActionFor(student,'pume_pass')
@@ -384,4 +458,11 @@
                 wftool.doActionFor(student,'reject_admission')
                 continue
+            #
+            # Clearance
+            #
+            student.invokeFactory('StudentClearance','clearance')
+            #wftool.doActionFor(student.clearance,'open')
+            dp = {'Title': 'Clearance/Eligibility Record'}
+            student.clearance.manage_setLocalRoles(sid, ['Owner',])
             #
             # Study Course
@@ -408,4 +489,8 @@
             study_course.getContent().edit(mapping=dsc)
             if tr_count > MAX_TRANS:
+                if len(no_import) > 1:
+                    open("%s/import/%s_not_imported.csv" % (i_home,name),"w+").write(
+                             '\n'.join(no_import))
+                    no_import = []
                 em = '%d transactions commited\n' % tr_count
                 transaction.commit()
@@ -413,7 +498,4 @@
                 total += tr_count
                 tr_count = 0
-        if len(no_import) > 1:
-            open("%s/import/%s_not_imported.csv" % (i_home,name),"w").write(
-                     '\n'.join(no_import))
         return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1'))
     ###)
Index: WAeUP_SRP/trunk/WAeUPTables.py
===================================================================
--- WAeUP_SRP/trunk/WAeUPTables.py	(revision 965)
+++ WAeUP_SRP/trunk/WAeUPTables.py	(revision 966)
@@ -1,2 +1,3 @@
+#-*- mode: python; mode: fold -*-
 # (C) Copyright 2005 AixtraWare <http://aixtraware.de>
 # Author: Joachim Schmitz <js@aixtraware.de>
@@ -166,4 +167,15 @@
 InitializeClass(PinTable)
 
+class PumeResultsTable(WAeUPTable):
+
+    meta_type = 'WAeUP PumeResults Tool'
+    name = "pumeresults"
+    key = "jamb_reg_no"
+    def __init__(self):
+        WAeUPTable.__init__(self, 'portal_pumeresults')
+
+
+InitializeClass(PumeResultsTable)
+
 # BBB:
 AccomodationTable = AccommodationTable
Index: WAeUP_SRP/trunk/Widgets.py
===================================================================
--- WAeUP_SRP/trunk/Widgets.py	(revision 965)
+++ WAeUP_SRP/trunk/Widgets.py	(revision 966)
@@ -288,5 +288,4 @@
     letters = 2
     letters_str = "L"*letters
-
     def validate(self, datastructure, **kw):
         """Validate datastructure and update datamodel."""
@@ -294,4 +293,5 @@
         valid = CPSStringWidget.validate(self, datastructure, **kw)
         #import pdb;pdb.set_trace()
+        pumeresults = self.portal_pumeresults
         if not valid:
             return 0
@@ -303,10 +303,10 @@
                 err = 'Invalid number, the expected format is: %s%s with N = Number, L = Letter' % (self.digits_str,self.letters_str)
             else:
-                s = getStudentByRegNo(self,value)
-                if s is None:
+                #s = getStudentByRegNo(self,value)
+                pume = pumeresults(jamb_reg_no = value)
+                if pume is None:
                     err = 'No Student with JAMB-Reg-No %s' % (value)
                 else:
-                    s_id = s.getId()
-                    datastructure['s_id'] = s_id
+                    datastructure['pume'] = pume[0]
             if err:
                 datastructure.setError(widget_id, err)
Index: WAeUP_SRP/trunk/exportimport.py
===================================================================
--- WAeUP_SRP/trunk/exportimport.py	(revision 965)
+++ WAeUP_SRP/trunk/exportimport.py	(revision 966)
@@ -99,4 +99,5 @@
     importWAeUPTable(site.portal_accommodation, '', context,'accommodation')
     importWAeUPTable(site.portal_pins, '', context,'pins')
+    importWAeUPTable(site.portal_pumeresults, '', context,'pumeresults')
 
 from Products.CPSCore.exportimport.catalog import CatalogToolXMLAdapter
Index: WAeUP_SRP/trunk/profiles/default/pumeresults.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/pumeresults.xml	(revision 966)
+++ WAeUP_SRP/trunk/profiles/default/pumeresults.xml	(revision 966)
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<object name="portal_catalog" meta_type="CMF Catalog">
+ <column value="jamb_reg_no"/>
+ <column value="name"/>
+ <column value="score"/>
+ <column value="sex"/>
+ <column value="faculty"/>
+ <column value="course"/>
+ <column value="status"/>
+ <column value="department"/>
+ <column value="course_code_org"/>
+ <column value="course_code"/>
+ <index name="jamb_reg_no" meta_type="FieldIndex">
+  <indexed_attr value="jamb_reg_no"/>
+ </index>
+ <index name="status" meta_type="KeywordIndex">
+  <indexed_attr value="status"/>
+ </index>
+ <index name="faculty" meta_type="KeywordIndex">
+  <indexed_attr value="faculty"/>
+ </index>
+ <index name="department" meta_type="KeywordIndex">
+  <indexed_attr value="department"/>
+ </index>
+ <index name="course_code" meta_type="KeywordIndex">
+  <indexed_attr value="course_code"/>
+ </index>
+ <index name="score" meta_type="FieldIndex">
+  <indexed_attr value="score"/>
+ </index>
+</object>
Index: WAeUP_SRP/trunk/profiles/default/toolset.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/toolset.xml	(revision 965)
+++ WAeUP_SRP/trunk/profiles/default/toolset.xml	(revision 966)
@@ -5,4 +5,6 @@
  <required tool_id="portal_pins"
            class="Products.WAeUP_SRP.WAeUPTables.PinTable"/>
+ <required tool_id="portal_pumeresults"
+           class="Products.WAeUP_SRP.WAeUPTables.PumeResultsTable"/>
  <required tool_id="waeup_tool"
            class="Products.WAeUP_SRP.WAeUPTool.WAeUPTool"/>
Index: WAeUP_SRP/trunk/skins/waeup_student/display_pume_result.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/display_pume_result.py	(revision 965)
+++ WAeUP_SRP/trunk/skins/waeup_student/display_pume_result.py	(revision 966)
@@ -44,9 +44,5 @@
                                  )
 elif psm == 'valid':
-    url = "%s/campus/students/%s/pume/pume_anon_view" % (context.portal_url(),ds['s_id'])
-    return REQUEST.RESPONSE.redirect(url)
-
-
-return
-
-
+    return context.pume_anon_view(pume=ds['pume'])
+##    url = "%s/campus/students/%s/pume/pume_anon_view" % (context.portal_url(),ds['s_id'])
+##    return REQUEST.RESPONSE.redirect(url)
Index: WAeUP_SRP/trunk/skins/waeup_student/display_pume_result.py.org
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/display_pume_result.py.org	(revision 966)
+++ WAeUP_SRP/trunk/skins/waeup_student/display_pume_result.py.org	(revision 966)
@@ -0,0 +1,52 @@
+##parameters=REQUEST
+# $Id$
+"""
+process the Application Form
+return html renderer + psm
+"""
+import DateTime
+current = DateTime.DateTime()
+pr = context.portal_registration
+
+
+type_name = 'StudentApplication'
+ti = context.portal_types[type_name]
+REQUEST.set('type_name',type_name)
+
+validate = REQUEST.has_key("cpsdocument_create_button")
+
+lt = context.portal_layouts
+pr = context.portal_registration
+
+res,psm,ds = lt.renderLayout(layout_id= 'student_application_search',
+                      schema_id= 'student_application',
+                      context=context,
+                      mapping=validate and REQUEST,
+                      ob={},
+                      layout_mode='create',
+                      formaction = "display_pume_result",
+                      button = "Search",
+                      )
+if psm == 'invalid':
+    return context.display_pume_result_form(rendered = res,
+                                 psm = "Please correct your input!",
+                                 #psm = "%s, %s" % (psm,ds),
+                                 firstlayout = True,
+                                 lastlayout = True,
+                                 ds = ds,
+                                 )
+elif psm == '':
+    return context.display_pume_result_form(rendered = res,
+                                 psm = None,
+                                 firstlayout = True,
+                                 lastlayout = True,
+                                 ds = ds,
+                                 )
+elif psm == 'valid':
+    url = "%s/campus/students/%s/pume/pume_anon_view" % (context.portal_url(),ds['s_id'])
+    return REQUEST.RESPONSE.redirect(url)
+
+
+return
+
+
Index: WAeUP_SRP/trunk/skins/waeup_student/getStudentInfo.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/getStudentInfo.py	(revision 965)
+++ WAeUP_SRP/trunk/skins/waeup_student/getStudentInfo.py	(revision 966)
@@ -48,14 +48,17 @@
 info['app'] = student.application
 info['app_doc'] = student.application.getContent()
-info['per'] = student.personal
-info['per_doc'] = student.personal.getContent()
+info['per'] = getattr(student,'personal',None)
+info['sex'] = 'male'
+if info['per'] is not None:
+    info['per_doc'] = student.personal.getContent()
+    if info['per_doc'].sex:
+        info['sex'] = 'female'
+else:
+    if info['app_doc'].jamb_sex == "F":
+        info['sex'] = 'female'
 course = getattr(student,'study_course',None)
-#
 info['course'] = course
 if course:
     info['course_doc'] = student.study_course.getContent()
-info['sex'] = 'male'
-if info['per_doc'].sex:
-    info['sex'] = 'female'
 #
 acco = getattr(student,'accommodation_2006',None)
Index: WAeUP_SRP/trunk/skins/waeup_student/pume_anon_slip.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/pume_anon_slip.pt	(revision 965)
+++ WAeUP_SRP/trunk/skins/waeup_student/pume_anon_slip.pt	(revision 966)
@@ -1,20 +1,25 @@
-<metal:html tal:define="app_doc python: context.aq_parent.application.getContent();
-                        pume_doc python: context.getContent()">
+<metal:html tal:define="pume python:context.portal_pumeresults(jamb_reg_no=request.get('nr'))[0]">
   <metal:body use-macro="here/main_template/macros/master">
     <metal:main fill-slot="main">
-      <h3>PUME Results of <span tal:content="app_doc/jamb_firstname" />
-                            <span tal:content="app_doc/jamb_lastname" /></h3>
-
-      <br />
-      <span tal:omit-tag=""
-            tal:content="structure python: app_doc.render(proxy=app_doc,
-            layout_mode='view_info', 
-            layout_id='student_application_fe')" 
-            />
-      <span tal:condition="python:1" tal:omit-tag=""
-            tal:content="structure python: pume_doc.render(proxy=pume_doc,
-            layout_mode='view_slip', 
-            layout_id='student_pume_fe')" 
-            />
+        <h3>PUME Results of <span tal:content="pume/name" /></h3>
+                            
+       <br />                            
+       <table>
+        <tr>
+          <th>JAMB Registration Nr</th><td tal:content="pume/jamb_reg_no"></td>
+        </tr>
+        <tr>
+          <th>Name</th><td tal:content="pume/name"></td>
+        </tr>
+        <tr>
+          <th>Score</th><td tal:content="pume/score"></td>
+        </tr>
+        <tr>
+          <th>Status</th><td tal:content="pume/status"></td>
+        </tr>
+        <tr>
+          <th>Course Requested</th><td tal:content="pume/course"></td>
+        </tr>
+      </table>
     </metal:main>
   </metal:body>
Index: WAeUP_SRP/trunk/skins/waeup_student/pume_anon_slip.pt.org
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/pume_anon_slip.pt.org	(revision 966)
+++ WAeUP_SRP/trunk/skins/waeup_student/pume_anon_slip.pt.org	(revision 966)
@@ -0,0 +1,21 @@
+<metal:html tal:define="app_doc python: context.aq_parent.application.getContent();
+                        pume_doc python: context.getContent()">
+  <metal:body use-macro="here/main_template/macros/master">
+    <metal:main fill-slot="main">
+      <h3>PUME Results of <span tal:content="app_doc/jamb_firstname" />
+                            <span tal:content="app_doc/jamb_lastname" /></h3>
+
+      <br />
+      <span tal:omit-tag=""
+            tal:content="structure python: app_doc.render(proxy=app_doc,
+            layout_mode='view_info', 
+            layout_id='student_application_fe')" 
+            />
+      <span tal:condition="python:1" tal:omit-tag=""
+            tal:content="structure python: pume_doc.render(proxy=pume_doc,
+            layout_mode='view_slip', 
+            layout_id='student_pume_fe')" 
+            />
+    </metal:main>
+  </metal:body>
+</metal:html>
Index: WAeUP_SRP/trunk/skins/waeup_student/pume_anon_view.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/pume_anon_view.pt	(revision 965)
+++ WAeUP_SRP/trunk/skins/waeup_student/pume_anon_view.pt	(revision 966)
@@ -1,10 +1,7 @@
-<metal:html tal:define="app_doc python: context.aq_parent.application.getContent();
-                        pume_doc python: context.getContent()">
+<metal:html tal:define="pume options/pume">
   <metal:body use-macro="here/main_template/macros/master">
     <metal:main fill-slot="main">
-
-            
         <div style="text-align: right">
-        <a href="" target="slip" tal:attributes="href string:pume_anon_slip"
+        <a href="" target="slip" tal:attributes="href string:pume_anon_slip?nr=${pume/jamb_reg_no}"
             onclick="javascript:window.open('','slip','width=600, height=700, directories=no, toolbar=no, location=no, menubar=yes, scrollbars=yes, status=no, resizable=no, dependent=no')">
             <img tal:attributes="src string:${here/portal_url}/actionicon_print.png" />
@@ -13,20 +10,24 @@
         </div>
 
-        <h3>PUME Results of <span tal:content="app_doc/jamb_firstname" />
-                            <span tal:content="app_doc/jamb_lastname" /></h3>
+        <h3>PUME Results of <span tal:content="pume/name" /></h3>
                             
        <br />                            
-
-        <span tal:omit-tag=""
-              tal:content="structure python: app_doc.render(proxy=app_doc,
-              layout_mode='view_info', 
-              layout_id='student_application_fe')" 
-              />        
-        <span tal:omit-tag=""
-              tal:content="structure python: pume_doc.render(proxy=pume_doc,
-              layout_mode='view_slip', 
-              layout_id='student_pume_fe')" 
-              />
-
+       <table>
+        <tr>
+          <th>JAMB Registration Nr</th><td tal:content="pume/jamb_reg_no"></td>
+        </tr>
+        <tr>
+          <th>Name</th><td tal:content="pume/name"></td>
+        </tr>
+        <tr>
+          <th>Score</th><td tal:content="pume/score"></td>
+        </tr>
+        <tr>
+          <th>Status</th><td tal:content="pume/status"></td>
+        </tr>
+        <tr>
+          <th>Course Requested</th><td tal:content="pume/course"></td>
+        </tr>
+      </table>
     </metal:main>
   </metal:body>
Index: WAeUP_SRP/trunk/skins/waeup_student/pume_anon_view.pt.org
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/pume_anon_view.pt.org	(revision 966)
+++ WAeUP_SRP/trunk/skins/waeup_student/pume_anon_view.pt.org	(revision 966)
@@ -0,0 +1,33 @@
+<metal:html tal:define="app_doc python: context.aq_parent.application.getContent();
+                        pume_doc python: context.getContent()">
+  <metal:body use-macro="here/main_template/macros/master">
+    <metal:main fill-slot="main">
+
+            
+        <div style="text-align: right">
+        <a href="" target="slip" tal:attributes="href string:pume_anon_slip"
+            onclick="javascript:window.open('','slip','width=600, height=700, directories=no, toolbar=no, location=no, menubar=yes, scrollbars=yes, status=no, resizable=no, dependent=no')">
+            <img tal:attributes="src string:${here/portal_url}/actionicon_print.png" />
+            PUME Result Slip
+        </a>
+        </div>
+
+        <h3>PUME Results of <span tal:content="app_doc/jamb_firstname" />
+                            <span tal:content="app_doc/jamb_lastname" /></h3>
+                            
+       <br />                            
+
+        <span tal:omit-tag=""
+              tal:content="structure python: app_doc.render(proxy=app_doc,
+              layout_mode='view_info', 
+              layout_id='student_application_fe')" 
+              />        
+        <span tal:omit-tag=""
+              tal:content="structure python: pume_doc.render(proxy=pume_doc,
+              layout_mode='view_slip', 
+              layout_id='student_pume_fe')" 
+              />
+
+    </metal:main>
+  </metal:body>
+</metal:html>
Index: WAeUP_SRP/trunk/skins/waeup_student/search_students.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/search_students.py	(revision 965)
+++ WAeUP_SRP/trunk/skins/waeup_student/search_students.py	(revision 966)
@@ -54,5 +54,6 @@
         'search_string': ''
         }
-
+#from Products.zdb import set_trace
+#set_trace()
 rend,psm,ds = lt.renderLayout(layout_id= 'student_search',
                       schema_id= 'student_search',
@@ -70,4 +71,5 @@
                              allowed = True,
                              )
+#set_trace()
 what = ds.get('search_mode')
 state = ds.get('review_state')
Index: WAeUP_SRP/trunk/skins/waeup_student/search_students_form.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/search_students_form.pt	(revision 965)
+++ WAeUP_SRP/trunk/skins/waeup_student/search_students_form.pt	(revision 966)
@@ -58,7 +58,5 @@
                        tal:content="student/id"></a></td>    
                 <td>
-                  <span tal:replace="python: student['per_doc'].firstname" />
-                  <span tal:replace="python: student['per_doc'].middlename" />
-                  <span tal:replace="python: student['per_doc'].lastname" />
+                  <span tal:replace="student/name" />
                 </td>    
                 <td><span tal:replace="python: student['app_doc'].jamb_reg_no" /></td>    
@@ -69,8 +67,4 @@
                           onclick="javascript:window.open('','edit','width=600, height=700, directories=no, toolbar=no, location=no, menubar=no, scrollbars=yes, status=no, resizable=no, dependent=no')"
                           >[change state]</a></td>
-                       
-                       
-                       
-                       
                 <td tal:condition="not: options/co_view|nothing"><span tal:replace="student/review_state" /></td>   
               </tr>
