Index: WAeUP_SRP/base/WAeUPImport.py
===================================================================
--- WAeUP_SRP/base/WAeUPImport.py	(revision 3232)
+++ WAeUP_SRP/base/WAeUPImport.py	(revision 3233)
@@ -85,9 +85,9 @@
         self.layout = self.layout_tool._getOb(iname,None)
         if self.schema is None:
-            errors.append('No schema %s' % iname)
+            errors.append('no schema %s' % iname)
         if self.pending_schema is None:
             self.pending_schema = self.schema
         if self.layout is None:
-            errors.append('No such layout %s' % iname)
+            errors.append('no such layout %s' % iname)
         self.data_keys = self.pending_schema.keys()
         self.csv_keys = self.pending_schema.keys()
@@ -187,13 +187,13 @@
             d = self._v_department_certificates.get(did,None)
             if d is None:
-                msg =  "No Department with ID: %s" % did
+                msg =  "no department with id: %s" % did
                 break
             certificate_id = mapping.get('code')
             if certificate_id in self._v_certificate_list:
-                msg =  "Duplicate Certificate ID: %s" % did
+                msg =  "duplicate certificate id: %s" % did
                 break
             c = getattr(d,certificate_id,None)
             if c is not None:
-                msg =  "Duplicate Certificate ID: %s" % did
+                msg =  "duplicate certificate id: %s" % did
                 break
             try:
@@ -215,5 +215,5 @@
         while True:
             if not res:
-                msg =  "No Certificate with ID: %s" % certificate_id
+                msg =  "no certificate with id: %s" % certificate_id
                 break
             c = res[0].getObject()
@@ -245,11 +245,11 @@
             department_courses = self._v_department_courses.get(department_id,None)
             if department_courses is None:
-                msg =  "No Department with ID: %(department_id)s" % vars()
+                msg =  "no department with id: %(department_id)s" % vars()
                 break
             if course_id in self._v_course_list:
-                msg =  "Duplicate Course ID: %(course_id)s" % vars()
+                msg =  "duplicate course id: %(course_id)s" % vars()
                 break
             if course_id in department_courses:
-                msg =  "Course %(course_id)s already exists in department %(department_id)s" % vars()
+                msg =  "course %(course_id)s already exists in department %(department_id)s" % vars()
                 break
             try:
@@ -270,5 +270,5 @@
         while True:
             if not res:
-                msg =  "No Course with ID: %s" % course_id
+                msg =  "no course with id: %s" % course_id
                 break
             c = res[0].getObject()
@@ -284,27 +284,34 @@
     plural_name = "%ss" % name
     commit_after = 1000000
-    required_modes = ('create','edit')
+    required_modes = ('create','edit','remove')
 
     def getStudentRecord(self,mapping): ###(
-        for id_key in ('student_id','matric_no'):
+        id_field_found = False
+        msg = ''
+        for id_key in ('id','matric_no'):
             id_field = mapping.get(id_key,'')
             if id_field:
+                if id_field_found:
+                    msg = "%s must not be provided" % id_key
+                    break
                 search_key = id_key
                 search_field = id_field
-                break
-        if search_key == "student_id":
-            search_key = 'id'
+                id_field_found = True
+        #if search_key == "student_id":
+        #    search_key = 'id'
+        if not id_field_found:
+            msg = "neither id nor matric_no provided"
+            return None,msg
         query = Eq(search_key,search_field)
         res = self.students_catalog.evalAdvancedQuery(query)
         student_record = None
-        msg = ''
         if res:
             student_record = res[0]
             if search_key == "matric_no":
-                mapping['student_id'] = student_record.id
-            elif search_key == "student_id":
+                mapping['id'] = student_record.id
+            elif search_key == "id":
                 mapping['matric_no'] = student_record.matric_no
         else:
-            msg = "No student with %(search_key)s %(search_field)s" % vars()
+            msg = "no student with %(search_key)s %(search_field)s" % vars()
         return student_record,msg
     ###)
