#-*- mode: python; mode: fold -*-
# $Id: __init__.py 3277 2008-03-07 08:12:02Z joachim $
from Products.CMFCore.utils import ContentInit, ToolInit
from Products.CMFCore.DirectoryView import registerDirectory
from Products.CMFCore import utils as cmfutils
from Products.CMFCore.permissions import AddPortalContent

from Products.GenericSetup import profile_registry
from Products.GenericSetup import EXTENSION

from Products.CPSCore.interfaces import ICPSSite
from Products.CPSDirectory.DirectoryTool import DirectoryTypeRegistry

import PatchCPSWorkflowWorkflowDefinition
import PatchCatalogToolSearchResults
import PatchCatalogToolXMLAdapter
import PatchCPSSchemasAttributeStorageAdapter
import PatchCPSSchemasDataModel
import PatchCPSSchemasVocabulariesTool
import PatchCPSMembershipTool
import PatchCPSUserFolderUserFolder
import PatchCPSStackingDirectoryStorageAdapter
import PatchBasicWidgetsCPSStringWidget
import PatchExtendedWidgetsCPSDateTimeWidget
import PatchBasicWidgetsUnprepare
import PatchFasterSessionData
import PatchQueueCatalogProcessQueue
import PatchZCatalogCatalogUpdateMetadata
# Only for CPS 3.4.1. In 3.4.2 and later this should be fixed.
import PatchCPSDefaultImportExport
import PatchRenderActionIcon
#import PatchZODBConnectionOpen
import PatchLocalizerMessageCatalog_gettext
import Products.WAeUP_SRP.WAeUPPermissions
import WAeUPTool

import Widgets
tools = (WAeUPTool.WAeUPTool,)

waeup_types = (
    ("University",('University',)),
    ("Academics",
       ("AcademicsFolder",
        "Certificate",
        "CertificateCourse",
        "Faculty",
        "Department",
        "Course",
        "CertificateCourse",
        "StudyLevel",
        )
     ),
     ("Accommodation",
        ("AccoFolder",
         "AccoHall",
         )
     ),
     ("Payment",
        ("PaymentsFolder",
         "Payment",
         )
     ),
     ("Students",
        ("StudentsFolder",
         "Student",
         "StudentAccommodation",
         "StudentStudyCourse",
         "StudentCourseResult",
         "StudentApplication",
         "StudentPume",
         "StudentClearance",
         "StudentPersonal",
         "StudentStudyLevel",
         #"Semester",
         "StudentCourseResult",
         # move to Academics later
         #"Semester",
         )
      ),
     ("ScratchCards",
         ("ScratchCardBatch",
          "ScratchCardBatchesFolder",
         )
     ),
     ("Documents",
        ("DocumentsFolder",
         "WAeUPDocument",
        )
     ),
     ("Upload",
        ("UploadsFolder",
         "Upload",
         )
     ),
    )

contentClasses = []
cc = []
for modu,names in waeup_types:
    mod = __import__('Products.WAeUP_SRP.%(modu)s' % vars(),
                globals(),
                locals(),
                ['*',]
                )
    for name in names:
        #print name
        contentClasses.append(getattr(mod,name))
        cc.append(getattr(mod,"add%(name)s" % vars()))
contentConstructors = tuple(cc)

fti = [{} for t in range(len(contentConstructors))]

registerDirectory('skins', globals())

def initialize(registrar):
    ToolInit('WAeUP Tool',
              tools=tools,
              icon='tool.gif',
              ).initialize(registrar)
    ContentInit('WAeUP Types',
                content_types = contentClasses,
                permission = AddPortalContent,
                extra_constructors = contentConstructors,
                fti = fti,
                ).initialize(registrar)

    # Extension profile registration
    profile_registry.registerProfile(
        'default',
        'WAeUP_SRP',
        "The WestAfrican e-University Project",
        'profiles/default',
        'WAeUP_SRP',
        EXTENSION,
        for_=ICPSSite)
##    DirectoryTypeRegistry.register(WAeUPTables.Applicants)

