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