#-*- mode: python; mode: fold -*- 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 from Products.WAeUP.Students import addStudentsFolder 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',"\ + "'University', 'StudentsFolder', '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 = "('University', 'StudentsFolder', '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_subscriptions': ['activate_comments',]}) self.verifyAction('portal_subscriptions', **action) # now portal_discussion self.deleteActions({'portal_discussion': ['comment', 'activate_comments', 'deactivate_comments', 'manage_comments']}) action = {'id' : 'comment', 'name': 'action_comment', 'action': "string:${object/absolute_url}/post_comment", 'condition' : "python:getattr(object.getContent(), 'allow_discussion' , None) and object.hasCommentAction()", 'permission': (View,), 'category' : 'object', } self.verifyAction('portal_discussion', **action) action = {'id' : 'activate_comments', 'name': 'action_activate_comments', 'action': "string:${object/absolute_url}/set_comment_mode?mode=1", 'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1", 'permission': (ForumManageComments,), 'category' : 'object', } self.verifyAction('portal_discussion', **action) action = {'id' : 'deactivate_comments', 'name': 'action_deactivate_comments', 'action': "string:${object/absolute_url}/set_comment_mode?mode=0", 'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1", 'permission': (ForumManageComments,), 'category' : 'object', } self.verifyAction('portal_discussion', **action) action = {'id' : 'manage_comments', 'name': 'action_manage_comments', 'action': "string:${object/absolute_url}/manage_comment", 'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1", 'permission': (ForumManageComments,), 'category' : 'object', } self.verifyAction('portal_discussion', **action) ########################################## # actions ########################################## actions = ( { 'tool' : 'portal_actions', 'id' : 'checkadmission', 'name' : 'Check Admission', 'action' : 'string:${object/absolute_url}/check_admission', 'permission': (View, ), 'condition' : 'python: not member', 'category' : 'student', 'visible' : 1, }, ## { 'tool' : 'portal_actions', ## 'id' : 'new_student', ## 'name' : 'Add Student', ## 'action' : 'string:${object/absolute_url}/create_student_form', ## 'permission': (View), ## 'condition' : 'python: 0 and member and here.portal_type == "StudentsFolder"', ## 'category' : 'student', ## 'visible' : 1, ## }, { 'tool' : 'portal_actions', 'id' : 'edit_student', 'name' : 'Edit Student', 'action' : 'cpsdocument_edit_form', 'permission': ( ), 'condition' : 'python: 0 and member and here.portal_type == "Student"', 'category' : 'student', 'visible' : 1, }, { 'tool' : 'portal_actions', 'id' : 'add_jamb', 'name' : 'Add Student JAMB', 'action' : 'string:${object/absolute_url}/create_jamb', 'permission': (), 'condition' : 'python: member and here.portal_type in ("StudentsFolder",) and "StudentManager" in member.getGroups()', 'category' : 'student', 'visible' : 1, }, { 'tool' : 'portal_actions', 'id' : 'add_personal', 'name' : 'Add personal Data', 'action' : 'string:${object/absolute_url}/create_personal_form', 'permission': (), 'condition' : 'python: 0 and member and not here.portal_type in ("Jamb","StudentsFolder") and not "StudentManager" in member.getGroups()', 'category' : 'student', 'visible' : 1, }, { 'tool' : 'portal_actions', 'id' : 'edit_jamb', 'name' : 'Edit Jamb Data', 'action' : 'cpsdocument_edit_form', 'permission': ( ), 'condition' : 'python: member and here.portal_type in ("Student",) and "StudentManager" in member.getGroups()', '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('University', ('Workspace','Section',)) ########################################## # 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()) ########################################## # Groups ########################################## 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 = { 'University': 'waeup_section_wf', 'StudentsFolder': 'waeup_section_wf', 'Student': 'waeup_section_wf', 'StudentPersonal': 'waeup_section_wf', 'Jamb': 'waeup_section_wf', 'ScratchCard': 'waeup_section_wf', 'Faculty': 'waeup_section_wf', 'Department': 'waeup_section_wf', 'Course': '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) dirtool = getattr(self,'portal_directories') groups = dirtool.groups for newEntry in ('Students','StudentManager'): if newEntry not in groups.listEntryIds(): groups.createEntry({'group': newEntry, 'members': []}) groups.manage_setLocalGroupRoles(groupid = 'StudentManager',roles=('Manager',)) #groups.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',)) sections = getattr(self,'sections') waeup = getattr(sections,'waeup',None) if not waeup: sections.content_create(type_name='University',title='waeup') sections.waeup.folder_localrole_add(member_ids=('group:Students',), member_role='SectionReviewer', ) sections.waeup.content_create(type_name='StudentsFolder',title='students') sections.waeup.folder_localrole_add(member_ids=('group:Students',), member_role='SectionReviewer', ) sections.waeup.folder_localrole_add(member_ids=('group:StudentManager',), member_role='SectionManager', ) sections.waeup.students.manage_setLocalGroupRoles(groupid = 'role:Anonymous',roles=('SectionReader',)) sections.waeup.students.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',)) return installer.logResult()