[60] | 1 | #-*- mode: python; mode: fold -*- |
---|
[72] | 2 | # $Id: install.py 124 2005-10-29 10:45:10Z henrik $ |
---|
[19] | 3 | from Products.CPSInstaller.CPSInstaller import CPSInstaller |
---|
[20] | 4 | from Products.CMFCore.CMFCorePermissions import View, ModifyPortalContent |
---|
[84] | 5 | from Products.WAeUP.WAeUPPermissions import UniversityManage, StudentManage,FacultyManage,\ |
---|
| 6 | DepartmentManage,CourseManage |
---|
[19] | 7 | try: |
---|
[23] | 8 | from Products.CPSSubscriptions.permissions import CanNotifyContent |
---|
[19] | 9 | CPSSubscriptions = True |
---|
| 10 | except ImportError: |
---|
| 11 | CPSSubscriptions = False |
---|
| 12 | try: |
---|
[23] | 13 | from Products.CPSForum.CPSForumPermissions import ForumManageComments |
---|
[19] | 14 | CPSForum = True |
---|
| 15 | except ImportError: |
---|
| 16 | CPSForum = False |
---|
| 17 | |
---|
[60] | 18 | from Products.WAeUP.Students import addStudentsFolder |
---|
| 19 | |
---|
[19] | 20 | class WAeUPInstaller(CPSInstaller): |
---|
| 21 | """ |
---|
| 22 | WAeUP Installer |
---|
| 23 | """ |
---|
| 24 | product_name = "WAeUP" |
---|
| 25 | |
---|
| 26 | def install(self,portal): |
---|
| 27 | "install" |
---|
| 28 | |
---|
| 29 | product_name = self.product_name |
---|
| 30 | self.log("Starting %(product_name)s install" % vars() ) |
---|
[119] | 31 | |
---|
[87] | 32 | # Roles and Permissions ###( |
---|
[84] | 33 | # |
---|
| 34 | self.verifyRoles(( |
---|
| 35 | # A role that can manage the University. |
---|
| 36 | 'UniversityManager', |
---|
| 37 | # A role that can manage the StudentsRecords. |
---|
| 38 | 'StudentManager', |
---|
| 39 | # A role that can manage a Faculty. |
---|
| 40 | 'FacultyManager', |
---|
| 41 | # A role that can manage a department. |
---|
| 42 | 'DepartmentManager', |
---|
| 43 | # A role that can manage a Course. |
---|
| 44 | 'CourseManager', |
---|
[87] | 45 | # The Student Role |
---|
| 46 | 'Student', |
---|
[84] | 47 | )) |
---|
| 48 | waeup_perms = { |
---|
| 49 | UniversityManage: |
---|
[119] | 50 | ('Manager', 'SectionManager','UniversityManager', |
---|
[84] | 51 | ), |
---|
| 52 | StudentManage: |
---|
[119] | 53 | ('Manager', 'SectionManager','UniversityManager', 'StudentManager' |
---|
[84] | 54 | ), |
---|
| 55 | FacultyManage: |
---|
[119] | 56 | ('Manager', 'SectionManager','UniversityManager', 'FacultyManager' |
---|
[84] | 57 | ), |
---|
| 58 | DepartmentManage: |
---|
[119] | 59 | ('Manager', 'SectionManager','UniversityManager', 'DepartmentManager' |
---|
[84] | 60 | ), |
---|
| 61 | CourseManage: |
---|
[119] | 62 | ('Manager', 'SectionManager','UniversityManager', 'CourseManager' |
---|
[84] | 63 | ), |
---|
| 64 | } |
---|
| 65 | self.setupPortalPermissions(waeup_perms) |
---|
| 66 | |
---|
[87] | 67 | ###) |
---|
| 68 | |
---|
[19] | 69 | ########################################## |
---|
[119] | 70 | # Actions |
---|
[19] | 71 | ########################################## |
---|
[103] | 72 | waeup_ptypes = "'University','StudentsFolder','Student','Jamb','Faculty','Department','Course'" |
---|
[119] | 73 | waeup_ptypes += ",'AccoFolder','Accommodation','StudentPersonal','AcademicsFolder'" |
---|
[84] | 74 | if CPSSubscriptions: ###( |
---|
[119] | 75 | |
---|
[19] | 76 | ptypes = "('Portal', 'CPSMailAccess Message', 'CPSMailAccess Box', 'CPSMailAccess Folder',"\ |
---|
[103] | 77 | + waeup_ptypes + ")" |
---|
[19] | 78 | condition = "object.portal_type not in %s" % ptypes |
---|
[119] | 79 | |
---|
[19] | 80 | action = {'id' : 'notify_content', |
---|
| 81 | 'name' : 'action_notify_content', |
---|
| 82 | 'action' : 'string:${object_url}/content_notify_email_form', |
---|
| 83 | 'condition' : 'python:%s' % condition, |
---|
| 84 | 'permission' : (CanNotifyContent,), |
---|
| 85 | 'category' : 'object', |
---|
| 86 | } |
---|
| 87 | self.deleteActions({'portal_subscriptions': ['notify_content',]}) |
---|
| 88 | self.verifyAction('portal_subscriptions', **action) |
---|
| 89 | if CPSForum: |
---|
[103] | 90 | condition = "object.portal_type not in (%s)" % waeup_ptypes |
---|
[119] | 91 | |
---|
[19] | 92 | action = {'id' : 'activate_comments', |
---|
| 93 | 'name': 'action_activate_comments', |
---|
| 94 | 'action': 'string:${object/absolute_url}/set_comment_mode?mode=1', |
---|
| 95 | 'condition' : 'python:%s' % condition, |
---|
| 96 | 'permission': (ForumManageComments,), |
---|
| 97 | 'category' : 'object', |
---|
| 98 | } |
---|
[57] | 99 | self.deleteActions({'portal_subscriptions': ['activate_comments',]}) |
---|
[19] | 100 | self.verifyAction('portal_subscriptions', **action) |
---|
[57] | 101 | # now portal_discussion |
---|
| 102 | self.deleteActions({'portal_discussion': ['comment', |
---|
| 103 | 'activate_comments', |
---|
| 104 | 'deactivate_comments', |
---|
| 105 | 'manage_comments']}) |
---|
| 106 | action = {'id' : 'comment', |
---|
| 107 | 'name': 'action_comment', |
---|
| 108 | 'action': "string:${object/absolute_url}/post_comment", |
---|
| 109 | 'condition' : "python:getattr(object.getContent(), 'allow_discussion' , None) and object.hasCommentAction()", |
---|
| 110 | 'permission': (View,), |
---|
| 111 | 'category' : 'object', |
---|
| 112 | } |
---|
| 113 | self.verifyAction('portal_discussion', **action) |
---|
| 114 | action = {'id' : 'activate_comments', |
---|
| 115 | 'name': 'action_activate_comments', |
---|
| 116 | 'action': "string:${object/absolute_url}/set_comment_mode?mode=1", |
---|
| 117 | 'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1", |
---|
| 118 | 'permission': (ForumManageComments,), |
---|
| 119 | 'category' : 'object', |
---|
| 120 | } |
---|
| 121 | self.verifyAction('portal_discussion', **action) |
---|
| 122 | action = {'id' : 'deactivate_comments', |
---|
| 123 | 'name': 'action_deactivate_comments', |
---|
| 124 | 'action': "string:${object/absolute_url}/set_comment_mode?mode=0", |
---|
| 125 | 'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1", |
---|
| 126 | 'permission': (ForumManageComments,), |
---|
| 127 | 'category' : 'object', |
---|
| 128 | } |
---|
| 129 | self.verifyAction('portal_discussion', **action) |
---|
| 130 | action = {'id' : 'manage_comments', |
---|
| 131 | 'name': 'action_manage_comments', |
---|
| 132 | 'action': "string:${object/absolute_url}/manage_comment", |
---|
| 133 | 'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1", |
---|
| 134 | 'permission': (ForumManageComments,), |
---|
| 135 | 'category' : 'object', |
---|
| 136 | } |
---|
| 137 | self.verifyAction('portal_discussion', **action) |
---|
[119] | 138 | |
---|
[84] | 139 | ###) |
---|
| 140 | |
---|
[19] | 141 | ########################################## |
---|
[100] | 142 | # main_tab actions ###( |
---|
[19] | 143 | ########################################## |
---|
[20] | 144 | actions = ( { 'tool' : 'portal_actions', |
---|
[100] | 145 | 'id' : 'student_administration', |
---|
[119] | 146 | 'name' : 'Students', |
---|
[124] | 147 | 'action' : 'string:$folder_url/students', |
---|
[20] | 148 | 'permission': (View, ), |
---|
[100] | 149 | 'category' : 'main_tabs', |
---|
[20] | 150 | 'visible' : 1, |
---|
| 151 | }, |
---|
[100] | 152 | { 'tool' : 'portal_actions', |
---|
[113] | 153 | 'id' : 'Academics', |
---|
| 154 | 'name' : 'Academics', |
---|
[124] | 155 | #'action' : 'string:${portal_url}/sections/waeup/academics/academics_view', |
---|
| 156 | 'action' : 'string:$folder_url/academics', |
---|
[100] | 157 | 'permission': (View ), |
---|
| 158 | 'category' : 'main_tabs', |
---|
| 159 | 'visible' : 1, |
---|
| 160 | }, |
---|
[103] | 161 | { 'tool' : 'portal_actions', |
---|
| 162 | 'id' : 'accomodation', |
---|
| 163 | 'name' : 'Accommodation', |
---|
[124] | 164 | #'action' : 'string:${portal_url}/sections/waeup/accommodation/accommodation_index_html', |
---|
| 165 | 'action' : 'string:$folder_url/accommodation', |
---|
[115] | 166 | 'permissions': (View), |
---|
| 167 | #'permissions': (ModifyPortalContent,UniversityManage,StudentManage), |
---|
[103] | 168 | 'category' : 'main_tabs', |
---|
| 169 | 'visible' : 1, |
---|
| 170 | }, |
---|
[49] | 171 | ## { 'tool' : 'portal_actions', |
---|
[100] | 172 | ## 'id' : 'add_jamb', |
---|
| 173 | ## 'name' : 'Add Student JAMB', |
---|
| 174 | ## 'action' : 'string:${object/absolute_url}/create_jamb', |
---|
| 175 | ## 'permission': (), |
---|
| 176 | ## 'condition' : 'python: member and here.portal_type in ("StudentsFolder",) and "StudentManager" in member.getGroups()', |
---|
[49] | 177 | ## 'category' : 'student', |
---|
| 178 | ## 'visible' : 1, |
---|
| 179 | ## }, |
---|
[100] | 180 | ## { 'tool' : 'portal_actions', |
---|
| 181 | ## 'id' : 'add_faculty', |
---|
| 182 | ## 'name' : 'Add New Faculty', |
---|
| 183 | ## 'action' : 'string:${object/absolute_url}/addFaculty', |
---|
| 184 | ## 'permission': (), |
---|
| 185 | ## 'condition' : 'python: member and here.portal_type in ("University",) and "StudentManager" in member.getGroups()', |
---|
| 186 | ## 'category' : 'student', |
---|
| 187 | ## 'visible' : 1, |
---|
| 188 | ## }, |
---|
| 189 | ## { 'tool' : 'portal_actions', |
---|
| 190 | ## 'id' : 'add_department', |
---|
| 191 | ## 'name' : 'Add New Department', |
---|
| 192 | ## 'action' : 'string:${object/absolute_url}/addDepartment', |
---|
| 193 | ## 'permission': (), |
---|
| 194 | ## 'condition' : 'python: member and here.portal_type in ("Faculty",) and "StudentManager" in member.getGroups()', |
---|
| 195 | ## 'category' : 'student', |
---|
| 196 | ## 'visible' : 1, |
---|
| 197 | ## }, |
---|
| 198 | ## { 'tool' : 'portal_actions', |
---|
| 199 | ## 'id' : 'add_course', |
---|
| 200 | ## 'name' : 'Add New Course', |
---|
| 201 | ## 'action' : 'string:${object/absolute_url}/addCourse', |
---|
| 202 | ## 'permission': (), |
---|
| 203 | ## 'condition' : 'python: member and here.portal_type in ("Department",) and "StudentManager" in member.getGroups()', |
---|
| 204 | ## 'category' : 'student', |
---|
| 205 | ## 'visible' : 1, |
---|
| 206 | ## }, |
---|
| 207 | ## { 'tool' : 'portal_actions', |
---|
| 208 | ## 'id' : 'add_personal', |
---|
| 209 | ## 'name' : 'Add personal Data', |
---|
| 210 | ## 'action' : 'string:${object/absolute_url}/create_personal_form', |
---|
| 211 | ## 'permission': (), |
---|
| 212 | ## 'condition' : 'python: 0 and member and not here.portal_type in ("Jamb","StudentsFolder") and not "StudentManager" in member.getGroups()', |
---|
| 213 | ## 'category' : 'student', |
---|
| 214 | ## 'visible' : 1, |
---|
| 215 | ## }, |
---|
| 216 | ## { 'tool' : 'portal_actions', |
---|
| 217 | ## 'id' : 'edit_jamb', |
---|
| 218 | ## 'name' : 'Edit Jamb Data', |
---|
| 219 | ## 'action' : 'cpsdocument_edit_form', |
---|
| 220 | ## 'permission': ( ), |
---|
| 221 | ## 'condition' : 'python: member and here.portal_type in ("Student",) and "StudentManager" in member.getGroups()', |
---|
| 222 | ## 'category' : 'student', |
---|
| 223 | ## 'visible' : 1, |
---|
| 224 | ## }, |
---|
[20] | 225 | ) |
---|
| 226 | self.verifyActions(actions) |
---|
| 227 | ########################################## |
---|
[60] | 228 | ###) |
---|
| 229 | |
---|
[119] | 230 | # skins |
---|
[20] | 231 | ########################################## |
---|
[19] | 232 | self.log("Verifying %(product_name)s skinss" % vars()) |
---|
| 233 | wskins = { 'waeup_default' : 'Products/WAeUP/skins/waeup_default', |
---|
[84] | 234 | 'waeup_faculty' : 'Products/WAeUP/skins/waeup_faculty', |
---|
[19] | 235 | 'waeup_student' : 'Products/WAeUP/skins/waeup_student', |
---|
| 236 | } |
---|
| 237 | self.verifySkins(wskins) |
---|
| 238 | self.resetSkinCache() |
---|
[119] | 239 | |
---|
[19] | 240 | ########################################## |
---|
[20] | 241 | # portal types |
---|
[19] | 242 | ########################################## |
---|
| 243 | dtypes = portal.getWAeUPTypes() |
---|
| 244 | self.verifyFlexibleTypes(dtypes) |
---|
[45] | 245 | self.allowContentTypes('University', ('Workspace','Section',)) |
---|
[19] | 246 | ########################################## |
---|
[20] | 247 | # Schemas |
---|
[19] | 248 | ########################################## |
---|
| 249 | self.log("Verifying %(product_name)s schemas" % vars()) |
---|
| 250 | self.verifySchemas(portal.getWAeUPSchemas()) |
---|
| 251 | ########################################## |
---|
[20] | 252 | # widgets |
---|
[19] | 253 | ########################################## |
---|
[20] | 254 | self.log("Verifying %(product_name)s widgets" % vars()) |
---|
| 255 | self.verifyWidgets(portal.getWAeUPWidgets()) |
---|
| 256 | ########################################## |
---|
| 257 | # layouts |
---|
| 258 | ########################################## |
---|
[19] | 259 | self.log("Verifying %(product_name)s layouts" % vars()) |
---|
| 260 | self.verifyLayouts(portal.getWAeUPLayouts()) |
---|
| 261 | ########################################## |
---|
[20] | 262 | # Vocabularies |
---|
[19] | 263 | ########################################## |
---|
| 264 | self.log("Verifying %(product_name)s vocabularies" % vars()) |
---|
| 265 | self.verifyVocabularies(portal.getWAeUPVocabularies()) |
---|
[60] | 266 | ########################################## |
---|
| 267 | # Groups |
---|
| 268 | ########################################## |
---|
[119] | 269 | |
---|
[19] | 270 | self.installCustomWorkflows() |
---|
| 271 | self.verifyWorkflowAssociation() |
---|
[119] | 272 | |
---|
[19] | 273 | self.log("End of specific %(product_name)s install" % vars()) |
---|
| 274 | self.finalize() |
---|
| 275 | |
---|
[119] | 276 | |
---|
[19] | 277 | def installCustomWorkflows(self): |
---|
| 278 | """Installs custom workflows |
---|
| 279 | """ |
---|
| 280 | from Products.WAeUP.Workflows.WAeUPWorkflow import \ |
---|
| 281 | waeupWorkflowsInstall |
---|
| 282 | |
---|
| 283 | waeupWorkflowsInstall(self.context) |
---|
| 284 | |
---|
| 285 | |
---|
| 286 | def verifyWorkflowAssociation(self): |
---|
| 287 | """Verify workflow association |
---|
| 288 | """ |
---|
[119] | 289 | ws_chains = { |
---|
[19] | 290 | 'Student': 'waeup_workspace_wf', |
---|
| 291 | 'Jamb': 'waeup_workspace_wf', |
---|
| 292 | } |
---|
| 293 | |
---|
[45] | 294 | se_chains = { 'University': 'waeup_section_wf', |
---|
[113] | 295 | 'AcademicsFolder': 'waeup_section_wf', |
---|
[45] | 296 | 'StudentsFolder': 'waeup_section_wf', |
---|
[19] | 297 | 'Student': 'waeup_section_wf', |
---|
[47] | 298 | 'StudentPersonal': 'waeup_section_wf', |
---|
[19] | 299 | 'Jamb': 'waeup_section_wf', |
---|
[25] | 300 | 'ScratchCard': 'waeup_section_wf', |
---|
[68] | 301 | 'Faculty': 'waeup_section_wf', |
---|
| 302 | 'Department': 'waeup_section_wf', |
---|
| 303 | 'Course': 'waeup_section_wf', |
---|
[103] | 304 | 'AccoFolder': 'waeup_section_wf', |
---|
| 305 | 'Accommodation': 'waeup_section_wf', |
---|
[19] | 306 | } |
---|
| 307 | |
---|
| 308 | self.verifyLocalWorkflowChains(self.portal['workspaces'], |
---|
| 309 | ws_chains, |
---|
| 310 | destructive=1) |
---|
| 311 | self.verifyLocalWorkflowChains(self.portal['sections'], |
---|
| 312 | se_chains, |
---|
| 313 | destructive=1) |
---|
| 314 | |
---|
| 315 | |
---|
| 316 | def install(self): |
---|
| 317 | installer = WAeUPInstaller(self) |
---|
| 318 | installer.install(self) |
---|
[60] | 319 | dirtool = getattr(self,'portal_directories') |
---|
| 320 | groups = dirtool.groups |
---|
[96] | 321 | for delEntry in ('StudentManager',): |
---|
| 322 | if delEntry in groups.listEntryIds(): |
---|
[119] | 323 | groups.deleteEntry(delEntry) |
---|
[96] | 324 | for newEntry in ('Students',): |
---|
[60] | 325 | if newEntry not in groups.listEntryIds(): |
---|
[119] | 326 | groups.createEntry({'group': newEntry, |
---|
| 327 | 'members': []}) |
---|
[96] | 328 | #groups.manage_setLocalGroupRoles(groupid = 'StudentManager',roles=('Manager',)) |
---|
[60] | 329 | #groups.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',)) |
---|
| 330 | sections = getattr(self,'sections') |
---|
| 331 | waeup = getattr(sections,'waeup',None) |
---|
| 332 | if not waeup: |
---|
| 333 | sections.content_create(type_name='University',title='waeup') |
---|
| 334 | sections.waeup.folder_localrole_add(member_ids=('group:Students',), |
---|
| 335 | member_role='SectionReviewer', |
---|
| 336 | ) |
---|
| 337 | sections.waeup.content_create(type_name='StudentsFolder',title='students') |
---|
| 338 | sections.waeup.folder_localrole_add(member_ids=('group:Students',), |
---|
| 339 | member_role='SectionReviewer', |
---|
| 340 | ) |
---|
[113] | 341 | sections.waeup.content_create(type_name='AcademicsFolder',title='academics') |
---|
[87] | 342 | ## sections.waeup.folder_localrole_add(member_ids=('group:StudentManager',), |
---|
| 343 | ## member_role='SectionManager', |
---|
| 344 | ## ) |
---|
[60] | 345 | sections.waeup.students.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',)) |
---|
[113] | 346 | elif not hasattr(waeup,'academics'): |
---|
| 347 | waeup.content_create(type_name='AcademicsFolder',title='academics') |
---|
[72] | 348 | sections.waeup.manage_setLocalGroupRoles(groupid = 'role:Anonymous',roles=('SectionReader',)) |
---|
[87] | 349 | # portlets ###( |
---|
| 350 | # |
---|
| 351 | portlets = ( |
---|
[100] | 352 | ## {'identifier': 'waeup_main_tabs', |
---|
| 353 | ## 'type': 'Custom Portlet', |
---|
| 354 | ## 'slot': 'main_tabs', |
---|
| 355 | ## 'order': 0, |
---|
| 356 | ## 'render_method': 'portlet_main_navigation', |
---|
| 357 | ## 'Title': 'main tabs', |
---|
| 358 | ## }, |
---|
[87] | 359 | {'identifier': 'waeup_breadcrumbs', |
---|
| 360 | 'type': 'Breadcrumbs Portlet', |
---|
| 361 | 'slot': 'waeup_breadcrumbs', |
---|
| 362 | 'first_item': 2, |
---|
| 363 | 'display_site_root': 0, |
---|
| 364 | 'Title': 'waeup_breadcrumbs', |
---|
| 365 | 'display': 'horizontal_trail', |
---|
| 366 | 'display_hidden_folders': 0, |
---|
| 367 | 'order': 0, |
---|
| 368 | }, |
---|
[100] | 369 | {'identifier': 'waeup_main_tab_actions', |
---|
| 370 | 'type': 'Actions Portlet', |
---|
| 371 | 'slot': 'main_tabs', |
---|
| 372 | 'order': 0, |
---|
| 373 | 'categories': ['main_tabs',], |
---|
| 374 | 'Title': 'waep_main_tab_actions', |
---|
| 375 | }, |
---|
[87] | 376 | {'identifier': 'waeup_object_actions', |
---|
| 377 | 'type': 'Actions Portlet', |
---|
| 378 | 'slot': 'waeup_object_actions', |
---|
| 379 | 'order': 0, |
---|
[100] | 380 | 'categories': ['object',], |
---|
[87] | 381 | 'Title': 'waep_manager_actions', |
---|
| 382 | }, |
---|
| 383 | {'identifier': 'waeup_left_top', |
---|
| 384 | 'type': 'Custom Portlet', |
---|
| 385 | 'slot': 'left_top', |
---|
| 386 | 'order': 0, |
---|
| 387 | 'render_method': 'portlet_session_info', |
---|
| 388 | 'Title': 'Session Info', |
---|
| 389 | }, |
---|
| 390 | ) |
---|
[89] | 391 | installer.verifyPortletContainer(waeup) |
---|
| 392 | installer.verifyPortlets(portlets,waeup) |
---|
[87] | 393 | |
---|
| 394 | ###) |
---|
| 395 | |
---|
[19] | 396 | return installer.logResult() |
---|