Index: WAeUP_SRP/trunk/Academics.py
===================================================================
--- WAeUP_SRP/trunk/Academics.py	(revision 276)
+++ WAeUP_SRP/trunk/Academics.py	(revision 278)
@@ -17,28 +17,293 @@
 #registerDirectory('skins/waeup_faculty', globals())
 
-##class SCFolder(CPSDocument): ###(
-##    """
-##    WAeUP StudyCourseFolder containing StudyCourses 
-##    """
-##    meta_type = 'SCFolder'
-##    portal_type = meta_type
-##    security = ClassSecurityInfo()
-##    
-##    def __init__(self, id, **kw):
-##        CPSDocument.__init__(self, id, **kw)
-##
+class AcademicsFolder(CPSDocument): ###(
+    """
+    WAeUP AcademicsFolder containing StudyCourses 
+    """
+    meta_type = 'AcademicsFolder'
+    portal_type = meta_type
+    security = ClassSecurityInfo()
+
 ##    security.declareProtected(View,"Title")
 ##    def Title(self):
 ##        """compose title"""
-##        return "SCFolder of %s" % (self.title)
-##
-##InitializeClass(SCFolder)
-##
-##def addSCFolder(container, id, REQUEST=None, **kw):
-##    """Add a SCFolder."""
-##    ob = SCFolder(id, **kw)
-##    return CPSBase_adder(container, ob, REQUEST=REQUEST)
-##
-#####)
+##        return "AcademicsFolder of %s" % (self.title)
+
+    security.declareProtected(ModifyPortalContent,"loadFacultiesFromCSV")###(
+    def loadFacultiesFromCSV(self): 
+        """install Universityspecific Faculies from CSV values"""
+        #return
+        logger = logging.getLogger('loadfaculties')
+        logger.info('Start loading Faculties')
+        academics = self.portal_catalog({'meta_type': 'AcademicsFolder'})[-1].getObject()
+        try:
+            faculties = csv.DictReader(open("%s/import/faculty.csv" % i_home,"rb"))
+        except:
+            return
+        l = self.portal_catalog({'meta_type': "Faculty"})
+        facs = {}
+        for f in l:
+            facs[f.id] = f.getObject()
+        for faculty in faculties:
+            logger.info('processing %(Session)s %(FacultyCode)s %(Description)s %(CollegeCode)s %(FacultyKey)s %(Status)s %(degree_grade)s %(Bankcode)s' % faculty)
+            fid = faculty['FacultyCode']
+            f = facs.get(fid,None)
+            if f is None:
+                #self.log('Creating Faculty %(id)s = %(Title)s' % faculty)
+                logger.info('Creating Faculty with ID %(FacultyCode)s %(Description)s' % faculty)
+                academics.invokeFactory('Faculty', fid)
+                f = getattr(self,fid)
+            d = {'Title': faculty['Description']}
+            f.getContent().edit(mapping=d)
+    ###)
+
+    security.declareProtected(ModifyPortalContent,"yamlDumpFaculties")###(
+    def yamlDumpFaculties(self): 
+        """dump Faculies to Yaml"""
+        #return
+        import yaml
+        logger = logging.getLogger('dumpfaculties')
+        logger.info('Start dumping Faculties')
+        academics = self.portal_catalog({'meta_type': 'AcademicsFolder'})[-1].getObject()
+        l = self.portal_catalog({'meta_type': "Faculty"})
+        facs = {}
+        for f in l:
+            facs[f.id] = f.getObject()
+        for fid in facs.keys():
+            faculty = facs.get(fid).aq_self
+            logger.info('dumping %s %s ' % (faculty.id, faculty.title))
+            print yaml.dump(faculty)
+            
+    ###)
+
+
+    security.declareProtected(ModifyPortalContent,"loadDepartmentsFromCSV")###(
+    def loadDepartmentsFromCSV(self):
+        """install Universityspecific Faculies from CSV values"""
+        #return
+        logger = logging.getLogger('loaddepartments')
+        try:
+            deps = csv.DictReader(open("%s/import/departments.csv" % i_home,"rb"))
+        except:
+            return
+        l = self.portal_catalog({'meta_type': "Faculty"})
+        facs = {}
+        for f in l:
+            facs[f.id] = f.getObject()
+        for dep in deps:
+            logger.info('Processing %(Session)s %(DeptCode)s %(Description)s %(FacultyCode)s' % dep)
+            fid = dep['FacultyCode']
+            f = facs.get(fid,None)
+            if f is None:
+                logger.info( "No Faculty with ID: %s" % fid)
+            else:
+                did = dep.get('DeptCode')
+                d = getattr(f,did,None)
+                if d is None or d.portal_type == "Faculty":
+                    #self.log('Creating Department %(DeptCode)s = %(Description)s' % dep)
+                    logger.info('Creating Department %(DeptCode)s = %(Description)s' % dep)
+                    f.invokeFactory('Department', did)
+                    d = getattr(f,did)
+                dict = {'Title': dep['Description']}
+                d.getContent().edit(mapping=dict)
+    ###)
+    
+    security.declareProtected(ModifyPortalContent,"loadCoursesFromCSV")###(
+    def loadCoursesFromCSV(self):
+        """install Universityspecific Courses from CSV values"""
+        #return
+        logger = logging.getLogger('loadcourses')
+        try:
+            courses = csv.DictReader(open("%s/import/courses.csv" % i_home,"rb"))
+        except:
+            return
+        l = self.portal_catalog({'meta_type': "Faculty"})
+        facs = {}
+        for f in l:
+            facs[f.id] = f.getObject()
+        dl = self.portal_catalog({'meta_type': "Department"})
+        deps = {}
+        for d in dl:
+            deps[d.id] = d.getObject()
+        cl = self.portal_catalog({'meta_type': "Course"})
+        course_list = [ c.id for c in cl]
+        for course in courses:
+            logger.info('Processing %(CourseCode)s %(Description)s %(Credits)s %(Dept)s %(Semester)s %(Session)s %(PassMark)s %(CourseKey)s %(Category)s %(AdmStatus)s %(FORMERCODE)s' % course)
+            if course.get("FORMERCODE").endswith('BITS'):
+                continue
+            depid = course.get('Dept').upper()
+            if depid in deps.keys():
+                dept= deps.get(depid)
+    ##        elif depid in facs.keys():
+    ##            dept= facs.get(depid)
+            else:
+                logger.info("Dep %(Dept)s for Course %(CourseCode)s not found" % course)
+                continue
+            course_id = ''.join(re.split('\W+',course.get('CourseCode')))
+            if len(course_id) == 3:
+                course_id = "%s000" % course_id
+            elif len(course_id) != 6:
+                logger.info("invalid course_code %(CourseCode)s" % course)
+                #print course_id,course.get('CourseCode'),course.get('Description')
+                continue
+    ##        if course_id in course_list:
+    ##            continue
+            c = getattr(dept,course_id,None)
+            if c is None:
+                #self.log('Creating Department %(DeptCode)s = %(Description)s' % dep)
+                logger.info('Creating Course %(CourseCode)s  %(Description)s in Department %(Dept)s' % course)
+                dept.invokeFactory('Course', course_id)
+                c = getattr(dept,course_id)
+            dict = {'Title': course['Description']}
+            dict['code'] = course_id
+            dict['org_code'] = course.get('CourseCode') 
+            dict['credits'] = course.get('Credits')
+            dict['semester'] = course.get('Semester')
+            dict['session'] = course.get('Session')
+            dict['category'] = course.get('Category')
+            dict['passmark'] = course.get('PassMark')
+            c.getContent().edit(mapping=dict)
+    ###)
+
+    security.declareProtected(ModifyPortalContent,"loadCertificatesFromCSV")###(
+    def loadCertificatesFromCSV(self):
+        """install Universityspecific Certificates from CSV values"""
+        #return
+        logger = logging.getLogger('loadcertificates')
+        try:
+            certificates = csv.DictReader(open("%s/import/certificates.csv" % i_home,"rb"))
+        except:
+            return
+        f_ids = [f.id for f in self.portal_catalog({'meta_type': "Faculty"})]
+        #d_ids = [d.id for d in self.portal_catalog({'meta_type': "Department"})]
+        dl = self.portal_catalog({'meta_type': "Department"})
+        deps = {}
+        for d in dl:
+            deps[d.id] = d.getObject()
+        for certificate in certificates:
+            logger.info('Processing %(CertCode)s %(Description)s %(Faculty)s %(MaxPass)s %(MaxLoad)s %(session)s %(PromotionCredits)s %(Probationcredits)s %(StartLevel)s %(endLevel)s %(Nyears)s %(Ncore)s %(MaxElect)s %(MPREFIX)s %(Dept)s %(Admstatus)s %(category)s' % certificate)
+            depid = certificate.get('Dept')
+            facid = certificate.get('Faculty')
+            if facid not in f_ids:
+                logger.info('Faculty %(Faculty)s for %(CertCode)s %(Description)s not found' % certificate)
+                continue
+            if not deps.has_key(depid):
+                logger.info('Department %(Dept)s for %(CertCode)s %(Description)s not found' % certificate)
+                continue
+            certificate_id = "%(category)s_%(Admstatus)s_%(Dept)s" % certificate
+            dep = deps[depid]
+            c = getattr(dep,certificate_id,None)
+            if c is None:
+                #self.log('Creating Department %(DeptCode)s = %(Description)s' % dep)
+                logger.info('Creating certificate %(CertCode)s  %(Description)s in Department %(Dept)s' % certificate)
+                dep.invokeFactory('Certificate', certificate_id)
+                c = getattr(dep,certificate_id)
+            dict = {'Title': certificate['Description']}
+            code = certificate.get('CertCode')
+            code = code.replace('.','')
+            code = code.replace('(','')
+            code = code.replace(')','')
+            code = code.replace('/','')
+            code = code.replace(' ','')
+            code = code.replace('_','')
+            dict['code'] = code
+            dict['faculty'] = certificate.get('Faculty') 
+            dict['department'] = certificate.get('Dept') 
+            dict['max_pass'] = certificate.get('MaxPass')
+            dict['max_load'] = certificate.get('MaxLoad')
+            dict['admin_status'] = certificate.get('Admstatus')
+            dict['category'] = certificate.get('category')
+            dict['m_prefix'] = certificate.get('MPREFIX')
+            dict['nr_years'] = int(certificate.get('Nyears'))
+            nc = certificate.get('Ncore','1')
+            try: 
+                dict['n_core'] = int(nc)
+            except:
+                dict['n_core'] = 1
+            dict['start_level'] = certificate.get('StartLevel')
+            dict['end_level'] = certificate.get('endLevel')
+            dict['promotion_credits'] = certificate.get('PromotionCredits')
+            dict['probation_credits'] = certificate.get('ProbationCredits')
+            c.getContent().edit(mapping=dict)
+    ###)
+
+    security.declareProtected(ModifyPortalContent,"loadCertificateCoursesFromCSV")###(
+    def loadCertificateCoursesFromCSV(self):
+        """install Certificate Courses from CSV values"""
+        #return
+        logger = logging.getLogger('loadcertificatecourses')
+        try:
+            cert_courses = csv.DictReader(open("%s/import/course_level_courses.csv" % i_home,"rb"))
+        except:
+            return
+        d_ids = [d.id for d in self.portal_catalog({'meta_type': "Department"})]
+        for cert_course in cert_courses:
+            logger.info('Processing %(CosCode)s %(CertCode)s %(CoreKey)s %(Session)s %(Level)s %(Core)s %(Elective)s %(Mandatory)s %(AdmStatus)s %(Dept)s %(Semester)s' % cert_course)
+            depid = cert_course.get('Dept')
+            code = cert_course.get('CertCode')
+            code = code.replace('.','')
+            code = code.replace('(','')
+            code = code.replace(')','')
+            code = code.replace('/','')
+            code = code.replace(' ','')
+            code = code.replace('_','')
+            if cert_course.get('Session') != '2002/2003':
+                continue
+            certificate = self.portal_catalog({'meta_type': "Certificate",
+                                               'SearchableText': code})
+            if not certificate:
+                print code
+                logger.info('CertCode %(CertCode)s for %(CosCode)s not found' % cert_course)
+                continue
+            certificate = certificate[-1].getObject()
+            certificate_code = certificate.getId()
+            if depid not in d_ids:
+                logger.info('Department %(Dept)s for %(CertCode)s not found' % cert_course)
+                continue
+            course_code = cert_course.get('CosCode')
+            level = cert_course.get('Level')
+            l = getattr(certificate,level,None)
+            if l is None:
+                #self.log('Creating Department %(DeptCode)s = %(Description)s' % dep)
+                logger.info('Creating Level %(Level)s in certificate %(CertCode)s' % cert_course)
+                certificate.invokeFactory('StudyLevel', level)
+                l = getattr(certificate, level)
+                l.invokeFactory('Semester','first')
+                l.invokeFactory('Semester','second')
+            first_s = getattr(l,'first')
+            second_s = getattr(l,'second')
+            if cert_course.get('Semester') == '1':
+                semester = first_s
+            else:
+                semester = second_s
+            if hasattr(semester,course_code):
+                logger.info('Duplicate %(CosCode)s in Level %(Level)s' % cert_course)
+                continue
+                
+            semester.invokeFactory('CertificateCourse',course_code)
+            cc = getattr(semester,course_code)
+            dict = {}
+            dict['code'] = cert_course.get('CosCode')
+            dict['certificate_code'] = code
+            dict['certificate_code_org'] = cert_course.get('CertCode') 
+            dict['department'] = cert_course.get('Dept') 
+            dict['admin_status'] = cert_course.get('Admstatus')
+            dict['session'] = cert_course.get('Session')
+            if cert_course.get('Core') != '':
+                dict['core_or_elective'] = True
+            else:
+                dict['core_or_elective'] = False
+            dict['level'] = cert_course.get('Level')
+            cc.getContent().edit(mapping=dict)
+    ###)
+
+InitializeClass(AcademicsFolder)
+
+def addAcademicsFolder(container, id, REQUEST=None, **kw):
+    """Add a AcademicsFolder."""
+    ob = AcademicsFolder(id, **kw)
+    return CPSBase_adder(container, ob, REQUEST=REQUEST)
+
+###)
 
 class Certificate(CPSDocument): ###(
