Index: WAeUP_SRP/trunk/WAeUPTool.py
===================================================================
--- WAeUP_SRP/trunk/WAeUPTool.py	(revision 2192)
+++ WAeUP_SRP/trunk/WAeUPTool.py	(revision 2193)
@@ -47,5 +47,5 @@
 import logging
 import transaction
-import csv,re,os
+import csv,re,os,sys
 from Products.AdvancedQuery import Eq, Between, Le,In
 
@@ -905,7 +905,56 @@
         return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1'))
     ###)
-
-
-    student_field2types = {   ###(
+    
+    security.declareProtected(ModifyPortalContent,'mass_create') ###(
+    def mass_create_department(self,mapping):
+        "create a department in the correct faculty"
+        logger = logging.getLogger('WAeUPTool.mass_create_department')
+        fid = mapping['faculty_code']
+        if getattr(self,'_v_faculties',None) is None:
+            res = self.portal_catalog(portal_type = "Faculty")
+            self._v_faculties = {}
+            for f in res:
+                self._v_faculties[f.getId] = f.getObject()
+        f = self._v_faculties.get(fid,None)
+        if f is None:
+            return '', "No Faculty with ID: %s" % fid
+        else:
+            did = mapping.get('code')
+            d = getattr(f,did,None)
+            if d is None or d.portal_type == "Faculty":
+                logger.info('Creating Department %(code)s = %(title)s' % mapping)
+                f.invokeFactory('Department', did)
+                d = getattr(f,did)
+                d.invokeFactory('CoursesFolder','courses')
+                courses = getattr(d,'courses')
+                dict = {'Title': 'Courses'}
+                courses.getContent().edit(mapping=dict)
+                d.invokeFactory('CertificatesFolder','certificates')
+                certificates = getattr(d,'certificates')
+                dict = {'Title': 'Certificates'}
+                certificates.getContent().edit(mapping=dict)
+            d.getContent().edit(mapping=mapping)
+        return did,''
+    ###)
+
+    security.declareProtected(ModifyPortalContent,'mass_edit') ###(
+    def mass_edit_department(self,mapping):
+        "create a department in the correct faculty"
+        logger = logging.getLogger('WAeUPTool.mass_create_department')
+        academics_folder = self.portal_url.getPortalObject().campus.academics
+        fid = mapping['faculty_code']
+        did = mapping.get('code')
+        try:
+            d = getattr(getattr(academics_folder,fid),did,None)
+        except KeyError:
+            return '', "Department %s or Faculty %s wrong" % (did,fid)
+        else:
+            if d is None or d.portal_type == "Faculty":
+                logger.info('Editing Department %(code)s = %(title)s' % mapping)
+            d.getContent().edit(mapping=mapping)
+        return did,''
+    ###)
+
+    field2types_student = {   ###(
                       'StudentApplication':
                           {'id': 'application',
@@ -985,9 +1034,8 @@
     ###)
 
-
-    security.declareProtected(ModifyPortalContent,'importStudent') ###(
-    def importStudent(self,mapping):
+    security.declareProtected(ModifyPortalContent,'mass_create_student') ###(
+    def mass_create_student(self,mapping):
         "create a students record due import"
-        logger = logging.getLogger('WAeUPTool.importStudent')
+        logger = logging.getLogger('WAeUPTool.mass_create_student')
         students_folder = self.portal_url.getPortalObject().campus.students
         jamb_reg_no = mapping.get('jamb_reg_no',None)
@@ -1004,5 +1052,5 @@
         students_folder.invokeFactory('Student', sid)
         student_obj = getattr(students_folder,sid)
-        f2t = self.student_field2types
+        f2t = self.field2types_student
         d = {}
         d['jamb_sex']  = 'M'
@@ -1035,8 +1083,8 @@
     ###)
 
-    security.declareProtected(ModifyPortalContent,'importEditStudent') ###(
-    def importEditStudent(self,mapping):
+    security.declareProtected(ModifyPortalContent,'mass_edit_student') ###(
+    def mass_edit_student(self,mapping):
         "edit a students record due import"
-        logger = logging.getLogger('WAeUPTool.importEditStudent')
+        logger = logging.getLogger('WAeUPTool.mass_edit_student')
         students_folder = self.portal_url.getPortalObject().campus.students
         sid = mapping.get('id',None)
@@ -1072,5 +1120,5 @@
         sid = res[0].id
         student_obj = getattr(students_folder,sid)
-        f2t = self.student_field2types
+        f2t = self.field2types_student
         d = {}
         #import pdb;pdb.set_trace()
@@ -1130,5 +1178,4 @@
     ###)
 
-
     security.declareProtected(ModifyPortalContent,"importData")###(
     def importData(self,filename,name,edit=False):
@@ -1164,8 +1211,9 @@
         for widget in layout.keys():
             validators[widget] = layout[widget].validate
+        #import pdb;pdb.set_trace()
         if edit:
-            importer_name = "importEdit%s" % name.capitalize()
-        else:
-            importer_name = "import%s" % name.capitalize()
+            importer_name = "mass_edit_%s" % name
+        else:
+            importer_name = "mass_create_%s" % name
         importer = getattr(self, '%s' % importer_name,None)
         if importer is None:
Index: WAeUP_SRP/trunk/profiles/default/layouts.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/layouts.xml	(revision 2192)
+++ WAeUP_SRP/trunk/profiles/default/layouts.xml	(revision 2193)
@@ -11,4 +11,5 @@
   <object name="certificate_course" meta_type="CPS Layout"/>
   <object name="course" meta_type="CPS Layout"/>
+  <object name="import_department" meta_type="CPS Layout"/>
   <object name="department" meta_type="CPS Layout"/>
   <object name="faculty" meta_type="CPS Layout"/>
Index: WAeUP_SRP/trunk/profiles/default/layouts/import_department.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/layouts/import_department.xml	(revision 2193)
+++ WAeUP_SRP/trunk/profiles/default/layouts/import_department.xml	(revision 2193)
@@ -0,0 +1,87 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="layout.xsl"?>
+<object name="import_department" meta_type="CPS Layout">
+ <property name="layout_create_method"></property>
+ <property name="layout_edit_method"></property>
+ <property name="layout_view_method"></property>
+ <property name="style_prefix">layout_waeup_</property>
+ <property name="flexible_widgets"/>
+ <property name="validate_values_expr"></property>
+ <widget name="code" meta_type="WAeUPId Widget">
+  <property name="title">Department Id</property>
+  <property name="fields">
+   <element value="code"/>
+  </property>
+  <property name="is_required">True</property>
+  <property name="label">Department Id</property>
+  <property name="label_edit">Department Id</property>
+  <property name="readonly_layout_modes"/>
+  <property name="hidden_layout_modes">
+   <element value="view"/>
+   <element value="edit"/>
+  </property>
+  <property name="hidden_readonly_layout_modes"/>
+ </widget>
+ <widget name="faculty_code" meta_type="String Widget">
+  <property name="title">Faculty Code</property>
+  <property name="fields">
+   <element value="faculty_code"/>
+  </property>
+  <property name="label">Faculty Code</property>
+  <property name="label_edit">Faculty Code</property>
+  <property name="readonly_layout_modes"/>
+  <property name="hidden_layout_modes"/>
+  <property name="hidden_readonly_layout_modes"/>
+ </widget>
+ <widget name="review_state" meta_type="String Widget">
+  <property name="title">Review State</property>
+  <property name="fields">
+   <element value="review_state"/>
+  </property>
+  <property name="label">Review State</property>
+  <property name="label_edit">Review State</property>
+  <property name="readonly_layout_modes"/>
+  <property name="hidden_layout_modes"/>
+  <property name="hidden_readonly_layout_modes"/>
+ </widget>
+ <widget name="title" meta_type="String Widget">
+  <property name="title">Title</property>
+  <property name="fields">
+   <element value="title"/>
+  </property>
+  <property name="label">Title</property>
+  <property name="label_edit">Title</property>
+  <property name="readonly_layout_modes"/>
+  <property name="hidden_layout_modes"/>
+  <property name="hidden_readonly_layout_modes"/>
+ </widget>
+ <widget name="title_prefix" meta_type="Select Widget">
+  <property name="title">Title Prefix</property>
+  <property name="fields">
+   <element value="title_prefix"/>
+  </property>
+  <property name="label">Title Prefix</property>
+  <property name="label_edit">Title Prefix</property>
+  <property name="readonly_layout_modes"/>
+  <property name="hidden_layout_modes"/>
+  <property name="hidden_readonly_layout_modes"/>
+  <property name="vocabulary">institution_types_voc</property>
+ </widget>
+ <table>
+  <row>
+   <cell name="code"/>
+  </row>
+  <row>
+   <cell name="title_prefix"/>
+  </row>
+  <row>
+   <cell name="title"/>
+  </row>
+  <row>
+   <cell name="faculty_code"/>
+  </row>
+  <row>
+   <cell name=""/>
+  </row>
+ </table>
+</object>
Index: WAeUP_SRP/trunk/profiles/default/schemas.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/schemas.xml	(revision 2192)
+++ WAeUP_SRP/trunk/profiles/default/schemas.xml	(revision 2193)
@@ -11,4 +11,5 @@
  <object name="certificate_course" meta_type="CPS Schema"/>
  <object name="course" meta_type="CPS Schema"/>
+ <object name="import_department" meta_type="CPS Schema"/>
  <object name="department" meta_type="CPS Schema"/>
  <object name="faculty" meta_type="CPS Schema"/>
Index: WAeUP_SRP/trunk/profiles/default/schemas/import_department.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/schemas/import_department.xml	(revision 2193)
+++ WAeUP_SRP/trunk/profiles/default/schemas/import_department.xml	(revision 2193)
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="schema.xsl"?>
+<object name="import_department" meta_type="CPS Schema">
+ <field name="code" meta_type="CPS String Field"/>
+ <field name="faculty_code" meta_type="CPS String Field"/>
+ <field name="review_state" meta_type="CPS String Field"/>
+ <field name="title" meta_type="CPS String Field"/>
+ <field name="title_prefix" meta_type="CPS String Field"/>
+</object>
Index: WAeUP_SRP/trunk/profiles/default/vocabularies/import_names.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/vocabularies/import_names.xml	(revision 2192)
+++ WAeUP_SRP/trunk/profiles/default/vocabularies/import_names.xml	(revision 2193)
@@ -7,3 +7,4 @@
  <property name="acl_write_roles">Manager</property>
  <item key="student" msgid="">Student Data</item>
+ <item key="department" msgid="">Department Data</item>
 </object>
