[60] | 1 | #-*- mode: python; mode: fold -*- |
---|
[72] | 2 | # $Id: install.py 140 2005-11-02 14:58:23Z 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 |
---|
| 34 | |
---|
| 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'" |
---|
[84] | 112 | if CPSSubscriptions: ###( |
---|
[119] | 113 | |
---|
[19] | 114 | ptypes = "('Portal', 'CPSMailAccess Message', 'CPSMailAccess Box', 'CPSMailAccess Folder',"\ |
---|
[103] | 115 | + waeup_ptypes + ")" |
---|
[19] | 116 | condition = "object.portal_type not in %s" % ptypes |
---|
[119] | 117 | |
---|
[19] | 118 | action = {'id' : 'notify_content', |
---|
| 119 | 'name' : 'action_notify_content', |
---|
| 120 | 'action' : 'string:${object_url}/content_notify_email_form', |
---|
| 121 | 'condition' : 'python:%s' % condition, |
---|
| 122 | 'permission' : (CanNotifyContent,), |
---|
| 123 | 'category' : 'object', |
---|
| 124 | } |
---|
| 125 | self.deleteActions({'portal_subscriptions': ['notify_content',]}) |
---|
| 126 | self.verifyAction('portal_subscriptions', **action) |
---|
| 127 | if CPSForum: |
---|
[103] | 128 | condition = "object.portal_type not in (%s)" % waeup_ptypes |
---|
[119] | 129 | |
---|
[19] | 130 | action = {'id' : 'activate_comments', |
---|
| 131 | 'name': 'action_activate_comments', |
---|
| 132 | 'action': 'string:${object/absolute_url}/set_comment_mode?mode=1', |
---|
| 133 | 'condition' : 'python:%s' % condition, |
---|
| 134 | 'permission': (ForumManageComments,), |
---|
| 135 | 'category' : 'object', |
---|
| 136 | } |
---|
[57] | 137 | self.deleteActions({'portal_subscriptions': ['activate_comments',]}) |
---|
[19] | 138 | self.verifyAction('portal_subscriptions', **action) |
---|
[57] | 139 | # now portal_discussion |
---|
| 140 | self.deleteActions({'portal_discussion': ['comment', |
---|
| 141 | 'activate_comments', |
---|
| 142 | 'deactivate_comments', |
---|
| 143 | 'manage_comments']}) |
---|
| 144 | action = {'id' : 'comment', |
---|
| 145 | 'name': 'action_comment', |
---|
| 146 | 'action': "string:${object/absolute_url}/post_comment", |
---|
| 147 | 'condition' : "python:getattr(object.getContent(), 'allow_discussion' , None) and object.hasCommentAction()", |
---|
| 148 | 'permission': (View,), |
---|
| 149 | 'category' : 'object', |
---|
| 150 | } |
---|
| 151 | self.verifyAction('portal_discussion', **action) |
---|
| 152 | action = {'id' : 'activate_comments', |
---|
| 153 | 'name': 'action_activate_comments', |
---|
| 154 | 'action': "string:${object/absolute_url}/set_comment_mode?mode=1", |
---|
| 155 | 'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1", |
---|
| 156 | 'permission': (ForumManageComments,), |
---|
| 157 | 'category' : 'object', |
---|
| 158 | } |
---|
| 159 | self.verifyAction('portal_discussion', **action) |
---|
| 160 | action = {'id' : 'deactivate_comments', |
---|
| 161 | 'name': 'action_deactivate_comments', |
---|
| 162 | 'action': "string:${object/absolute_url}/set_comment_mode?mode=0", |
---|
| 163 | 'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1", |
---|
| 164 | 'permission': (ForumManageComments,), |
---|
| 165 | 'category' : 'object', |
---|
| 166 | } |
---|
| 167 | self.verifyAction('portal_discussion', **action) |
---|
| 168 | action = {'id' : 'manage_comments', |
---|
| 169 | 'name': 'action_manage_comments', |
---|
| 170 | 'action': "string:${object/absolute_url}/manage_comment", |
---|
| 171 | 'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1", |
---|
| 172 | 'permission': (ForumManageComments,), |
---|
| 173 | 'category' : 'object', |
---|
| 174 | } |
---|
| 175 | self.verifyAction('portal_discussion', **action) |
---|
[119] | 176 | |
---|
[84] | 177 | ###) |
---|
| 178 | |
---|
[19] | 179 | ########################################## |
---|
[100] | 180 | # main_tab actions ###( |
---|
[19] | 181 | ########################################## |
---|
[139] | 182 | path = "/sections/%(SRPP_ID)s" % globals() |
---|
[20] | 183 | actions = ( { 'tool' : 'portal_actions', |
---|
[100] | 184 | 'id' : 'student_administration', |
---|
[119] | 185 | 'name' : 'Students', |
---|
[139] | 186 | #'action' : 'string:$folder_url/students', |
---|
| 187 | 'action' : 'string:$portal_url%(path)s/students' % vars(), |
---|
[20] | 188 | 'permission': (View, ), |
---|
[100] | 189 | 'category' : 'main_tabs', |
---|
[20] | 190 | 'visible' : 1, |
---|
| 191 | }, |
---|
[100] | 192 | { 'tool' : 'portal_actions', |
---|
[113] | 193 | 'id' : 'Academics', |
---|
| 194 | 'name' : 'Academics', |
---|
[139] | 195 | 'action' : 'string:$portal_url%(path)s/academics' % vars(), |
---|
| 196 | #'action' : 'string:${portal_url}/sections/unidemo', |
---|
| 197 | #'action' : 'string:$folder_url/academics', |
---|
[100] | 198 | 'permission': (View ), |
---|
| 199 | 'category' : 'main_tabs', |
---|
| 200 | 'visible' : 1, |
---|
| 201 | }, |
---|
[103] | 202 | { 'tool' : 'portal_actions', |
---|
| 203 | 'id' : 'accomodation', |
---|
| 204 | 'name' : 'Accommodation', |
---|
[139] | 205 | 'action' : 'string:$portal_url%(path)s/accommodation' % vars(), |
---|
[124] | 206 | #'action' : 'string:${portal_url}/sections/waeup/accommodation/accommodation_index_html', |
---|
[115] | 207 | 'permissions': (View), |
---|
| 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 | ## |
---|
| 295 | ## |
---|
| 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 | ###) |
---|
| 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 | |
---|
[19] | 350 | def installCustomWorkflows(self): |
---|
| 351 | """Installs custom workflows |
---|
| 352 | """ |
---|
| 353 | from Products.WAeUP.Workflows.WAeUPWorkflow import \ |
---|
| 354 | waeupWorkflowsInstall |
---|
| 355 | |
---|
| 356 | waeupWorkflowsInstall(self.context) |
---|
| 357 | |
---|
| 358 | |
---|
| 359 | def verifyWorkflowAssociation(self): |
---|
| 360 | """Verify workflow association |
---|
| 361 | """ |
---|
[119] | 362 | ws_chains = { |
---|
[19] | 363 | 'Student': 'waeup_workspace_wf', |
---|
| 364 | 'Jamb': 'waeup_workspace_wf', |
---|
| 365 | } |
---|
| 366 | |
---|
[45] | 367 | se_chains = { 'University': 'waeup_section_wf', |
---|
[113] | 368 | 'AcademicsFolder': 'waeup_section_wf', |
---|
[45] | 369 | 'StudentsFolder': 'waeup_section_wf', |
---|
[19] | 370 | 'Student': 'waeup_section_wf', |
---|
[47] | 371 | 'StudentPersonal': 'waeup_section_wf', |
---|
[19] | 372 | 'Jamb': 'waeup_section_wf', |
---|
[25] | 373 | 'ScratchCard': 'waeup_section_wf', |
---|
[68] | 374 | 'Faculty': 'waeup_section_wf', |
---|
| 375 | 'Department': 'waeup_section_wf', |
---|
| 376 | 'Course': 'waeup_section_wf', |
---|
[103] | 377 | 'AccoFolder': 'waeup_section_wf', |
---|
| 378 | 'Accommodation': 'waeup_section_wf', |
---|
[19] | 379 | } |
---|
| 380 | |
---|
| 381 | self.verifyLocalWorkflowChains(self.portal['workspaces'], |
---|
| 382 | ws_chains, |
---|
| 383 | destructive=1) |
---|
| 384 | self.verifyLocalWorkflowChains(self.portal['sections'], |
---|
| 385 | se_chains, |
---|
| 386 | destructive=1) |
---|
| 387 | |
---|
| 388 | |
---|
| 389 | def install(self): |
---|
| 390 | installer = WAeUPInstaller(self) |
---|
| 391 | installer.install(self) |
---|
[60] | 392 | dirtool = getattr(self,'portal_directories') |
---|
| 393 | groups = dirtool.groups |
---|
[96] | 394 | for delEntry in ('StudentManager',): |
---|
| 395 | if delEntry in groups.listEntryIds(): |
---|
[119] | 396 | groups.deleteEntry(delEntry) |
---|
[96] | 397 | for newEntry in ('Students',): |
---|
[60] | 398 | if newEntry not in groups.listEntryIds(): |
---|
[119] | 399 | groups.createEntry({'group': newEntry, |
---|
| 400 | 'members': []}) |
---|
[96] | 401 | #groups.manage_setLocalGroupRoles(groupid = 'StudentManager',roles=('Manager',)) |
---|
[60] | 402 | #groups.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',)) |
---|
| 403 | sections = getattr(self,'sections') |
---|
[139] | 404 | waeup = getattr(sections,SRPP_ID,None) |
---|
[60] | 405 | if not waeup: |
---|
[139] | 406 | sections.invokeFactory('University',SRPP_ID) |
---|
| 407 | waeup = getattr(sections,SRPP_ID) |
---|
| 408 | waeup.getContent().edit(mapping={'Title':SRPP_TITLE}) |
---|
| 409 | waeup.folder_localrole_add(member_ids=('group:Students',), |
---|
[60] | 410 | member_role='SectionReviewer', |
---|
| 411 | ) |
---|
[139] | 412 | waeup.invokeFactory('StudentsFolder','students') |
---|
| 413 | students = getattr(waeup,'students').getContent() |
---|
| 414 | students.edit(mapping={'Title':'Students'}) |
---|
| 415 | waeup.folder_localrole_add(member_ids=('group:Students',), |
---|
[60] | 416 | member_role='SectionReviewer', |
---|
| 417 | ) |
---|
[139] | 418 | ## waeup.content_create(type_name='AcademicsFolder',title='academics') |
---|
[87] | 419 | ## sections.waeup.folder_localrole_add(member_ids=('group:StudentManager',), |
---|
| 420 | ## member_role='SectionManager', |
---|
| 421 | ## ) |
---|
[139] | 422 | waeup.students.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',)) |
---|
| 423 | waeup.invokeFactory('AcademicsFolder','academics', title='Academics') |
---|
| 424 | academics = getattr(waeup,'academics').getContent() |
---|
| 425 | academics.edit(mapping={'Title':'Academics'}) |
---|
| 426 | waeup.invokeFactory('AccoFolder','accommodation', title='Accommodation') |
---|
| 427 | accommodation = getattr(waeup,'accommodation').getContent() |
---|
| 428 | accommodation.edit(mapping={'Title':'Accommodation'}) |
---|
| 429 | if not hasattr(waeup,'academics'): |
---|
| 430 | waeup.invokeFactory('AcademicsFolder','academics') |
---|
| 431 | academics = getattr(waeup,'academics').getContent() |
---|
| 432 | academics.edit(mapping={'Title':'Academics'}) |
---|
| 433 | if not hasattr(waeup,'accommodation'): |
---|
| 434 | waeup.invokeFactory('AccoFolder','accommodation') |
---|
| 435 | accommodation = getattr(waeup,'accommodation').getContent() |
---|
| 436 | accommodation.edit(mapping={'Title':'Accommodation'}) |
---|
| 437 | waeup.manage_setLocalGroupRoles(groupid = 'role:Anonymous',roles=('SectionReader',)) |
---|
[87] | 438 | # portlets ###( |
---|
| 439 | # |
---|
| 440 | portlets = ( |
---|
[100] | 441 | ## {'identifier': 'waeup_main_tabs', |
---|
| 442 | ## 'type': 'Custom Portlet', |
---|
| 443 | ## 'slot': 'main_tabs', |
---|
| 444 | ## 'order': 0, |
---|
| 445 | ## 'render_method': 'portlet_main_navigation', |
---|
| 446 | ## 'Title': 'main tabs', |
---|
| 447 | ## }, |
---|
[87] | 448 | {'identifier': 'waeup_breadcrumbs', |
---|
| 449 | 'type': 'Breadcrumbs Portlet', |
---|
| 450 | 'slot': 'waeup_breadcrumbs', |
---|
| 451 | 'first_item': 2, |
---|
| 452 | 'display_site_root': 0, |
---|
| 453 | 'Title': 'waeup_breadcrumbs', |
---|
| 454 | 'display': 'horizontal_trail', |
---|
| 455 | 'display_hidden_folders': 0, |
---|
| 456 | 'order': 0, |
---|
| 457 | }, |
---|
[100] | 458 | {'identifier': 'waeup_main_tab_actions', |
---|
| 459 | 'type': 'Actions Portlet', |
---|
| 460 | 'slot': 'main_tabs', |
---|
| 461 | 'order': 0, |
---|
| 462 | 'categories': ['main_tabs',], |
---|
| 463 | 'Title': 'waep_main_tab_actions', |
---|
| 464 | }, |
---|
[87] | 465 | {'identifier': 'waeup_object_actions', |
---|
| 466 | 'type': 'Actions Portlet', |
---|
| 467 | 'slot': 'waeup_object_actions', |
---|
| 468 | 'order': 0, |
---|
[100] | 469 | 'categories': ['object',], |
---|
[87] | 470 | 'Title': 'waep_manager_actions', |
---|
| 471 | }, |
---|
| 472 | {'identifier': 'waeup_left_top', |
---|
| 473 | 'type': 'Custom Portlet', |
---|
| 474 | 'slot': 'left_top', |
---|
| 475 | 'order': 0, |
---|
| 476 | 'render_method': 'portlet_session_info', |
---|
| 477 | 'Title': 'Session Info', |
---|
| 478 | }, |
---|
| 479 | ) |
---|
[89] | 480 | installer.verifyPortletContainer(waeup) |
---|
| 481 | installer.verifyPortlets(portlets,waeup) |
---|
[87] | 482 | |
---|
| 483 | ###) |
---|
| 484 | |
---|
[19] | 485 | return installer.logResult() |
---|
[139] | 486 | |
---|
| 487 | def migrate(self): |
---|
| 488 | "update data" |
---|
| 489 | log = [] |
---|
| 490 | prlog = log.append |
---|
| 491 | |
---|
| 492 | def pr(msg, prlog=prlog): |
---|
[140] | 493 | prlog('%s' % msg) |
---|
[139] | 494 | |
---|
| 495 | sections = getattr(self,'sections') |
---|
[140] | 496 | waeup = getattr(sections,SRPP_ID,None) |
---|
[139] | 497 | pr( "Start migrate") |
---|
| 498 | pr("migrating courses") |
---|
| 499 | for fac in [getattr(waeup,f.id) for f in waeup.contentValues(filter={'portal_type': ('Faculty',)})]: |
---|
| 500 | pr("Faculty: %s" % fac.title_or_id()) |
---|
| 501 | for dep in [getattr(fac,d.id) for d in fac.contentValues(filter={'portal_type': ('Department',)})]: |
---|
| 502 | pr("Department: %s" % dep.title_or_id()) |
---|
| 503 | for course in [getattr(dep,c.id) for c in dep.contentValues(filter={'portal_type': ('Course',)})]: |
---|
| 504 | pr("Course: %s" % course.title_or_id()) |
---|
| 505 | content = course.getContent() |
---|
| 506 | heading = getattr(content,'heading',course.id) |
---|
| 507 | pr("heading = %(heading)s" % vars()) |
---|
| 508 | content.edit(mapping={'Title': heading}) |
---|
| 509 | pr("migrating halls") |
---|
| 510 | for ac in [getattr(waeup,a.id) for a in waeup.contentValues(filter={'portal_type': ('AccoFolder',)})]: |
---|
| 511 | for hall in [getattr(ac,h.id) for h in ac.contentValues(filter={'portal_type': ('Accommodation',)})]: |
---|
| 512 | pr("Hall: %s" % hall.title_or_id()) |
---|
| 513 | content = hall.getContent() |
---|
| 514 | heading = getattr(content,'heading',hall.id) |
---|
| 515 | pr("heading = %(heading)s" % vars()) |
---|
| 516 | content.edit(mapping={'Title': heading}) |
---|
| 517 | return '\n'.join(log) |
---|
| 518 | |
---|