Index: WAeUP_SRP/trunk/__init__.py
===================================================================
--- WAeUP_SRP/trunk/__init__.py	(revision 276)
+++ WAeUP_SRP/trunk/__init__.py	(revision 278)
@@ -15,4 +15,5 @@
 
 import Products.WAeUP_SRP.WAeUPPermissions
+from Products.WAeUP_SRP.Academics import AcademicsFolder, addAcademicsFolder
 from Products.WAeUP_SRP.University import University, addUniversity
 from Products.WAeUP_SRP.Accommodation import AccoFolder, addAccoFolder
@@ -39,5 +40,5 @@
 contentClasses = (
     University,
-    #SCFolder,
+    AcademicsFolder,
     Certificate,
     CertificateCourse,
@@ -60,5 +61,5 @@
 contentConstructors = (
     addUniversity,
-    #addSCFolder,
+    addAcademicsFolder,
     addCertificate,
     addCertificateCourse,
@@ -81,5 +82,5 @@
 fti = (
     {}, # University
-    #{}, #SCFolder
+    {}, #AcademicsFolder
     {}, #Certificate
     {}, #CertificateCourse
Index: WAeUP_SRP/trunk/profiles/default/roots/uniportal.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/roots/uniportal.xml	(revision 276)
+++ WAeUP_SRP/trunk/profiles/default/roots/uniportal.xml	(revision 278)
@@ -2,4 +2,5 @@
 <object name="uniportal">
   <property name="title">University Portal</property>
+  <property name=".cpsskins_theme">waeup_plain_theme</property>
   <object name="academics" portal_type="AcademicsFolder" />
   <object name="accomodation" portal_type="AccoFolder" />
Index: WAeUP_SRP/trunk/profiles/default/types/AcademicsFolder.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/types/AcademicsFolder.xml	(revision 276)
+++ WAeUP_SRP/trunk/profiles/default/types/AcademicsFolder.xml	(revision 278)
@@ -57,3 +57,34 @@
   <permission value="University Manage"/>
  </action>
+ <action title="IMPORT: Faculties" action_id="import_faculties"
+    category="object" condition_expr=""
+    url_expr="string:${object_url}/loadFacultiesFromCSV" visible="True">
+  <permission value="Modify portal content"/>
+ </action>
+ <action title="Departments" action_id="import_departments" category="object"
+    condition_expr="" url_expr="string:${object_url}/loadDepartmentsFromCSV"
+    visible="True">
+  <permission value="Modify portal content"/>
+ </action>
+ <action title="Courses" action_id="import_courses" category="object"
+    condition_expr="" url_expr="string:${object_url}/loadCoursesFromCSV"
+    visible="True">
+  <permission value="Modify portal content"/>
+ </action>
+ <action title="Certificates" action_id="import_certificates"
+    category="object" condition_expr=""
+    url_expr="string:${object_url}/loadCertificatesFromCSV" visible="True">
+  <permission value="Modify portal content"/>
+ </action>
+ <action title="CertificateCourses" action_id="import_certificate_courses"
+    category="object" condition_expr=""
+    url_expr="string:${object_url}/loadCertificateCoursesFromCSV"
+    visible="True">
+  <permission value="Modify portal content"/>
+ </action>
+ <action title="EXPORT: Faculties" action_id="export_faculties"
+    category="object" condition_expr=""
+    url_expr="string:${object_url}/yamlDumpFaculties" visible="False">
+  <permission value="Modify portal content"/>
+ </action>
 </object>
