[60] | 1 | #-*- mode: python; mode: fold -*- |
---|
[72] | 2 | # $Id: install.py 72 2005-10-21 12:41:02Z joachim $ |
---|
[19] | 3 | from Products.CPSInstaller.CPSInstaller import CPSInstaller |
---|
[20] | 4 | from Products.CMFCore.CMFCorePermissions import View, ModifyPortalContent |
---|
[19] | 5 | try: |
---|
[23] | 6 | from Products.CPSSubscriptions.permissions import CanNotifyContent |
---|
[19] | 7 | CPSSubscriptions = True |
---|
| 8 | except ImportError: |
---|
| 9 | CPSSubscriptions = False |
---|
| 10 | try: |
---|
[23] | 11 | from Products.CPSForum.CPSForumPermissions import ForumManageComments |
---|
[19] | 12 | CPSForum = True |
---|
| 13 | except ImportError: |
---|
| 14 | CPSForum = False |
---|
| 15 | |
---|
[60] | 16 | from Products.WAeUP.Students import addStudentsFolder |
---|
| 17 | |
---|
[19] | 18 | class WAeUPInstaller(CPSInstaller): |
---|
| 19 | """ |
---|
| 20 | WAeUP Installer |
---|
| 21 | """ |
---|
| 22 | product_name = "WAeUP" |
---|
| 23 | |
---|
| 24 | def install(self,portal): |
---|
| 25 | "install" |
---|
| 26 | |
---|
| 27 | product_name = self.product_name |
---|
| 28 | self.log("Starting %(product_name)s install" % vars() ) |
---|
| 29 | |
---|
| 30 | ########################################## |
---|
[60] | 31 | # Actions ###( |
---|
[19] | 32 | ########################################## |
---|
| 33 | if CPSSubscriptions: |
---|
| 34 | ptypes = "('Portal', 'CPSMailAccess Message', 'CPSMailAccess Box', 'CPSMailAccess Folder',"\ |
---|
[45] | 35 | + "'University', 'StudentsFolder', 'Student', 'Jamb')" |
---|
[19] | 36 | condition = "object.portal_type not in %s" % ptypes |
---|
| 37 | |
---|
| 38 | action = {'id' : 'notify_content', |
---|
| 39 | 'name' : 'action_notify_content', |
---|
| 40 | 'action' : 'string:${object_url}/content_notify_email_form', |
---|
| 41 | 'condition' : 'python:%s' % condition, |
---|
| 42 | 'permission' : (CanNotifyContent,), |
---|
| 43 | 'category' : 'object', |
---|
| 44 | } |
---|
| 45 | self.deleteActions({'portal_subscriptions': ['notify_content',]}) |
---|
| 46 | self.verifyAction('portal_subscriptions', **action) |
---|
| 47 | if CPSForum: |
---|
[45] | 48 | ptypes = "('University', 'StudentsFolder', 'Student', 'Jamb')" |
---|
[19] | 49 | condition = "object.portal_type not in %s" % ptypes |
---|
| 50 | |
---|
| 51 | action = {'id' : 'activate_comments', |
---|
| 52 | 'name': 'action_activate_comments', |
---|
| 53 | 'action': 'string:${object/absolute_url}/set_comment_mode?mode=1', |
---|
| 54 | 'condition' : 'python:%s' % condition, |
---|
| 55 | 'permission': (ForumManageComments,), |
---|
| 56 | 'category' : 'object', |
---|
| 57 | } |
---|
[57] | 58 | self.deleteActions({'portal_subscriptions': ['activate_comments',]}) |
---|
[19] | 59 | self.verifyAction('portal_subscriptions', **action) |
---|
[57] | 60 | # now portal_discussion |
---|
| 61 | self.deleteActions({'portal_discussion': ['comment', |
---|
| 62 | 'activate_comments', |
---|
| 63 | 'deactivate_comments', |
---|
| 64 | 'manage_comments']}) |
---|
| 65 | action = {'id' : 'comment', |
---|
| 66 | 'name': 'action_comment', |
---|
| 67 | 'action': "string:${object/absolute_url}/post_comment", |
---|
| 68 | 'condition' : "python:getattr(object.getContent(), 'allow_discussion' , None) and object.hasCommentAction()", |
---|
| 69 | 'permission': (View,), |
---|
| 70 | 'category' : 'object', |
---|
| 71 | } |
---|
| 72 | self.verifyAction('portal_discussion', **action) |
---|
| 73 | action = {'id' : 'activate_comments', |
---|
| 74 | 'name': 'action_activate_comments', |
---|
| 75 | 'action': "string:${object/absolute_url}/set_comment_mode?mode=1", |
---|
| 76 | 'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1", |
---|
| 77 | 'permission': (ForumManageComments,), |
---|
| 78 | 'category' : 'object', |
---|
| 79 | } |
---|
| 80 | self.verifyAction('portal_discussion', **action) |
---|
| 81 | action = {'id' : 'deactivate_comments', |
---|
| 82 | 'name': 'action_deactivate_comments', |
---|
| 83 | 'action': "string:${object/absolute_url}/set_comment_mode?mode=0", |
---|
| 84 | 'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1", |
---|
| 85 | 'permission': (ForumManageComments,), |
---|
| 86 | 'category' : 'object', |
---|
| 87 | } |
---|
| 88 | self.verifyAction('portal_discussion', **action) |
---|
| 89 | action = {'id' : 'manage_comments', |
---|
| 90 | 'name': 'action_manage_comments', |
---|
| 91 | 'action': "string:${object/absolute_url}/manage_comment", |
---|
| 92 | 'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1", |
---|
| 93 | 'permission': (ForumManageComments,), |
---|
| 94 | 'category' : 'object', |
---|
| 95 | } |
---|
| 96 | self.verifyAction('portal_discussion', **action) |
---|
[19] | 97 | |
---|
| 98 | ########################################## |
---|
[20] | 99 | # actions |
---|
[19] | 100 | ########################################## |
---|
[20] | 101 | actions = ( { 'tool' : 'portal_actions', |
---|
| 102 | 'id' : 'checkadmission', |
---|
| 103 | 'name' : 'Check Admission', |
---|
[47] | 104 | 'action' : 'string:${object/absolute_url}/check_admission', |
---|
[20] | 105 | 'permission': (View, ), |
---|
[49] | 106 | 'condition' : 'python: not member', |
---|
[23] | 107 | 'category' : 'student', |
---|
[20] | 108 | 'visible' : 1, |
---|
| 109 | }, |
---|
[49] | 110 | ## { 'tool' : 'portal_actions', |
---|
| 111 | ## 'id' : 'new_student', |
---|
| 112 | ## 'name' : 'Add Student', |
---|
| 113 | ## 'action' : 'string:${object/absolute_url}/create_student_form', |
---|
| 114 | ## 'permission': (View), |
---|
| 115 | ## 'condition' : 'python: 0 and member and here.portal_type == "StudentsFolder"', |
---|
| 116 | ## 'category' : 'student', |
---|
| 117 | ## 'visible' : 1, |
---|
| 118 | ## }, |
---|
[20] | 119 | { 'tool' : 'portal_actions', |
---|
| 120 | 'id' : 'edit_student', |
---|
| 121 | 'name' : 'Edit Student', |
---|
| 122 | 'action' : 'cpsdocument_edit_form', |
---|
[26] | 123 | 'permission': ( ), |
---|
[49] | 124 | 'condition' : 'python: 0 and member and here.portal_type == "Student"', |
---|
[20] | 125 | 'category' : 'student', |
---|
| 126 | 'visible' : 1, |
---|
| 127 | }, |
---|
| 128 | { 'tool' : 'portal_actions', |
---|
[28] | 129 | 'id' : 'add_jamb', |
---|
[49] | 130 | 'name' : 'Add Student JAMB', |
---|
| 131 | 'action' : 'string:${object/absolute_url}/create_jamb', |
---|
[28] | 132 | 'permission': (), |
---|
[49] | 133 | 'condition' : 'python: member and here.portal_type in ("StudentsFolder",) and "StudentManager" in member.getGroups()', |
---|
[28] | 134 | 'category' : 'student', |
---|
| 135 | 'visible' : 1, |
---|
| 136 | }, |
---|
| 137 | { 'tool' : 'portal_actions', |
---|
[47] | 138 | 'id' : 'add_personal', |
---|
| 139 | 'name' : 'Add personal Data', |
---|
| 140 | 'action' : 'string:${object/absolute_url}/create_personal_form', |
---|
| 141 | 'permission': (), |
---|
[49] | 142 | 'condition' : 'python: 0 and member and not here.portal_type in ("Jamb","StudentsFolder") and not "StudentManager" in member.getGroups()', |
---|
[47] | 143 | 'category' : 'student', |
---|
| 144 | 'visible' : 1, |
---|
| 145 | }, |
---|
| 146 | { 'tool' : 'portal_actions', |
---|
[28] | 147 | 'id' : 'edit_jamb', |
---|
| 148 | 'name' : 'Edit Jamb Data', |
---|
| 149 | 'action' : 'cpsdocument_edit_form', |
---|
[26] | 150 | 'permission': ( ), |
---|
[49] | 151 | 'condition' : 'python: member and here.portal_type in ("Student",) and "StudentManager" in member.getGroups()', |
---|
[20] | 152 | 'category' : 'student', |
---|
| 153 | 'visible' : 1, |
---|
| 154 | }, |
---|
| 155 | ) |
---|
| 156 | self.verifyActions(actions) |
---|
| 157 | ########################################## |
---|
[60] | 158 | ###) |
---|
| 159 | |
---|
| 160 | # skins |
---|
[20] | 161 | ########################################## |
---|
[19] | 162 | self.log("Verifying %(product_name)s skinss" % vars()) |
---|
| 163 | wskins = { 'waeup_default' : 'Products/WAeUP/skins/waeup_default', |
---|
| 164 | 'waeup_student' : 'Products/WAeUP/skins/waeup_student', |
---|
| 165 | } |
---|
| 166 | self.verifySkins(wskins) |
---|
| 167 | self.resetSkinCache() |
---|
| 168 | ########################################## |
---|
[20] | 169 | # portal types |
---|
[19] | 170 | ########################################## |
---|
| 171 | dtypes = portal.getWAeUPTypes() |
---|
| 172 | self.verifyFlexibleTypes(dtypes) |
---|
[45] | 173 | self.allowContentTypes('University', ('Workspace','Section',)) |
---|
[19] | 174 | ########################################## |
---|
[20] | 175 | # Schemas |
---|
[19] | 176 | ########################################## |
---|
| 177 | self.log("Verifying %(product_name)s schemas" % vars()) |
---|
| 178 | self.verifySchemas(portal.getWAeUPSchemas()) |
---|
| 179 | ########################################## |
---|
[20] | 180 | # widgets |
---|
[19] | 181 | ########################################## |
---|
[20] | 182 | self.log("Verifying %(product_name)s widgets" % vars()) |
---|
| 183 | self.verifyWidgets(portal.getWAeUPWidgets()) |
---|
| 184 | ########################################## |
---|
| 185 | # layouts |
---|
| 186 | ########################################## |
---|
[19] | 187 | self.log("Verifying %(product_name)s layouts" % vars()) |
---|
| 188 | self.verifyLayouts(portal.getWAeUPLayouts()) |
---|
| 189 | ########################################## |
---|
[20] | 190 | # Vocabularies |
---|
[19] | 191 | ########################################## |
---|
| 192 | self.log("Verifying %(product_name)s vocabularies" % vars()) |
---|
| 193 | self.verifyVocabularies(portal.getWAeUPVocabularies()) |
---|
[60] | 194 | ########################################## |
---|
| 195 | # Groups |
---|
| 196 | ########################################## |
---|
| 197 | |
---|
[19] | 198 | self.installCustomWorkflows() |
---|
| 199 | self.verifyWorkflowAssociation() |
---|
| 200 | |
---|
| 201 | self.log("End of specific %(product_name)s install" % vars()) |
---|
| 202 | self.finalize() |
---|
| 203 | |
---|
| 204 | |
---|
| 205 | def installCustomWorkflows(self): |
---|
| 206 | """Installs custom workflows |
---|
| 207 | """ |
---|
| 208 | from Products.WAeUP.Workflows.WAeUPWorkflow import \ |
---|
| 209 | waeupWorkflowsInstall |
---|
| 210 | |
---|
| 211 | waeupWorkflowsInstall(self.context) |
---|
| 212 | |
---|
| 213 | |
---|
| 214 | def verifyWorkflowAssociation(self): |
---|
| 215 | """Verify workflow association |
---|
| 216 | """ |
---|
| 217 | ws_chains = { |
---|
| 218 | 'Student': 'waeup_workspace_wf', |
---|
| 219 | 'Jamb': 'waeup_workspace_wf', |
---|
| 220 | } |
---|
| 221 | |
---|
[45] | 222 | se_chains = { 'University': 'waeup_section_wf', |
---|
| 223 | 'StudentsFolder': 'waeup_section_wf', |
---|
[19] | 224 | 'Student': 'waeup_section_wf', |
---|
[47] | 225 | 'StudentPersonal': 'waeup_section_wf', |
---|
[19] | 226 | 'Jamb': 'waeup_section_wf', |
---|
[25] | 227 | 'ScratchCard': 'waeup_section_wf', |
---|
[68] | 228 | 'Faculty': 'waeup_section_wf', |
---|
| 229 | 'Department': 'waeup_section_wf', |
---|
| 230 | 'Course': 'waeup_section_wf', |
---|
[19] | 231 | } |
---|
| 232 | |
---|
| 233 | self.verifyLocalWorkflowChains(self.portal['workspaces'], |
---|
| 234 | ws_chains, |
---|
| 235 | destructive=1) |
---|
| 236 | self.verifyLocalWorkflowChains(self.portal['sections'], |
---|
| 237 | se_chains, |
---|
| 238 | destructive=1) |
---|
| 239 | |
---|
| 240 | |
---|
| 241 | def install(self): |
---|
| 242 | installer = WAeUPInstaller(self) |
---|
| 243 | installer.install(self) |
---|
[60] | 244 | dirtool = getattr(self,'portal_directories') |
---|
| 245 | groups = dirtool.groups |
---|
| 246 | for newEntry in ('Students','StudentManager'): |
---|
| 247 | if newEntry not in groups.listEntryIds(): |
---|
| 248 | groups.createEntry({'group': newEntry, |
---|
| 249 | 'members': []}) |
---|
| 250 | groups.manage_setLocalGroupRoles(groupid = 'StudentManager',roles=('Manager',)) |
---|
| 251 | #groups.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',)) |
---|
| 252 | sections = getattr(self,'sections') |
---|
| 253 | waeup = getattr(sections,'waeup',None) |
---|
| 254 | if not waeup: |
---|
| 255 | sections.content_create(type_name='University',title='waeup') |
---|
| 256 | sections.waeup.folder_localrole_add(member_ids=('group:Students',), |
---|
| 257 | member_role='SectionReviewer', |
---|
| 258 | ) |
---|
| 259 | sections.waeup.content_create(type_name='StudentsFolder',title='students') |
---|
| 260 | sections.waeup.folder_localrole_add(member_ids=('group:Students',), |
---|
| 261 | member_role='SectionReviewer', |
---|
| 262 | ) |
---|
| 263 | sections.waeup.folder_localrole_add(member_ids=('group:StudentManager',), |
---|
| 264 | member_role='SectionManager', |
---|
| 265 | ) |
---|
| 266 | sections.waeup.students.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',)) |
---|
[72] | 267 | sections.waeup.manage_setLocalGroupRoles(groupid = 'role:Anonymous',roles=('SectionReader',)) |
---|
[19] | 268 | return installer.logResult() |
---|