[60] | 1 | #-*- mode: python; mode: fold -*- |
---|
[72] | 2 | # $Id: install.py 197 2006-02-08 12:47:31Z joachim $ |
---|
[139] | 3 | from Products.ExternalMethod.ExternalMethod import ExternalMethod |
---|
[19] | 4 | from Products.CPSInstaller.CPSInstaller import CPSInstaller |
---|
[139] | 5 | from Products.CMFCore.CMFCorePermissions import View, ModifyPortalContent,AccessContentsInformation |
---|
[84] | 6 | from Products.WAeUP.WAeUPPermissions import UniversityManage, StudentManage,FacultyManage,\ |
---|
| 7 | DepartmentManage,CourseManage |
---|
[19] | 8 | try: |
---|
[23] | 9 | from Products.CPSSubscriptions.permissions import CanNotifyContent |
---|
[19] | 10 | CPSSubscriptions = True |
---|
| 11 | except ImportError: |
---|
| 12 | CPSSubscriptions = False |
---|
| 13 | try: |
---|
[23] | 14 | from Products.CPSForum.CPSForumPermissions import ForumManageComments |
---|
[19] | 15 | CPSForum = True |
---|
| 16 | except ImportError: |
---|
| 17 | CPSForum = False |
---|
| 18 | |
---|
[60] | 19 | from Products.WAeUP.Students import addStudentsFolder |
---|
| 20 | |
---|
[139] | 21 | SRPP_ID = "demouni" |
---|
| 22 | SRPP_TITLE = "Demo University" |
---|
| 23 | |
---|
[19] | 24 | class WAeUPInstaller(CPSInstaller): |
---|
| 25 | """ |
---|
| 26 | WAeUP Installer |
---|
| 27 | """ |
---|
| 28 | product_name = "WAeUP" |
---|
| 29 | |
---|
| 30 | def install(self,portal): |
---|
| 31 | "install" |
---|
[139] | 32 | log = [] |
---|
| 33 | prlog = log.append |
---|
[143] | 34 | |
---|
[139] | 35 | def pr(msg, prlog=prlog): |
---|
| 36 | prlog('%s<br>' % msg) |
---|
[19] | 37 | |
---|
| 38 | product_name = self.product_name |
---|
[139] | 39 | pr("Starting %(product_name)s install" % vars() ) |
---|
[119] | 40 | |
---|
[87] | 41 | # Roles and Permissions ###( |
---|
[84] | 42 | # |
---|
| 43 | self.verifyRoles(( |
---|
| 44 | # A role that can manage the University. |
---|
| 45 | 'UniversityManager', |
---|
| 46 | # A role that can manage the StudentsRecords. |
---|
| 47 | 'StudentManager', |
---|
| 48 | # A role that can manage a Faculty. |
---|
| 49 | 'FacultyManager', |
---|
| 50 | # A role that can manage a department. |
---|
| 51 | 'DepartmentManager', |
---|
| 52 | # A role that can manage a Course. |
---|
| 53 | 'CourseManager', |
---|
[87] | 54 | # The Student Role |
---|
| 55 | 'Student', |
---|
[84] | 56 | )) |
---|
| 57 | waeup_perms = { |
---|
| 58 | UniversityManage: |
---|
[119] | 59 | ('Manager', 'SectionManager','UniversityManager', |
---|
[84] | 60 | ), |
---|
| 61 | StudentManage: |
---|
[119] | 62 | ('Manager', 'SectionManager','UniversityManager', 'StudentManager' |
---|
[84] | 63 | ), |
---|
| 64 | FacultyManage: |
---|
[119] | 65 | ('Manager', 'SectionManager','UniversityManager', 'FacultyManager' |
---|
[84] | 66 | ), |
---|
| 67 | DepartmentManage: |
---|
[119] | 68 | ('Manager', 'SectionManager','UniversityManager', 'DepartmentManager' |
---|
[84] | 69 | ), |
---|
| 70 | CourseManage: |
---|
[119] | 71 | ('Manager', 'SectionManager','UniversityManager', 'CourseManager' |
---|
[84] | 72 | ), |
---|
| 73 | } |
---|
| 74 | self.setupPortalPermissions(waeup_perms) |
---|
[139] | 75 | ###) |
---|
[84] | 76 | |
---|
[139] | 77 | # external methods ###( |
---|
| 78 | # |
---|
| 79 | ext_methods = ( { 'id': 'waeup_migrate', |
---|
| 80 | 'title': 'WAeUP (migrate from an earlier version)', |
---|
| 81 | 'script': 'WAeUP.install', |
---|
| 82 | 'method': 'migrate', |
---|
| 83 | 'protected': 1, |
---|
| 84 | }, |
---|
| 85 | ) |
---|
| 86 | portal_objectIds = portal.objectIds() |
---|
| 87 | for meth in ext_methods: |
---|
| 88 | method = meth['id'] |
---|
| 89 | if method in portal_objectIds: |
---|
| 90 | portal._delObject(method) |
---|
| 91 | pr('Creating %s External Method' % method) |
---|
| 92 | ext_method = ExternalMethod(method, |
---|
| 93 | meth['title'], |
---|
| 94 | meth['script'], |
---|
| 95 | meth['method']) |
---|
| 96 | portal._setObject(method, ext_method) |
---|
| 97 | if method in portal_objectIds: |
---|
| 98 | manage_perms = portal[method].manage_permission |
---|
| 99 | if meth['protected']: |
---|
| 100 | pr("Protecting %s" % method) |
---|
| 101 | manage_perms(View, roles=['Manager'], acquire=0) |
---|
| 102 | manage_perms(AccessContentsInformation, roles=['Manager'], acquire=0) |
---|
| 103 | else: |
---|
| 104 | manage_perms(View, roles=['Manager'], acquire=1) |
---|
| 105 | ###) |
---|
[87] | 106 | |
---|
[19] | 107 | ########################################## |
---|
[119] | 108 | # Actions |
---|
[19] | 109 | ########################################## |
---|
[103] | 110 | waeup_ptypes = "'University','StudentsFolder','Student','Jamb','Faculty','Department','Course'" |
---|
[119] | 111 | waeup_ptypes += ",'AccoFolder','Accommodation','StudentPersonal','AcademicsFolder'" |
---|
[181] | 112 | waeup_ptypes += ",'StudyLevel','Semester','CourseTicket','StudentDocuments','StudentEligibility'" |
---|
[84] | 113 | if CPSSubscriptions: ###( |
---|
[119] | 114 | |
---|
[19] | 115 | ptypes = "('Portal', 'CPSMailAccess Message', 'CPSMailAccess Box', 'CPSMailAccess Folder',"\ |
---|
[103] | 116 | + waeup_ptypes + ")" |
---|
[19] | 117 | condition = "object.portal_type not in %s" % ptypes |
---|
[119] | 118 | |
---|
[19] | 119 | action = {'id' : 'notify_content', |
---|
| 120 | 'name' : 'action_notify_content', |
---|
| 121 | 'action' : 'string:${object_url}/content_notify_email_form', |
---|
| 122 | 'condition' : 'python:%s' % condition, |
---|
| 123 | 'permission' : (CanNotifyContent,), |
---|
| 124 | 'category' : 'object', |
---|
| 125 | } |
---|
| 126 | self.deleteActions({'portal_subscriptions': ['notify_content',]}) |
---|
| 127 | self.verifyAction('portal_subscriptions', **action) |
---|
| 128 | if CPSForum: |
---|
[103] | 129 | condition = "object.portal_type not in (%s)" % waeup_ptypes |
---|
[119] | 130 | |
---|
[19] | 131 | action = {'id' : 'activate_comments', |
---|
| 132 | 'name': 'action_activate_comments', |
---|
| 133 | 'action': 'string:${object/absolute_url}/set_comment_mode?mode=1', |
---|
| 134 | 'condition' : 'python:%s' % condition, |
---|
| 135 | 'permission': (ForumManageComments,), |
---|
| 136 | 'category' : 'object', |
---|
| 137 | } |
---|
[57] | 138 | self.deleteActions({'portal_subscriptions': ['activate_comments',]}) |
---|
[19] | 139 | self.verifyAction('portal_subscriptions', **action) |
---|
[57] | 140 | # now portal_discussion |
---|
| 141 | self.deleteActions({'portal_discussion': ['comment', |
---|
| 142 | 'activate_comments', |
---|
| 143 | 'deactivate_comments', |
---|
| 144 | 'manage_comments']}) |
---|
| 145 | action = {'id' : 'comment', |
---|
| 146 | 'name': 'action_comment', |
---|
| 147 | 'action': "string:${object/absolute_url}/post_comment", |
---|
| 148 | 'condition' : "python:getattr(object.getContent(), 'allow_discussion' , None) and object.hasCommentAction()", |
---|
| 149 | 'permission': (View,), |
---|
| 150 | 'category' : 'object', |
---|
| 151 | } |
---|
| 152 | self.verifyAction('portal_discussion', **action) |
---|
| 153 | action = {'id' : 'activate_comments', |
---|
| 154 | 'name': 'action_activate_comments', |
---|
| 155 | 'action': "string:${object/absolute_url}/set_comment_mode?mode=1", |
---|
| 156 | 'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1", |
---|
| 157 | 'permission': (ForumManageComments,), |
---|
| 158 | 'category' : 'object', |
---|
| 159 | } |
---|
| 160 | self.verifyAction('portal_discussion', **action) |
---|
| 161 | action = {'id' : 'deactivate_comments', |
---|
| 162 | 'name': 'action_deactivate_comments', |
---|
| 163 | 'action': "string:${object/absolute_url}/set_comment_mode?mode=0", |
---|
| 164 | 'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1", |
---|
| 165 | 'permission': (ForumManageComments,), |
---|
| 166 | 'category' : 'object', |
---|
| 167 | } |
---|
| 168 | self.verifyAction('portal_discussion', **action) |
---|
| 169 | action = {'id' : 'manage_comments', |
---|
| 170 | 'name': 'action_manage_comments', |
---|
| 171 | 'action': "string:${object/absolute_url}/manage_comment", |
---|
| 172 | 'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1", |
---|
| 173 | 'permission': (ForumManageComments,), |
---|
| 174 | 'category' : 'object', |
---|
| 175 | } |
---|
| 176 | self.verifyAction('portal_discussion', **action) |
---|
[119] | 177 | |
---|
[84] | 178 | ###) |
---|
| 179 | |
---|
[19] | 180 | ########################################## |
---|
[100] | 181 | # main_tab actions ###( |
---|
[19] | 182 | ########################################## |
---|
[143] | 183 | path = "/sections/%(SRPP_ID)s" % globals() |
---|
[20] | 184 | actions = ( { 'tool' : 'portal_actions', |
---|
[100] | 185 | 'id' : 'student_administration', |
---|
[119] | 186 | 'name' : 'Students', |
---|
[160] | 187 | 'action' : "python: portal.portal_url.getUrlFromRpath('sections/demouni/students')", |
---|
[143] | 188 | #'action' : 'string:$portal_url%(path)s/students' % vars(), |
---|
[20] | 189 | 'permission': (View, ), |
---|
[100] | 190 | 'category' : 'main_tabs', |
---|
[20] | 191 | 'visible' : 1, |
---|
| 192 | }, |
---|
[100] | 193 | { 'tool' : 'portal_actions', |
---|
[170] | 194 | 'id' : 'academics', |
---|
[113] | 195 | 'name' : 'Academics', |
---|
[160] | 196 | 'action' : "python: portal.portal_url.getUrlFromRpath('sections/demouni/academics')", |
---|
| 197 | #'action' : 'string:${portal_url}/academics', |
---|
[169] | 198 | 'permission': (UniversityManage), |
---|
[100] | 199 | 'category' : 'main_tabs', |
---|
| 200 | 'visible' : 1, |
---|
| 201 | }, |
---|
[103] | 202 | { 'tool' : 'portal_actions', |
---|
| 203 | 'id' : 'accomodation', |
---|
| 204 | 'name' : 'Accommodation', |
---|
[160] | 205 | 'action' : "python: portal.portal_url.getUrlFromRpath('sections/demouni/accommodation')", |
---|
| 206 | #'action' : 'string:${portal_url}/accommodation', |
---|
[169] | 207 | 'permissions': (UniversityManage), |
---|
[115] | 208 | #'permissions': (ModifyPortalContent,UniversityManage,StudentManage), |
---|
[103] | 209 | 'category' : 'main_tabs', |
---|
| 210 | 'visible' : 1, |
---|
| 211 | }, |
---|
[195] | 212 | { 'tool' : 'portal_actions', |
---|
| 213 | 'id' : 'chat', |
---|
| 214 | 'name' : 'Chat', |
---|
| 215 | 'action' : "python: portal.portal_url.getUrlFromRpath('sections/demouni/chat')", |
---|
| 216 | #'action' : 'string:${portal_url}/accommodation', |
---|
| 217 | 'permissions': (View), |
---|
| 218 | #'permissions': (ModifyPortalContent,UniversityManage,StudentManage), |
---|
| 219 | 'category' : 'main_tabs', |
---|
| 220 | 'visible' : 1, |
---|
| 221 | }, |
---|
[173] | 222 | ## { 'tool' : 'portal_actions', ###( |
---|
[100] | 223 | ## 'id' : 'add_jamb', |
---|
| 224 | ## 'name' : 'Add Student JAMB', |
---|
| 225 | ## 'action' : 'string:${object/absolute_url}/create_jamb', |
---|
| 226 | ## 'permission': (), |
---|
| 227 | ## 'condition' : 'python: member and here.portal_type in ("StudentsFolder",) and "StudentManager" in member.getGroups()', |
---|
[49] | 228 | ## 'category' : 'student', |
---|
| 229 | ## 'visible' : 1, |
---|
| 230 | ## }, |
---|
[100] | 231 | ## { 'tool' : 'portal_actions', |
---|
| 232 | ## 'id' : 'add_faculty', |
---|
| 233 | ## 'name' : 'Add New Faculty', |
---|
| 234 | ## 'action' : 'string:${object/absolute_url}/addFaculty', |
---|
| 235 | ## 'permission': (), |
---|
| 236 | ## 'condition' : 'python: member and here.portal_type in ("University",) and "StudentManager" in member.getGroups()', |
---|
| 237 | ## 'category' : 'student', |
---|
| 238 | ## 'visible' : 1, |
---|
| 239 | ## }, |
---|
| 240 | ## { 'tool' : 'portal_actions', |
---|
| 241 | ## 'id' : 'add_department', |
---|
| 242 | ## 'name' : 'Add New Department', |
---|
| 243 | ## 'action' : 'string:${object/absolute_url}/addDepartment', |
---|
| 244 | ## 'permission': (), |
---|
| 245 | ## 'condition' : 'python: member and here.portal_type in ("Faculty",) and "StudentManager" in member.getGroups()', |
---|
| 246 | ## 'category' : 'student', |
---|
| 247 | ## 'visible' : 1, |
---|
| 248 | ## }, |
---|
| 249 | ## { 'tool' : 'portal_actions', |
---|
| 250 | ## 'id' : 'add_course', |
---|
| 251 | ## 'name' : 'Add New Course', |
---|
| 252 | ## 'action' : 'string:${object/absolute_url}/addCourse', |
---|
| 253 | ## 'permission': (), |
---|
| 254 | ## 'condition' : 'python: member and here.portal_type in ("Department",) and "StudentManager" in member.getGroups()', |
---|
| 255 | ## 'category' : 'student', |
---|
| 256 | ## 'visible' : 1, |
---|
| 257 | ## }, |
---|
| 258 | ## { 'tool' : 'portal_actions', |
---|
| 259 | ## 'id' : 'add_personal', |
---|
| 260 | ## 'name' : 'Add personal Data', |
---|
| 261 | ## 'action' : 'string:${object/absolute_url}/create_personal_form', |
---|
| 262 | ## 'permission': (), |
---|
| 263 | ## 'condition' : 'python: 0 and member and not here.portal_type in ("Jamb","StudentsFolder") and not "StudentManager" in member.getGroups()', |
---|
| 264 | ## 'category' : 'student', |
---|
| 265 | ## 'visible' : 1, |
---|
| 266 | ## }, |
---|
| 267 | ## { 'tool' : 'portal_actions', |
---|
| 268 | ## 'id' : 'edit_jamb', |
---|
| 269 | ## 'name' : 'Edit Jamb Data', |
---|
| 270 | ## 'action' : 'cpsdocument_edit_form', |
---|
| 271 | ## 'permission': ( ), |
---|
| 272 | ## 'condition' : 'python: member and here.portal_type in ("Student",) and "StudentManager" in member.getGroups()', |
---|
| 273 | ## 'category' : 'student', |
---|
| 274 | ## 'visible' : 1, |
---|
| 275 | ## }, |
---|
[173] | 276 | ###) |
---|
| 277 | |
---|
[20] | 278 | ) |
---|
[173] | 279 | self.deleteActions({'portal_actions': [action['id'] for action in actions]}) |
---|
[20] | 280 | self.verifyActions(actions) |
---|
| 281 | ########################################## |
---|
[60] | 282 | ###) |
---|
| 283 | |
---|
[119] | 284 | # skins |
---|
[20] | 285 | ########################################## |
---|
[139] | 286 | pr("Verifying %(product_name)s skinss" % vars()) |
---|
[19] | 287 | wskins = { 'waeup_default' : 'Products/WAeUP/skins/waeup_default', |
---|
[84] | 288 | 'waeup_faculty' : 'Products/WAeUP/skins/waeup_faculty', |
---|
[19] | 289 | 'waeup_student' : 'Products/WAeUP/skins/waeup_student', |
---|
| 290 | } |
---|
| 291 | self.verifySkins(wskins) |
---|
| 292 | self.resetSkinCache() |
---|
[119] | 293 | |
---|
[139] | 294 | # Themes ###( |
---|
| 295 | # |
---|
| 296 | # Importing portal themes |
---|
| 297 | ## theme_container = getattr(portal, 'portal_themes') |
---|
| 298 | ## # the first theme in each category is the default theme. |
---|
| 299 | ## themes_list = {'WAeUP': ({'id': 'waeup_plain_theme', |
---|
| 300 | ## 'file': 'waeup_plain_theme.zexp', |
---|
| 301 | ## }, |
---|
| 302 | ## {'id': 'waeup_management_theme', |
---|
| 303 | ## 'file': 'waeup_management_theme.zexp', |
---|
| 304 | ## }, |
---|
| 305 | ## ), |
---|
| 306 | ## } |
---|
| 307 | ## |
---|
[143] | 308 | ## |
---|
[139] | 309 | ## theme_ids = theme_container.objectIds() |
---|
| 310 | ## theme_container.manage_delObjects(theme_ids) |
---|
| 311 | ## target_themes = themes_list[Target] |
---|
| 312 | ## for theme in target_themes: |
---|
| 313 | ## pr(" Importing %s theme" % theme['id']) |
---|
| 314 | ## zexppath = os.path.join(zexpdir, theme['file']) |
---|
| 315 | ## try: |
---|
| 316 | ## theme_container._importObjectFromFile(zexppath) |
---|
| 317 | ## except: |
---|
| 318 | ## pr(" Could not import theme %s" % theme['id']) |
---|
| 319 | ## |
---|
| 320 | ## # set the first theme in the list as the default one. |
---|
| 321 | ## theme_container.setDefaultTheme(target_themes[0]['id']) |
---|
| 322 | ###) |
---|
[143] | 323 | |
---|
| 324 | |
---|
[19] | 325 | ########################################## |
---|
[20] | 326 | # portal types |
---|
[19] | 327 | ########################################## |
---|
| 328 | dtypes = portal.getWAeUPTypes() |
---|
| 329 | self.verifyFlexibleTypes(dtypes) |
---|
[45] | 330 | self.allowContentTypes('University', ('Workspace','Section',)) |
---|
[19] | 331 | ########################################## |
---|
[20] | 332 | # Schemas |
---|
[19] | 333 | ########################################## |
---|
[139] | 334 | pr("Verifying %(product_name)s schemas" % vars()) |
---|
[19] | 335 | self.verifySchemas(portal.getWAeUPSchemas()) |
---|
| 336 | ########################################## |
---|
[20] | 337 | # widgets |
---|
[19] | 338 | ########################################## |
---|
[139] | 339 | pr("Verifying %(product_name)s widgets" % vars()) |
---|
[20] | 340 | self.verifyWidgets(portal.getWAeUPWidgets()) |
---|
| 341 | ########################################## |
---|
| 342 | # layouts |
---|
| 343 | ########################################## |
---|
[139] | 344 | pr("Verifying %(product_name)s layouts" % vars()) |
---|
[19] | 345 | self.verifyLayouts(portal.getWAeUPLayouts()) |
---|
| 346 | ########################################## |
---|
[20] | 347 | # Vocabularies |
---|
[19] | 348 | ########################################## |
---|
[139] | 349 | pr("Verifying %(product_name)s vocabularies" % vars()) |
---|
[19] | 350 | self.verifyVocabularies(portal.getWAeUPVocabularies()) |
---|
[60] | 351 | ########################################## |
---|
| 352 | # Groups |
---|
| 353 | ########################################## |
---|
[119] | 354 | |
---|
[19] | 355 | self.installCustomWorkflows() |
---|
| 356 | self.verifyWorkflowAssociation() |
---|
[119] | 357 | |
---|
[139] | 358 | pr("End of specific %(product_name)s install" % vars()) |
---|
| 359 | #return '\n'.join(log) |
---|
[19] | 360 | self.finalize() |
---|
| 361 | |
---|
[152] | 362 | def verifyPortlets(self, portlets=(), object=None): ###( |
---|
| 363 | """Verify the existence of given portet in the object's portlet |
---|
| 364 | container. If not found, a portlet is instantiated. |
---|
| 365 | Existing portlets are not affected. |
---|
| 366 | |
---|
| 367 | 'portlets' is a tuple with the dictionaries given by the export tab |
---|
| 368 | as entries. |
---|
| 369 | The default object is the portal itself. |
---|
| 370 | |
---|
| 371 | return the list a new portlet ids. |
---|
| 372 | """ |
---|
| 373 | |
---|
| 374 | if object is None: |
---|
| 375 | object = self.portal |
---|
| 376 | |
---|
| 377 | self.log('Verifying portlets on %s' % object.absolute_url(relative=1)) |
---|
| 378 | |
---|
| 379 | portlet_container = self.getPortletContainer(object, create=1) |
---|
| 380 | |
---|
| 381 | ttool = self.getTool('portal_types') |
---|
| 382 | |
---|
| 383 | returned = [] |
---|
| 384 | for new_portlet in portlets: |
---|
| 385 | existing_portlets = portlet_container.listPortlets() |
---|
| 386 | updated = 0 |
---|
| 387 | |
---|
| 388 | # Check if the portlet needs an update |
---|
| 389 | identifier = new_portlet.get('identifier') |
---|
| 390 | if identifier: |
---|
| 391 | for portlet in existing_portlets: |
---|
| 392 | if identifier == portlet.identifier: |
---|
| 393 | self.log(" Update of portlet: %s" % portlet) |
---|
| 394 | portlet.edit(**new_portlet) |
---|
| 395 | portlet_id = portlet.getId() |
---|
| 396 | updated = 1 |
---|
| 397 | continue |
---|
| 398 | slot = new_portlet.get('slot') |
---|
| 399 | if slot: |
---|
| 400 | for portlet in existing_portlets: |
---|
| 401 | if slot == portlet.slot: |
---|
| 402 | self.log(" Update of portlet: %s" % portlet) |
---|
| 403 | portlet.edit(**new_portlet) |
---|
| 404 | portlet_id = portlet.getId() |
---|
| 405 | updated = 1 |
---|
| 406 | continue |
---|
| 407 | |
---|
| 408 | if not updated: |
---|
| 409 | self.log(" Creation of portlet: %s" % new_portlet) |
---|
| 410 | portlet_id = self.portal.portal_cpsportlets.createPortlet( |
---|
| 411 | ptype_id=new_portlet['type'], |
---|
| 412 | context=object, |
---|
| 413 | **new_portlet) |
---|
| 414 | if portlet_id not in returned: |
---|
| 415 | returned.append(portlet_id) |
---|
| 416 | return returned |
---|
[173] | 417 | ###) |
---|
[152] | 418 | |
---|
[197] | 419 | |
---|
[152] | 420 | def installCustomWorkflows(self): ###( |
---|
[19] | 421 | """Installs custom workflows |
---|
| 422 | """ |
---|
| 423 | from Products.WAeUP.Workflows.WAeUPWorkflow import \ |
---|
| 424 | waeupWorkflowsInstall |
---|
| 425 | |
---|
| 426 | waeupWorkflowsInstall(self.context) |
---|
| 427 | |
---|
[152] | 428 | ###) |
---|
[19] | 429 | |
---|
[152] | 430 | def verifyWorkflowAssociation(self): ###( |
---|
[19] | 431 | """Verify workflow association |
---|
| 432 | """ |
---|
[119] | 433 | ws_chains = { |
---|
[19] | 434 | 'Student': 'waeup_workspace_wf', |
---|
| 435 | 'Jamb': 'waeup_workspace_wf', |
---|
| 436 | } |
---|
| 437 | |
---|
[45] | 438 | se_chains = { 'University': 'waeup_section_wf', |
---|
[113] | 439 | 'AcademicsFolder': 'waeup_section_wf', |
---|
[152] | 440 | 'StudentsFolder': 'waeup_student_wf', |
---|
| 441 | 'Student': 'waeup_student_wf', |
---|
| 442 | 'StudentPersonal': 'waeup_student_wf', |
---|
[179] | 443 | 'StudentEligibility': 'waeup_student_wf', |
---|
[166] | 444 | 'StudentDocuments': 'waeup_student_wf', |
---|
[19] | 445 | 'Jamb': 'waeup_section_wf', |
---|
[25] | 446 | 'ScratchCard': 'waeup_section_wf', |
---|
[68] | 447 | 'Faculty': 'waeup_section_wf', |
---|
| 448 | 'Department': 'waeup_section_wf', |
---|
| 449 | 'Course': 'waeup_section_wf', |
---|
[152] | 450 | 'StudyLevel': 'waeup_student_wf', |
---|
| 451 | 'Semester': 'waeup_student_wf', |
---|
| 452 | 'CourseTicket': 'waeup_student_wf', |
---|
[103] | 453 | 'AccoFolder': 'waeup_section_wf', |
---|
| 454 | 'Accommodation': 'waeup_section_wf', |
---|
[19] | 455 | } |
---|
| 456 | |
---|
| 457 | self.verifyLocalWorkflowChains(self.portal['workspaces'], |
---|
| 458 | ws_chains, |
---|
| 459 | destructive=1) |
---|
| 460 | self.verifyLocalWorkflowChains(self.portal['sections'], |
---|
| 461 | se_chains, |
---|
| 462 | destructive=1) |
---|
[173] | 463 | ###) |
---|
[19] | 464 | |
---|
[173] | 465 | def verifyFaculties(self, academics): ###( |
---|
| 466 | """install Universityspecific Faculies with Departments""" |
---|
| 467 | faculties = [ |
---|
| 468 | ## {'id': 'agri', ###( |
---|
| 469 | ## 'Title': 'Agriculture', |
---|
| 470 | ## 'departments': [ |
---|
| 471 | ## { 'id': 'dep1', ###( |
---|
| 472 | ## 'Title': 'One', |
---|
| 473 | ## }, |
---|
| 474 | ## ], |
---|
| 475 | ## },###) |
---|
| 476 | { 'id': 'science', |
---|
| 477 | 'Title': 'Science', |
---|
| 478 | 'departments': [ |
---|
| 479 | { 'id': 'bio', ###( |
---|
| 480 | 'Title': 'Biochemistry', |
---|
| 481 | }, |
---|
| 482 | { 'id': 'bot', |
---|
| 483 | 'Title': 'Botany', |
---|
| 484 | }, |
---|
| 485 | { 'id': 'che', |
---|
| 486 | 'Title': 'Chemistry', |
---|
| 487 | }, |
---|
| 488 | { 'id': 'com', |
---|
| 489 | 'Title': 'Computer Science', |
---|
| 490 | }, |
---|
| 491 | { 'id': 'geo', |
---|
| 492 | 'Title': 'Geologie', |
---|
| 493 | }, |
---|
| 494 | { 'id': 'mat', |
---|
| 495 | 'Title': 'Mathematics', |
---|
| 496 | }, |
---|
| 497 | { 'id': 'mic', |
---|
| 498 | 'Title': 'Microbiology', |
---|
| 499 | }, |
---|
| 500 | { 'id': 'opt', |
---|
| 501 | 'Title': 'Optometry', |
---|
| 502 | }, |
---|
| 503 | { 'id': 'phy', |
---|
| 504 | 'Title': 'Physics', |
---|
| 505 | }, |
---|
| 506 | { 'id': 'zoo', |
---|
| 507 | 'Title': 'Zoology', |
---|
| 508 | }, |
---|
| 509 | ], |
---|
| 510 | },###) |
---|
| 511 | ]###) |
---|
| 512 | self.log('Verifying Faculties in %s' % academics.absolute_url(relative=1)) |
---|
| 513 | for faculty in faculties: |
---|
| 514 | fid = faculty['id'] |
---|
| 515 | f = getattr(academics,fid,None) |
---|
| 516 | self.log('Checking Faculty %(id)s = %(Title)s' % faculty) |
---|
| 517 | if f is None: |
---|
| 518 | self.log('Creating Faculty %(id)s = %(Title)s' % faculty) |
---|
| 519 | academics.invokeFactory('Faculty', fid) |
---|
| 520 | f = getattr(academics,fid) |
---|
| 521 | f.getContent().edit(mapping=faculty) |
---|
| 522 | for department in faculty['departments']: |
---|
| 523 | self.log('Checking Department %(id)s = %(Title)s' % department) |
---|
| 524 | did = department['id'] |
---|
| 525 | d = getattr(f,did,None) |
---|
| 526 | if d is None: |
---|
| 527 | self.log('Creating Department %(id)s = %(Title)s' % department) |
---|
| 528 | f.invokeFactory('Department', did) |
---|
| 529 | d = getattr(f,did) |
---|
| 530 | d.getContent().edit(mapping=department) |
---|
| 531 | ###) |
---|
[19] | 532 | |
---|
[152] | 533 | |
---|
[173] | 534 | |
---|
[152] | 535 | def install(self): ###( |
---|
[19] | 536 | installer = WAeUPInstaller(self) |
---|
| 537 | installer.install(self) |
---|
[197] | 538 | #dirtool = getattr(self,'portal_directories') |
---|
| 539 | return installer.logResult() |
---|
[60] | 540 | groups = dirtool.groups |
---|
[96] | 541 | for delEntry in ('StudentManager',): |
---|
| 542 | if delEntry in groups.listEntryIds(): |
---|
[119] | 543 | groups.deleteEntry(delEntry) |
---|
[96] | 544 | for newEntry in ('Students',): |
---|
[60] | 545 | if newEntry not in groups.listEntryIds(): |
---|
[119] | 546 | groups.createEntry({'group': newEntry, |
---|
| 547 | 'members': []}) |
---|
[96] | 548 | #groups.manage_setLocalGroupRoles(groupid = 'StudentManager',roles=('Manager',)) |
---|
[60] | 549 | #groups.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',)) |
---|
| 550 | sections = getattr(self,'sections') |
---|
[139] | 551 | waeup = getattr(sections,SRPP_ID,None) |
---|
[60] | 552 | if not waeup: |
---|
[139] | 553 | sections.invokeFactory('University',SRPP_ID) |
---|
| 554 | waeup = getattr(sections,SRPP_ID) |
---|
| 555 | waeup.getContent().edit(mapping={'Title':SRPP_TITLE}) |
---|
| 556 | waeup.folder_localrole_add(member_ids=('group:Students',), |
---|
[60] | 557 | member_role='SectionReviewer', |
---|
| 558 | ) |
---|
[139] | 559 | waeup.invokeFactory('StudentsFolder','students') |
---|
| 560 | students = getattr(waeup,'students').getContent() |
---|
| 561 | students.edit(mapping={'Title':'Students'}) |
---|
| 562 | waeup.folder_localrole_add(member_ids=('group:Students',), |
---|
[60] | 563 | member_role='SectionReviewer', |
---|
| 564 | ) |
---|
[139] | 565 | ## waeup.content_create(type_name='AcademicsFolder',title='academics') |
---|
[87] | 566 | ## sections.waeup.folder_localrole_add(member_ids=('group:StudentManager',), |
---|
| 567 | ## member_role='SectionManager', |
---|
| 568 | ## ) |
---|
[139] | 569 | waeup.students.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',)) |
---|
| 570 | waeup.invokeFactory('AcademicsFolder','academics', title='Academics') |
---|
| 571 | academics = getattr(waeup,'academics').getContent() |
---|
| 572 | academics.edit(mapping={'Title':'Academics'}) |
---|
| 573 | waeup.invokeFactory('AccoFolder','accommodation', title='Accommodation') |
---|
| 574 | accommodation = getattr(waeup,'accommodation').getContent() |
---|
| 575 | accommodation.edit(mapping={'Title':'Accommodation'}) |
---|
[173] | 576 | academics = getattr(waeup,'academics',None) |
---|
| 577 | if academics is None: |
---|
[139] | 578 | waeup.invokeFactory('AcademicsFolder','academics') |
---|
[173] | 579 | academics = getattr(waeup,'academics') |
---|
| 580 | academics.getContent().edit(mapping={'Title':'Academics'}) |
---|
| 581 | installer.verifyFaculties(academics) |
---|
[139] | 582 | if not hasattr(waeup,'accommodation'): |
---|
| 583 | waeup.invokeFactory('AccoFolder','accommodation') |
---|
| 584 | accommodation = getattr(waeup,'accommodation').getContent() |
---|
| 585 | accommodation.edit(mapping={'Title':'Accommodation'}) |
---|
| 586 | waeup.manage_setLocalGroupRoles(groupid = 'role:Anonymous',roles=('SectionReader',)) |
---|
[87] | 587 | # portlets ###( |
---|
| 588 | # |
---|
| 589 | portlets = ( |
---|
[100] | 590 | ## {'identifier': 'waeup_main_tabs', |
---|
| 591 | ## 'type': 'Custom Portlet', |
---|
| 592 | ## 'slot': 'main_tabs', |
---|
| 593 | ## 'order': 0, |
---|
| 594 | ## 'render_method': 'portlet_main_navigation', |
---|
| 595 | ## 'Title': 'main tabs', |
---|
| 596 | ## }, |
---|
[152] | 597 | {#'identifier': 'waeup_breadcrumbs', |
---|
[87] | 598 | 'type': 'Breadcrumbs Portlet', |
---|
| 599 | 'slot': 'waeup_breadcrumbs', |
---|
[152] | 600 | 'first_item': 0, |
---|
[87] | 601 | 'display_site_root': 0, |
---|
| 602 | 'Title': 'waeup_breadcrumbs', |
---|
| 603 | 'display': 'horizontal_trail', |
---|
| 604 | 'display_hidden_folders': 0, |
---|
| 605 | 'order': 0, |
---|
| 606 | }, |
---|
[152] | 607 | {#'identifier': 'waeup_main_tab_actions', |
---|
[100] | 608 | 'type': 'Actions Portlet', |
---|
| 609 | 'slot': 'main_tabs', |
---|
| 610 | 'order': 0, |
---|
| 611 | 'categories': ['main_tabs',], |
---|
| 612 | 'Title': 'waep_main_tab_actions', |
---|
| 613 | }, |
---|
[152] | 614 | {#'identifier': 'waeup_object_actions', |
---|
[87] | 615 | 'type': 'Actions Portlet', |
---|
| 616 | 'slot': 'waeup_object_actions', |
---|
| 617 | 'order': 0, |
---|
[100] | 618 | 'categories': ['object',], |
---|
[87] | 619 | 'Title': 'waep_manager_actions', |
---|
| 620 | }, |
---|
[152] | 621 | {#'identifier': 'waeup_left_top', |
---|
[87] | 622 | 'type': 'Custom Portlet', |
---|
| 623 | 'slot': 'left_top', |
---|
| 624 | 'order': 0, |
---|
| 625 | 'render_method': 'portlet_session_info', |
---|
| 626 | 'Title': 'Session Info', |
---|
| 627 | }, |
---|
| 628 | ) |
---|
[89] | 629 | installer.verifyPortletContainer(waeup) |
---|
| 630 | installer.verifyPortlets(portlets,waeup) |
---|
[87] | 631 | |
---|
| 632 | ###) |
---|
[19] | 633 | return installer.logResult() |
---|
[152] | 634 | ###) |
---|
[139] | 635 | |
---|
[152] | 636 | def migrate(self): ###( |
---|
[139] | 637 | "update data" |
---|
| 638 | log = [] |
---|
| 639 | prlog = log.append |
---|
| 640 | |
---|
| 641 | def pr(msg, prlog=prlog): |
---|
[140] | 642 | prlog('%s' % msg) |
---|
[139] | 643 | |
---|
| 644 | sections = getattr(self,'sections') |
---|
[140] | 645 | waeup = getattr(sections,SRPP_ID,None) |
---|
[139] | 646 | pr( "Start migrate") |
---|
[162] | 647 | pr("migrating Students") |
---|
| 648 | students = getattr(waeup,'students') |
---|
[139] | 649 | pr("migrating courses") |
---|
[141] | 650 | academics = getattr(waeup,'academics') |
---|
| 651 | for fac in [getattr(academics,f.id) for f in academics.contentValues(filter={'portal_type': ('Faculty',)})]: |
---|
[139] | 652 | pr("Faculty: %s" % fac.title_or_id()) |
---|
| 653 | for dep in [getattr(fac,d.id) for d in fac.contentValues(filter={'portal_type': ('Department',)})]: |
---|
| 654 | pr("Department: %s" % dep.title_or_id()) |
---|
| 655 | for course in [getattr(dep,c.id) for c in dep.contentValues(filter={'portal_type': ('Course',)})]: |
---|
| 656 | pr("Course: %s" % course.title_or_id()) |
---|
| 657 | content = course.getContent() |
---|
| 658 | heading = getattr(content,'heading',course.id) |
---|
| 659 | pr("heading = %(heading)s" % vars()) |
---|
| 660 | content.edit(mapping={'Title': heading}) |
---|
| 661 | pr("migrating halls") |
---|
| 662 | for ac in [getattr(waeup,a.id) for a in waeup.contentValues(filter={'portal_type': ('AccoFolder',)})]: |
---|
| 663 | for hall in [getattr(ac,h.id) for h in ac.contentValues(filter={'portal_type': ('Accommodation',)})]: |
---|
| 664 | pr("Hall: %s" % hall.title_or_id()) |
---|
| 665 | content = hall.getContent() |
---|
| 666 | heading = getattr(content,'heading',hall.id) |
---|
| 667 | pr("heading = %(heading)s" % vars()) |
---|
| 668 | content.edit(mapping={'Title': heading}) |
---|
| 669 | return '\n'.join(log) |
---|
[169] | 670 | |
---|
[152] | 671 | ###) |
---|
| 672 | |
---|