@@ -324,5 +331,5 @@
             course_id = mapping.get('code')
             if course_id not in self._v_courses.keys():
-                msg = "No course with ID: %s" % course_id
+                msg = "no course with id: %s" % course_id
                 break
             student_record,msg = self.getStudentRecord(mapping)
@@ -374,4 +381,10 @@
             if msg:
                 break
+            if not mapping.get('level_id',''):
+                msg =  "level_id is missing"
+                break
+            if not mapping.get('code',''):
+                msg =  "code is missing"
+                break              
             student_id = student_record.id
             level_id = mapping['level_id']
@@ -382,10 +395,10 @@
             self.course_results.modifyRecord(**mapping)
         except KeyError:
-            msg = "No course result to edit: %s" % key
+            msg = "no course result with key %s" % key
         return key,msg,mapping
     ###)
 
     def remove(self,mapping):###(
-        id_key = ''
+        key = ''
         msg = ''
         while True:
@@ -393,4 +406,10 @@
             if msg:
                 break
+            if not mapping.get('level_id',''):
+                msg =  "level_id is missing"
+                break
+            if not mapping.get('code',''):
+                msg =  "code is missing"
+                break                
             student_id = student_record.id
             level_id = mapping['level_id']
@@ -398,5 +417,5 @@
             key = "%(student_id)s|%(level_id)s|%(code)s" % vars()
             if self.course_results.getRecordByKey(key) is None:
-                msg =  "no course-result with %(key)s" % vars()
+                msg =  "no course result with key %(key)s" % vars()
                 break
             self.course_results.deleteRecord(key)
@@ -426,10 +445,10 @@
             certificate_course_id = mapping.get('code')
             if certificate_course_id not in self._v_courses:
-                msg =  "No Course with ID: %s" % certificate_course_id
+                msg =  "no course with id: %s" % certificate_course_id
                 break
             cert_id = mapping['certificate_code']
             cert = self._v_certificates.get(cert_id,None)
             if cert is None:
-                msg =  "No Certificate with ID: %s" % cert_id
+                msg =  "no certificate with id: %s" % cert_id
                 break
             level_id = mapping.get('level')
@@ -439,5 +458,5 @@
                 level = getattr(cert,level_id,None)
             elif hasattr(level,certificate_course_id):
-                msg =  "Duplicate CertificateCourse ID: %(certificate_course_id)s " % vars()
+                msg =  "duplicate certificate course id: %(certificate_course_id)s " % vars()
                 msg += "in %(cert_id)s/ %(level_id)s" % vars()
                 break
@@ -467,5 +486,5 @@
             faculty = self._v_faculties.get(faculty_id,None)
             if faculty is None:
-                msg =  "No Faculty with ID: %s" % faculty_id
+                msg =  "no faculty with id: %s" % faculty_id
                 break
             else:
@@ -501,8 +520,8 @@
                 d = getattr(getattr(academics_folder,faculty_id),department_id,None)
             except KeyError:
-                msg =  "Department %s or Faculty %s wrong" % (department_id,faculty_id)
+                msg =  "department %s or faculty %s wrong" % (department_id,faculty_id)
                 break
             if d is None or d.portal_type == "Faculty":
-                msg =  "Department %s not found" % (department_id)
+                msg =  "department %s not found" % (department_id)
                 break
             d.getContent().edit(mapping=mapping)
@@ -524,5 +543,5 @@
         while True:
             if faculty_id in academics_folder.objectIds():
-                msg =  "Faculty with ID: %s exists" % faculty_id
+                msg =  "faculty with id: %s exists" % faculty_id
                 break
             logger.info('Creating Faculty %(code)s, %(title)s' % mapping)
@@ -546,5 +565,5 @@
             f = getattr(academics_folder,faculty_id,None)
             if f is None:
-                msg =  "Faculty with ID: %s does not exist" % faculty_id
+                msg =  "faculty with id: %s does not exist" % faculty_id
             f.getContent().edit(mapping=mapping)
             break
