[60] | 1 | #-*- mode: python; mode: fold -*- |
---|
[72] | 2 | # $Id: install.py 170 2005-11-14 20:58:00Z henrik $ |
---|
[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'" |
---|
[166] | 112 | waeup_ptypes += ",'StudyLevel','Semester','CourseTicket','StudentDocuments'" |
---|
[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 | }, |
---|
[49] | 212 | ## { 'tool' : 'portal_actions', |
---|
[100] | 213 | ## 'id' : 'add_jamb', |
---|
| 214 | ## 'name' : 'Add Student JAMB', |
---|
| 215 | ## 'action' : 'string:${object/absolute_url}/create_jamb', |
---|
| 216 | ## 'permission': (), |
---|
| 217 | ## 'condition' : 'python: member and here.portal_type in ("StudentsFolder",) and "StudentManager" in member.getGroups()', |
---|
[49] | 218 | ## 'category' : 'student', |
---|
| 219 | ## 'visible' : 1, |
---|
| 220 | ## }, |
---|
[100] | 221 | ## { 'tool' : 'portal_actions', |
---|
| 222 | ## 'id' : 'add_faculty', |
---|
| 223 | ## 'name' : 'Add New Faculty', |
---|
| 224 | ## 'action' : 'string:${object/absolute_url}/addFaculty', |
---|
| 225 | ## 'permission': (), |
---|
| 226 | ## 'condition' : 'python: member and here.portal_type in ("University",) and "StudentManager" in member.getGroups()', |
---|
| 227 | ## 'category' : 'student', |
---|
| 228 | ## 'visible' : 1, |
---|
| 229 | ## }, |
---|
| 230 | ## { 'tool' : 'portal_actions', |
---|
| 231 | ## 'id' : 'add_department', |
---|
| 232 | ## 'name' : 'Add New Department', |
---|
| 233 | ## 'action' : 'string:${object/absolute_url}/addDepartment', |
---|
| 234 | ## 'permission': (), |
---|
| 235 | ## 'condition' : 'python: member and here.portal_type in ("Faculty",) and "StudentManager" in member.getGroups()', |
---|
| 236 | ## 'category' : 'student', |
---|
| 237 | ## 'visible' : 1, |
---|
| 238 | ## }, |
---|
| 239 | ## { 'tool' : 'portal_actions', |
---|
| 240 | ## 'id' : 'add_course', |
---|
| 241 | ## 'name' : 'Add New Course', |
---|
| 242 | ## 'action' : 'string:${object/absolute_url}/addCourse', |
---|
| 243 | ## 'permission': (), |
---|
| 244 | ## 'condition' : 'python: member and here.portal_type in ("Department",) and "StudentManager" in member.getGroups()', |
---|
| 245 | ## 'category' : 'student', |
---|
| 246 | ## 'visible' : 1, |
---|
| 247 | ## }, |
---|
| 248 | ## { 'tool' : 'portal_actions', |
---|
| 249 | ## 'id' : 'add_personal', |
---|
| 250 | ## 'name' : 'Add personal Data', |
---|
| 251 | ## 'action' : 'string:${object/absolute_url}/create_personal_form', |
---|
| 252 | ## 'permission': (), |
---|
| 253 | ## 'condition' : 'python: 0 and member and not here.portal_type in ("Jamb","StudentsFolder") and not "StudentManager" in member.getGroups()', |
---|
| 254 | ## 'category' : 'student', |
---|
| 255 | ## 'visible' : 1, |
---|
| 256 | ## }, |
---|
| 257 | ## { 'tool' : 'portal_actions', |
---|
| 258 | ## 'id' : 'edit_jamb', |
---|
| 259 | ## 'name' : 'Edit Jamb Data', |
---|
| 260 | ## 'action' : 'cpsdocument_edit_form', |
---|
| 261 | ## 'permission': ( ), |
---|
| 262 | ## 'condition' : 'python: member and here.portal_type in ("Student",) and "StudentManager" in member.getGroups()', |
---|
| 263 | ## 'category' : 'student', |
---|
| 264 | ## 'visible' : 1, |
---|
| 265 | ## }, |
---|
[20] | 266 | ) |
---|
| 267 | self.verifyActions(actions) |
---|
| 268 | ########################################## |
---|
[60] | 269 | ###) |
---|
| 270 | |
---|
[119] | 271 | # skins |
---|
[20] | 272 | ########################################## |
---|
[139] | 273 | pr("Verifying %(product_name)s skinss" % vars()) |
---|
[19] | 274 | wskins = { 'waeup_default' : 'Products/WAeUP/skins/waeup_default', |
---|
[84] | 275 | 'waeup_faculty' : 'Products/WAeUP/skins/waeup_faculty', |
---|
[19] | 276 | 'waeup_student' : 'Products/WAeUP/skins/waeup_student', |
---|
| 277 | } |
---|
| 278 | self.verifySkins(wskins) |
---|
| 279 | self.resetSkinCache() |
---|
[119] | 280 | |
---|
[139] | 281 | # Themes ###( |
---|
| 282 | # |
---|
| 283 | # Importing portal themes |
---|
| 284 | ## theme_container = getattr(portal, 'portal_themes') |
---|
| 285 | ## # the first theme in each category is the default theme. |
---|
| 286 | ## themes_list = {'WAeUP': ({'id': 'waeup_plain_theme', |
---|
| 287 | ## 'file': 'waeup_plain_theme.zexp', |
---|
| 288 | ## }, |
---|
| 289 | ## {'id': 'waeup_management_theme', |
---|
| 290 | ## 'file': 'waeup_management_theme.zexp', |
---|
| 291 | ## }, |
---|
| 292 | ## ), |
---|
| 293 | ## } |
---|
| 294 | ## |
---|
[143] | 295 | ## |
---|
[139] | 296 | ## theme_ids = theme_container.objectIds() |
---|
| 297 | ## theme_container.manage_delObjects(theme_ids) |
---|
| 298 | ## target_themes = themes_list[Target] |
---|
| 299 | ## for theme in target_themes: |
---|
| 300 | ## pr(" Importing %s theme" % theme['id']) |
---|
| 301 | ## zexppath = os.path.join(zexpdir, theme['file']) |
---|
| 302 | ## try: |
---|
| 303 | ## theme_container._importObjectFromFile(zexppath) |
---|
| 304 | ## except: |
---|
| 305 | ## pr(" Could not import theme %s" % theme['id']) |
---|
| 306 | ## |
---|
| 307 | ## # set the first theme in the list as the default one. |
---|
| 308 | ## theme_container.setDefaultTheme(target_themes[0]['id']) |
---|
| 309 | ###) |
---|
[143] | 310 | |
---|
| 311 | |
---|
[19] | 312 | ########################################## |
---|
[20] | 313 | # portal types |
---|
[19] | 314 | ########################################## |
---|
| 315 | dtypes = portal.getWAeUPTypes() |
---|
| 316 | self.verifyFlexibleTypes(dtypes) |
---|
[45] | 317 | self.allowContentTypes('University', ('Workspace','Section',)) |
---|
[19] | 318 | ########################################## |
---|
[20] | 319 | # Schemas |
---|
[19] | 320 | ########################################## |
---|
[139] | 321 | pr("Verifying %(product_name)s schemas" % vars()) |
---|
[19] | 322 | self.verifySchemas(portal.getWAeUPSchemas()) |
---|
| 323 | ########################################## |
---|
[20] | 324 | # widgets |
---|
[19] | 325 | ########################################## |
---|
[139] | 326 | pr("Verifying %(product_name)s widgets" % vars()) |
---|
[20] | 327 | self.verifyWidgets(portal.getWAeUPWidgets()) |
---|
| 328 | ########################################## |
---|
| 329 | # layouts |
---|
| 330 | ########################################## |
---|
[139] | 331 | pr("Verifying %(product_name)s layouts" % vars()) |
---|
[19] | 332 | self.verifyLayouts(portal.getWAeUPLayouts()) |
---|
| 333 | ########################################## |
---|
[20] | 334 | # Vocabularies |
---|
[19] | 335 | ########################################## |
---|
[139] | 336 | pr("Verifying %(product_name)s vocabularies" % vars()) |
---|
[19] | 337 | self.verifyVocabularies(portal.getWAeUPVocabularies()) |
---|
[60] | 338 | ########################################## |
---|
| 339 | # Groups |
---|
| 340 | ########################################## |
---|
[119] | 341 | |
---|
[19] | 342 | self.installCustomWorkflows() |
---|
| 343 | self.verifyWorkflowAssociation() |
---|
[119] | 344 | |
---|
[139] | 345 | pr("End of specific %(product_name)s install" % vars()) |
---|
| 346 | #return '\n'.join(log) |
---|
[19] | 347 | self.finalize() |
---|
| 348 | |
---|
[119] | 349 | |
---|
[152] | 350 | def verifyPortlets(self, portlets=(), object=None): ###( |
---|
| 351 | """Verify the existence of given portet in the object's portlet |
---|
| 352 | container. If not found, a portlet is instantiated. |
---|
| 353 | Existing portlets are not affected. |
---|
| 354 | |
---|
| 355 | 'portlets' is a tuple with the dictionaries given by the export tab |
---|
| 356 | as entries. |
---|
| 357 | The default object is the portal itself. |
---|
| 358 | |
---|
| 359 | return the list a new portlet ids. |
---|
| 360 | """ |
---|
| 361 | |
---|
| 362 | if object is None: |
---|
| 363 | object = self.portal |
---|
| 364 | |
---|
| 365 | self.log('Verifying portlets on %s' % object.absolute_url(relative=1)) |
---|
| 366 | |
---|
| 367 | portlet_container = self.getPortletContainer(object, create=1) |
---|
| 368 | |
---|
| 369 | ttool = self.getTool('portal_types') |
---|
| 370 | |
---|
| 371 | returned = [] |
---|
| 372 | for new_portlet in portlets: |
---|
| 373 | existing_portlets = portlet_container.listPortlets() |
---|
| 374 | updated = 0 |
---|
| 375 | |
---|
| 376 | # Check if the portlet needs an update |
---|
| 377 | identifier = new_portlet.get('identifier') |
---|
| 378 | if identifier: |
---|
| 379 | for portlet in existing_portlets: |
---|
| 380 | if identifier == portlet.identifier: |
---|
| 381 | self.log(" Update of portlet: %s" % portlet) |
---|
| 382 | portlet.edit(**new_portlet) |
---|
| 383 | portlet_id = portlet.getId() |
---|
| 384 | updated = 1 |
---|
| 385 | continue |
---|
| 386 | slot = new_portlet.get('slot') |
---|
| 387 | if slot: |
---|
| 388 | for portlet in existing_portlets: |
---|
| 389 | if slot == portlet.slot: |
---|
| 390 | self.log(" Update of portlet: %s" % portlet) |
---|
| 391 | portlet.edit(**new_portlet) |
---|
| 392 | portlet_id = portlet.getId() |
---|
| 393 | updated = 1 |
---|
| 394 | continue |
---|
| 395 | |
---|
| 396 | if not updated: |
---|
| 397 | self.log(" Creation of portlet: %s" % new_portlet) |
---|
| 398 | portlet_id = self.portal.portal_cpsportlets.createPortlet( |
---|
| 399 | ptype_id=new_portlet['type'], |
---|
| 400 | context=object, |
---|
| 401 | **new_portlet) |
---|
| 402 | if portlet_id not in returned: |
---|
| 403 | returned.append(portlet_id) |
---|
| 404 | return returned |
---|
| 405 | |
---|
| 406 | ###) |
---|
| 407 | |
---|
| 408 | def installCustomWorkflows(self): ###( |
---|
[19] | 409 | """Installs custom workflows |
---|
| 410 | """ |
---|
| 411 | from Products.WAeUP.Workflows.WAeUPWorkflow import \ |
---|
| 412 | waeupWorkflowsInstall |
---|
| 413 | |
---|
| 414 | waeupWorkflowsInstall(self.context) |
---|
| 415 | |
---|
[152] | 416 | ###) |
---|
[19] | 417 | |
---|
[152] | 418 | def verifyWorkflowAssociation(self): ###( |
---|
[19] | 419 | """Verify workflow association |
---|
| 420 | """ |
---|
[119] | 421 | ws_chains = { |
---|
[19] | 422 | 'Student': 'waeup_workspace_wf', |
---|
| 423 | 'Jamb': 'waeup_workspace_wf', |
---|
| 424 | } |
---|
| 425 | |
---|
[45] | 426 | se_chains = { 'University': 'waeup_section_wf', |
---|
[113] | 427 | 'AcademicsFolder': 'waeup_section_wf', |
---|
[152] | 428 | 'StudentsFolder': 'waeup_student_wf', |
---|
| 429 | 'Student': 'waeup_student_wf', |
---|
| 430 | 'StudentPersonal': 'waeup_student_wf', |
---|
[166] | 431 | 'StudentDocuments': 'waeup_student_wf', |
---|
[19] | 432 | 'Jamb': 'waeup_section_wf', |
---|
[25] | 433 | 'ScratchCard': 'waeup_section_wf', |
---|
[68] | 434 | 'Faculty': 'waeup_section_wf', |
---|
| 435 | 'Department': 'waeup_section_wf', |
---|
| 436 | 'Course': 'waeup_section_wf', |
---|
[152] | 437 | 'StudyLevel': 'waeup_student_wf', |
---|
| 438 | 'Semester': 'waeup_student_wf', |
---|
| 439 | 'CourseTicket': 'waeup_student_wf', |
---|
[103] | 440 | 'AccoFolder': 'waeup_section_wf', |
---|
| 441 | 'Accommodation': 'waeup_section_wf', |
---|
[19] | 442 | } |
---|
| 443 | |
---|
| 444 | self.verifyLocalWorkflowChains(self.portal['workspaces'], |
---|
| 445 | ws_chains, |
---|
| 446 | destructive=1) |
---|
| 447 | self.verifyLocalWorkflowChains(self.portal['sections'], |
---|
| 448 | se_chains, |
---|
| 449 | destructive=1) |
---|
| 450 | |
---|
[152] | 451 | ###) |
---|
[19] | 452 | |
---|
[152] | 453 | |
---|
| 454 | def install(self): ###( |
---|
[19] | 455 | installer = WAeUPInstaller(self) |
---|
| 456 | installer.install(self) |
---|
[60] | 457 | dirtool = getattr(self,'portal_directories') |
---|
| 458 | groups = dirtool.groups |
---|
[96] | 459 | for delEntry in ('StudentManager',): |
---|
| 460 | if delEntry in groups.listEntryIds(): |
---|
[119] | 461 | groups.deleteEntry(delEntry) |
---|
[96] | 462 | for newEntry in ('Students',): |
---|
[60] | 463 | if newEntry not in groups.listEntryIds(): |
---|
[119] | 464 | groups.createEntry({'group': newEntry, |
---|
| 465 | 'members': []}) |
---|
[96] | 466 | #groups.manage_setLocalGroupRoles(groupid = 'StudentManager',roles=('Manager',)) |
---|
[60] | 467 | #groups.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',)) |
---|
| 468 | sections = getattr(self,'sections') |
---|
[139] | 469 | waeup = getattr(sections,SRPP_ID,None) |
---|
[60] | 470 | if not waeup: |
---|
[139] | 471 | sections.invokeFactory('University',SRPP_ID) |
---|
| 472 | waeup = getattr(sections,SRPP_ID) |
---|
| 473 | waeup.getContent().edit(mapping={'Title':SRPP_TITLE}) |
---|
| 474 | waeup.folder_localrole_add(member_ids=('group:Students',), |
---|
[60] | 475 | member_role='SectionReviewer', |
---|
| 476 | ) |
---|
[139] | 477 | waeup.invokeFactory('StudentsFolder','students') |
---|
| 478 | students = getattr(waeup,'students').getContent() |
---|
| 479 | students.edit(mapping={'Title':'Students'}) |
---|
| 480 | waeup.folder_localrole_add(member_ids=('group:Students',), |
---|
[60] | 481 | member_role='SectionReviewer', |
---|
| 482 | ) |
---|
[139] | 483 | ## waeup.content_create(type_name='AcademicsFolder',title='academics') |
---|
[87] | 484 | ## sections.waeup.folder_localrole_add(member_ids=('group:StudentManager',), |
---|
| 485 | ## member_role='SectionManager', |
---|
| 486 | ## ) |
---|
[139] | 487 | waeup.students.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',)) |
---|
| 488 | waeup.invokeFactory('AcademicsFolder','academics', title='Academics') |
---|
| 489 | academics = getattr(waeup,'academics').getContent() |
---|
| 490 | academics.edit(mapping={'Title':'Academics'}) |
---|
| 491 | waeup.invokeFactory('AccoFolder','accommodation', title='Accommodation') |
---|
| 492 | accommodation = getattr(waeup,'accommodation').getContent() |
---|
| 493 | accommodation.edit(mapping={'Title':'Accommodation'}) |
---|
| 494 | if not hasattr(waeup,'academics'): |
---|
| 495 | waeup.invokeFactory('AcademicsFolder','academics') |
---|
| 496 | academics = getattr(waeup,'academics').getContent() |
---|
| 497 | academics.edit(mapping={'Title':'Academics'}) |
---|
| 498 | if not hasattr(waeup,'accommodation'): |
---|
| 499 | waeup.invokeFactory('AccoFolder','accommodation') |
---|
| 500 | accommodation = getattr(waeup,'accommodation').getContent() |
---|
| 501 | accommodation.edit(mapping={'Title':'Accommodation'}) |
---|
| 502 | waeup.manage_setLocalGroupRoles(groupid = 'role:Anonymous',roles=('SectionReader',)) |
---|
[87] | 503 | # portlets ###( |
---|
| 504 | # |
---|
| 505 | portlets = ( |
---|
[100] | 506 | ## {'identifier': 'waeup_main_tabs', |
---|
| 507 | ## 'type': 'Custom Portlet', |
---|
| 508 | ## 'slot': 'main_tabs', |
---|
| 509 | ## 'order': 0, |
---|
| 510 | ## 'render_method': 'portlet_main_navigation', |
---|
| 511 | ## 'Title': 'main tabs', |
---|
| 512 | ## }, |
---|
[152] | 513 | {#'identifier': 'waeup_breadcrumbs', |
---|
[87] | 514 | 'type': 'Breadcrumbs Portlet', |
---|
| 515 | 'slot': 'waeup_breadcrumbs', |
---|
[152] | 516 | 'first_item': 0, |
---|
[87] | 517 | 'display_site_root': 0, |
---|
| 518 | 'Title': 'waeup_breadcrumbs', |
---|
| 519 | 'display': 'horizontal_trail', |
---|
| 520 | 'display_hidden_folders': 0, |
---|
| 521 | 'order': 0, |
---|
| 522 | }, |
---|
[152] | 523 | {#'identifier': 'waeup_main_tab_actions', |
---|
[100] | 524 | 'type': 'Actions Portlet', |
---|
| 525 | 'slot': 'main_tabs', |
---|
| 526 | 'order': 0, |
---|
| 527 | 'categories': ['main_tabs',], |
---|
| 528 | 'Title': 'waep_main_tab_actions', |
---|
| 529 | }, |
---|
[152] | 530 | {#'identifier': 'waeup_object_actions', |
---|
[87] | 531 | 'type': 'Actions Portlet', |
---|
| 532 | 'slot': 'waeup_object_actions', |
---|
| 533 | 'order': 0, |
---|
[100] | 534 | 'categories': ['object',], |
---|
[87] | 535 | 'Title': 'waep_manager_actions', |
---|
| 536 | }, |
---|
[152] | 537 | {#'identifier': 'waeup_left_top', |
---|
[87] | 538 | 'type': 'Custom Portlet', |
---|
| 539 | 'slot': 'left_top', |
---|
| 540 | 'order': 0, |
---|
| 541 | 'render_method': 'portlet_session_info', |
---|
| 542 | 'Title': 'Session Info', |
---|
| 543 | }, |
---|
| 544 | ) |
---|
[89] | 545 | installer.verifyPortletContainer(waeup) |
---|
| 546 | installer.verifyPortlets(portlets,waeup) |
---|
[87] | 547 | |
---|
| 548 | ###) |
---|
[19] | 549 | return installer.logResult() |
---|
[152] | 550 | ###) |
---|
[139] | 551 | |
---|
[152] | 552 | def migrate(self): ###( |
---|
[139] | 553 | "update data" |
---|
| 554 | log = [] |
---|
| 555 | prlog = log.append |
---|
| 556 | |
---|
| 557 | def pr(msg, prlog=prlog): |
---|
[140] | 558 | prlog('%s' % msg) |
---|
[139] | 559 | |
---|
| 560 | sections = getattr(self,'sections') |
---|
[140] | 561 | waeup = getattr(sections,SRPP_ID,None) |
---|
[139] | 562 | pr( "Start migrate") |
---|
[162] | 563 | pr("migrating Students") |
---|
| 564 | students = getattr(waeup,'students') |
---|
[139] | 565 | pr("migrating courses") |
---|
[141] | 566 | academics = getattr(waeup,'academics') |
---|
| 567 | for fac in [getattr(academics,f.id) for f in academics.contentValues(filter={'portal_type': ('Faculty',)})]: |
---|
[139] | 568 | pr("Faculty: %s" % fac.title_or_id()) |
---|
| 569 | for dep in [getattr(fac,d.id) for d in fac.contentValues(filter={'portal_type': ('Department',)})]: |
---|
| 570 | pr("Department: %s" % dep.title_or_id()) |
---|
| 571 | for course in [getattr(dep,c.id) for c in dep.contentValues(filter={'portal_type': ('Course',)})]: |
---|
| 572 | pr("Course: %s" % course.title_or_id()) |
---|
| 573 | content = course.getContent() |
---|
| 574 | heading = getattr(content,'heading',course.id) |
---|
| 575 | pr("heading = %(heading)s" % vars()) |
---|
| 576 | content.edit(mapping={'Title': heading}) |
---|
| 577 | pr("migrating halls") |
---|
| 578 | for ac in [getattr(waeup,a.id) for a in waeup.contentValues(filter={'portal_type': ('AccoFolder',)})]: |
---|
| 579 | for hall in [getattr(ac,h.id) for h in ac.contentValues(filter={'portal_type': ('Accommodation',)})]: |
---|
| 580 | pr("Hall: %s" % hall.title_or_id()) |
---|
| 581 | content = hall.getContent() |
---|
| 582 | heading = getattr(content,'heading',hall.id) |
---|
| 583 | pr("heading = %(heading)s" % vars()) |
---|
| 584 | content.edit(mapping={'Title': heading}) |
---|
| 585 | return '\n'.join(log) |
---|
[169] | 586 | |
---|
[152] | 587 | ###) |
---|
| 588 | |
---|