#-*- mode: python; mode: fold -*- # $Id: install.py 103 2005-10-27 16:06:03Z joachim $ from Products.CPSInstaller.CPSInstaller import CPSInstaller from Products.CMFCore.CMFCorePermissions import View, ModifyPortalContent from Products.WAeUP.WAeUPPermissions import UniversityManage, StudentManage,FacultyManage,\ DepartmentManage,CourseManage 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() ) # Roles and Permissions ###( # self.verifyRoles(( # A role that can manage the University. 'UniversityManager', # A role that can manage the StudentsRecords. 'StudentManager', # A role that can manage a Faculty. 'FacultyManager', # A role that can manage a department. 'DepartmentManager', # A role that can manage a Course. 'CourseManager', # The Student Role 'Student', )) waeup_perms = { UniversityManage: ('Manager', 'SectionManager','UniversityManager', ), StudentManage: ('Manager', 'SectionManager','UniversityManager', 'StudentManager' ), FacultyManage: ('Manager', 'SectionManager','UniversityManager', 'FacultyManager' ), DepartmentManage: ('Manager', 'SectionManager','UniversityManager', 'DepartmentManager' ), CourseManage: ('Manager', 'SectionManager','UniversityManager', 'CourseManager' ), } self.setupPortalPermissions(waeup_perms) ###) ########################################## # Actions ########################################## waeup_ptypes = "'University','StudentsFolder','Student','Jamb','Faculty','Department','Course'" waeup_ptypes += ",'AccoFolder','Accommodation'" if CPSSubscriptions: ###( ptypes = "('Portal', 'CPSMailAccess Message', 'CPSMailAccess Box', 'CPSMailAccess Folder',"\ + waeup_ptypes + ")" 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: condition = "object.portal_type not in (%s)" % waeup_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) ###) ########################################## # main_tab actions ###( ########################################## actions = ( { 'tool' : 'portal_actions', 'id' : 'student_administration', 'name' : 'Student Administration', 'action' : 'string:${portal_url}/sections/waeup/students', 'permission': (View, ), 'category' : 'main_tabs', 'visible' : 1, }, { 'tool' : 'portal_actions', 'id' : 'faculties', 'name' : 'Faculties', 'action' : 'string:${portal_url}/sections/waeup/faculties', 'permission': (View ), 'category' : 'main_tabs', 'visible' : 1, }, { 'tool' : 'portal_actions', 'id' : 'accomodation', 'name' : 'Accommodation', 'action' : 'string:${portal_url}/sections/waeup/Accommodation/accommodation_index_html', 'permissions': (ModifyPortalContent,UniversityManage,StudentManage), 'category' : 'main_tabs', '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_faculty', ## 'name' : 'Add New Faculty', ## 'action' : 'string:${object/absolute_url}/addFaculty', ## 'permission': (), ## 'condition' : 'python: member and here.portal_type in ("University",) and "StudentManager" in member.getGroups()', ## 'category' : 'student', ## 'visible' : 1, ## }, ## { 'tool' : 'portal_actions', ## 'id' : 'add_department', ## 'name' : 'Add New Department', ## 'action' : 'string:${object/absolute_url}/addDepartment', ## 'permission': (), ## 'condition' : 'python: member and here.portal_type in ("Faculty",) and "StudentManager" in member.getGroups()', ## 'category' : 'student', ## 'visible' : 1, ## }, ## { 'tool' : 'portal_actions', ## 'id' : 'add_course', ## 'name' : 'Add New Course', ## 'action' : 'string:${object/absolute_url}/addCourse', ## 'permission': (), ## 'condition' : 'python: member and here.portal_type in ("Department",) 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_faculty' : 'Products/WAeUP/skins/waeup_faculty', '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', 'AccoFolder': 'waeup_section_wf', 'Accommodation': '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 delEntry in ('StudentManager',): if delEntry in groups.listEntryIds(): groups.deleteEntry(delEntry) for newEntry in ('Students',): 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 = 'Students',roles=('Contributor',)) sections.waeup.manage_setLocalGroupRoles(groupid = 'role:Anonymous',roles=('SectionReader',)) # portlets ###( # portlets = ( ## {'identifier': 'waeup_main_tabs', ## 'type': 'Custom Portlet', ## 'slot': 'main_tabs', ## 'order': 0, ## 'render_method': 'portlet_main_navigation', ## 'Title': 'main tabs', ## }, {'identifier': 'waeup_breadcrumbs', 'type': 'Breadcrumbs Portlet', 'slot': 'waeup_breadcrumbs', 'first_item': 2, 'display_site_root': 0, 'Title': 'waeup_breadcrumbs', 'display': 'horizontal_trail', 'display_hidden_folders': 0, 'order': 0, }, {'identifier': 'waeup_main_tab_actions', 'type': 'Actions Portlet', 'slot': 'main_tabs', 'order': 0, 'categories': ['main_tabs',], 'Title': 'waep_main_tab_actions', }, {'identifier': 'waeup_object_actions', 'type': 'Actions Portlet', 'slot': 'waeup_object_actions', 'order': 0, 'categories': ['object',], 'Title': 'waep_manager_actions', }, {'identifier': 'waeup_left_top', 'type': 'Custom Portlet', 'slot': 'left_top', 'order': 0, 'render_method': 'portlet_session_info', 'Title': 'Session Info', }, ) installer.verifyPortletContainer(waeup) installer.verifyPortlets(portlets,waeup) ###) return installer.logResult()