from Products.CPSInstaller.CPSInstaller import CPSInstaller from Products.CMFCore.CMFCorePermissions import View, ModifyPortalContent try: from Products.CPSSubscriptions.permissions import CanNotifyContent CPSSubscriptions = True except ImportError: CPSSubscriptions = False try: from Products.CPSForum.CPSForumPermissions import ForumManageComments CPSForum = True except ImportError: CPSForum = False class WAeUPInstaller(CPSInstaller): """ WAeUP Installer """ product_name = "WAeUP" def install(self,portal): "install" product_name = self.product_name self.log("Starting %(product_name)s install" % vars() ) ########################################## # Actions ########################################## if CPSSubscriptions: ptypes = "('Portal', 'CPSMailAccess Message', 'CPSMailAccess Box', 'CPSMailAccess Folder',"\ + "'StudentFolder', 'Student', 'Jamb')" condition = "object.portal_type not in %s" % ptypes action = {'id' : 'notify_content', 'name' : 'action_notify_content', 'action' : 'string:${object_url}/content_notify_email_form', 'condition' : 'python:%s' % condition, 'permission' : (CanNotifyContent,), 'category' : 'object', } self.deleteActions({'portal_subscriptions': ['notify_content',]}) self.verifyAction('portal_subscriptions', **action) if CPSForum: ptypes = "('StudentFolder', 'Student', 'Jamb')" condition = "object.portal_type not in %s" % ptypes action = {'id' : 'activate_comments', 'name': 'action_activate_comments', 'action': 'string:${object/absolute_url}/set_comment_mode?mode=1', 'condition' : 'python:%s' % condition, 'permission': (ForumManageComments,), 'category' : 'object', } self.deleteActions({'portal_discussion': ['activate_comments',]}) self.verifyAction('portal_subscriptions', **action) ########################################## # actions ########################################## actions = ( { 'tool' : 'portal_actions', 'id' : 'checkadmission', 'name' : 'Check Admission', 'action' : 'string:${object/absolute_url}/check_admission_form', 'permission': (View, ), 'condition' : 'not:member', 'category' : 'student', 'visible' : 1, }, { 'tool' : 'portal_actions', 'id' : 'new_student', 'name' : 'Add Student', 'action' : 'string:${object/absolute_url}/create_student', 'permission': (View), 'condition' : 'python: member and here.portal_type == "StudentFolder"', 'category' : 'student', 'visible' : 1, }, { 'tool' : 'portal_actions', 'id' : 'edit_student', 'name' : 'Edit Student', 'action' : 'cpsdocument_edit_form', 'permission': ( ), 'condition' : 'python: here.portal_type == "Student"', 'category' : 'student', 'visible' : 1, }, { 'tool' : 'portal_actions', 'id' : 'add_jamb', 'name' : 'Add Jamb Data', 'action' : 'string:${object/absolute_url}/create_jamb', 'permission': (), 'condition' : 'python:here.portal_type != "Jamb" and len(object.contentItems()) == 0', 'category' : 'student', 'visible' : 1, }, { 'tool' : 'portal_actions', 'id' : 'edit_jamb', 'name' : 'Edit Jamb Data', 'action' : 'cpsdocument_edit_form', 'permission': ( ), 'condition' : 'python: here.portal_type == "Jamb"', 'category' : 'student', 'visible' : 1, }, ) self.verifyActions(actions) ########################################## # skins ########################################## self.log("Verifying %(product_name)s skinss" % vars()) wskins = { 'waeup_default' : 'Products/WAeUP/skins/waeup_default', 'waeup_student' : 'Products/WAeUP/skins/waeup_student', } self.verifySkins(wskins) self.resetSkinCache() ########################################## # portal types ########################################## dtypes = portal.getWAeUPTypes() self.verifyFlexibleTypes(dtypes) self.allowContentTypes('StudentFolder', ('Workspace','Section',)) #self.allowContentTypes('Student', ('Workspace', 'Section')) ptypes = { 'StudentFolder' : { 'allowed_content_types': ('Student',), 'typeinfo_name': 'WAeUP: StudentFolder', 'add_meta_type': 'Factory-based Type Information', }, 'Student' : { 'allowed_content_types': ('Jamb',), 'typeinfo_name': 'WAeUP: Student', 'add_meta_type': 'Factory-based Type Information', }, } self.verifyContentTypes(ptypes) ########################################## # Schemas ########################################## self.log("Verifying %(product_name)s schemas" % vars()) self.verifySchemas(portal.getWAeUPSchemas()) ########################################## # widgets ########################################## self.log("Verifying %(product_name)s widgets" % vars()) self.verifyWidgets(portal.getWAeUPWidgets()) ########################################## # layouts ########################################## self.log("Verifying %(product_name)s layouts" % vars()) self.verifyLayouts(portal.getWAeUPLayouts()) ########################################## # Vocabularies ########################################## self.log("Verifying %(product_name)s vocabularies" % vars()) self.verifyVocabularies(portal.getWAeUPVocabularies()) self.installCustomWorkflows() self.verifyWorkflowAssociation() self.log("End of specific %(product_name)s install" % vars()) self.finalize() def installCustomWorkflows(self): """Installs custom workflows """ from Products.WAeUP.Workflows.WAeUPWorkflow import \ waeupWorkflowsInstall waeupWorkflowsInstall(self.context) def verifyWorkflowAssociation(self): """Verify workflow association """ ws_chains = { 'Student': 'waeup_workspace_wf', 'Jamb': 'waeup_workspace_wf', } se_chains = { 'StudentFolder': 'waeup_section_wf', 'Student': 'waeup_section_wf', 'Jamb': 'waeup_section_wf', 'ScratchCard': 'waeup_section_wf', } self.verifyLocalWorkflowChains(self.portal['workspaces'], ws_chains, destructive=1) self.verifyLocalWorkflowChains(self.portal['sections'], se_chains, destructive=1) def install(self): installer = WAeUPInstaller(self) installer.install(self) return installer.logResult()