1 | #-*- mode: python; mode: fold -*- |
---|
2 | # $Id: install.py 141 2005-11-02 16:52:46Z joachim $ |
---|
3 | from Products.ExternalMethod.ExternalMethod import ExternalMethod |
---|
4 | from Products.CPSInstaller.CPSInstaller import CPSInstaller |
---|
5 | from Products.CMFCore.CMFCorePermissions import View, ModifyPortalContent,AccessContentsInformation |
---|
6 | from Products.WAeUP.WAeUPPermissions import UniversityManage, StudentManage,FacultyManage,\ |
---|
7 | DepartmentManage,CourseManage |
---|
8 | try: |
---|
9 | from Products.CPSSubscriptions.permissions import CanNotifyContent |
---|
10 | CPSSubscriptions = True |
---|
11 | except ImportError: |
---|
12 | CPSSubscriptions = False |
---|
13 | try: |
---|
14 | from Products.CPSForum.CPSForumPermissions import ForumManageComments |
---|
15 | CPSForum = True |
---|
16 | except ImportError: |
---|
17 | CPSForum = False |
---|
18 | |
---|
19 | from Products.WAeUP.Students import addStudentsFolder |
---|
20 | |
---|
21 | SRPP_ID = "demouni" |
---|
22 | SRPP_TITLE = "Demo University" |
---|
23 | |
---|
24 | class WAeUPInstaller(CPSInstaller): |
---|
25 | """ |
---|
26 | WAeUP Installer |
---|
27 | """ |
---|
28 | product_name = "WAeUP" |
---|
29 | |
---|
30 | def install(self,portal): |
---|
31 | "install" |
---|
32 | log = [] |
---|
33 | prlog = log.append |
---|
34 | |
---|
35 | def pr(msg, prlog=prlog): |
---|
36 | prlog('%s<br>' % msg) |
---|
37 | |
---|
38 | product_name = self.product_name |
---|
39 | pr("Starting %(product_name)s install" % vars() ) |
---|
40 | |
---|
41 | # Roles and Permissions ###( |
---|
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', |
---|
54 | # The Student Role |
---|
55 | 'Student', |
---|
56 | )) |
---|
57 | waeup_perms = { |
---|
58 | UniversityManage: |
---|
59 | ('Manager', 'SectionManager','UniversityManager', |
---|
60 | ), |
---|
61 | StudentManage: |
---|
62 | ('Manager', 'SectionManager','UniversityManager', 'StudentManager' |
---|
63 | ), |
---|
64 | FacultyManage: |
---|
65 | ('Manager', 'SectionManager','UniversityManager', 'FacultyManager' |
---|
66 | ), |
---|
67 | DepartmentManage: |
---|
68 | ('Manager', 'SectionManager','UniversityManager', 'DepartmentManager' |
---|
69 | ), |
---|
70 | CourseManage: |
---|
71 | ('Manager', 'SectionManager','UniversityManager', 'CourseManager' |
---|
72 | ), |
---|
73 | } |
---|
74 | self.setupPortalPermissions(waeup_perms) |
---|
75 | ###) |
---|
76 | |
---|
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 | ###) |
---|
106 | |
---|
107 | ########################################## |
---|
108 | # Actions |
---|
109 | ########################################## |
---|
110 | waeup_ptypes = "'University','StudentsFolder','Student','Jamb','Faculty','Department','Course'" |
---|
111 | waeup_ptypes += ",'AccoFolder','Accommodation','StudentPersonal','AcademicsFolder'" |
---|
112 | if CPSSubscriptions: ###( |
---|
113 | |
---|
114 | ptypes = "('Portal', 'CPSMailAccess Message', 'CPSMailAccess Box', 'CPSMailAccess Folder',"\ |
---|
115 | + waeup_ptypes + ")" |
---|
116 | condition = "object.portal_type not in %s" % ptypes |
---|
117 | |
---|
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: |
---|
128 | condition = "object.portal_type not in (%s)" % waeup_ptypes |
---|
129 | |
---|
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 | } |
---|
137 | self.deleteActions({'portal_subscriptions': ['activate_comments',]}) |
---|
138 | self.verifyAction('portal_subscriptions', **action) |
---|
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) |
---|
176 | |
---|
177 | ###) |
---|
178 | |
---|
179 | ########################################## |
---|
180 | # main_tab actions ###( |
---|
181 | ########################################## |
---|
182 | path = "/sections/%(SRPP_ID)s" % globals() |
---|
183 | actions = ( { 'tool' : 'portal_actions', |
---|
184 | 'id' : 'student_administration', |
---|
185 | 'name' : 'Students', |
---|
186 | #'action' : 'string:$folder_url/students', |
---|
187 | 'action' : 'string:$portal_url%(path)s/students' % vars(), |
---|
188 | 'permission': (View, ), |
---|
189 | 'category' : 'main_tabs', |
---|
190 | 'visible' : 1, |
---|
191 | }, |
---|
192 | { 'tool' : 'portal_actions', |
---|
193 | 'id' : 'Academics', |
---|
194 | 'name' : 'Academics', |
---|
195 | 'action' : 'string:$portal_url%(path)s/academics' % vars(), |
---|
196 | #'action' : 'string:${portal_url}/sections/unidemo', |
---|
197 | #'action' : 'string:$folder_url/academics', |
---|
198 | 'permission': (View ), |
---|
199 | 'category' : 'main_tabs', |
---|
200 | 'visible' : 1, |
---|
201 | }, |
---|
202 | { 'tool' : 'portal_actions', |
---|
203 | 'id' : 'accomodation', |
---|
204 | 'name' : 'Accommodation', |
---|
205 | 'action' : 'string:$portal_url%(path)s/accommodation' % vars(), |
---|
206 | #'action' : 'string:${portal_url}/sections/waeup/accommodation/accommodation_index_html', |
---|
207 | 'permissions': (View), |
---|
208 | #'permissions': (ModifyPortalContent,UniversityManage,StudentManage), |
---|
209 | 'category' : 'main_tabs', |
---|
210 | 'visible' : 1, |
---|
211 | }, |
---|
212 | ## { 'tool' : 'portal_actions', |
---|
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()', |
---|
218 | ## 'category' : 'student', |
---|
219 | ## 'visible' : 1, |
---|
220 | ## }, |
---|
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 | ## }, |
---|
266 | ) |
---|
267 | self.verifyActions(actions) |
---|
268 | ########################################## |
---|
269 | ###) |
---|
270 | |
---|
271 | # skins |
---|
272 | ########################################## |
---|
273 | pr("Verifying %(product_name)s skinss" % vars()) |
---|
274 | wskins = { 'waeup_default' : 'Products/WAeUP/skins/waeup_default', |
---|
275 | 'waeup_faculty' : 'Products/WAeUP/skins/waeup_faculty', |
---|
276 | 'waeup_student' : 'Products/WAeUP/skins/waeup_student', |
---|
277 | } |
---|
278 | self.verifySkins(wskins) |
---|
279 | self.resetSkinCache() |
---|
280 | |
---|
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 | |
---|
312 | ########################################## |
---|
313 | # portal types |
---|
314 | ########################################## |
---|
315 | dtypes = portal.getWAeUPTypes() |
---|
316 | self.verifyFlexibleTypes(dtypes) |
---|
317 | self.allowContentTypes('University', ('Workspace','Section',)) |
---|
318 | ########################################## |
---|
319 | # Schemas |
---|
320 | ########################################## |
---|
321 | pr("Verifying %(product_name)s schemas" % vars()) |
---|
322 | self.verifySchemas(portal.getWAeUPSchemas()) |
---|
323 | ########################################## |
---|
324 | # widgets |
---|
325 | ########################################## |
---|
326 | pr("Verifying %(product_name)s widgets" % vars()) |
---|
327 | self.verifyWidgets(portal.getWAeUPWidgets()) |
---|
328 | ########################################## |
---|
329 | # layouts |
---|
330 | ########################################## |
---|
331 | pr("Verifying %(product_name)s layouts" % vars()) |
---|
332 | self.verifyLayouts(portal.getWAeUPLayouts()) |
---|
333 | ########################################## |
---|
334 | # Vocabularies |
---|
335 | ########################################## |
---|
336 | pr("Verifying %(product_name)s vocabularies" % vars()) |
---|
337 | self.verifyVocabularies(portal.getWAeUPVocabularies()) |
---|
338 | ########################################## |
---|
339 | # Groups |
---|
340 | ########################################## |
---|
341 | |
---|
342 | self.installCustomWorkflows() |
---|
343 | self.verifyWorkflowAssociation() |
---|
344 | |
---|
345 | pr("End of specific %(product_name)s install" % vars()) |
---|
346 | #return '\n'.join(log) |
---|
347 | self.finalize() |
---|
348 | |
---|
349 | |
---|
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 | """ |
---|
362 | ws_chains = { |
---|
363 | 'Student': 'waeup_workspace_wf', |
---|
364 | 'Jamb': 'waeup_workspace_wf', |
---|
365 | } |
---|
366 | |
---|
367 | se_chains = { 'University': 'waeup_section_wf', |
---|
368 | 'AcademicsFolder': 'waeup_section_wf', |
---|
369 | 'StudentsFolder': 'waeup_section_wf', |
---|
370 | 'Student': 'waeup_section_wf', |
---|
371 | 'StudentPersonal': 'waeup_section_wf', |
---|
372 | 'Jamb': 'waeup_section_wf', |
---|
373 | 'ScratchCard': 'waeup_section_wf', |
---|
374 | 'Faculty': 'waeup_section_wf', |
---|
375 | 'Department': 'waeup_section_wf', |
---|
376 | 'Course': 'waeup_section_wf', |
---|
377 | 'AccoFolder': 'waeup_section_wf', |
---|
378 | 'Accommodation': 'waeup_section_wf', |
---|
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) |
---|
392 | dirtool = getattr(self,'portal_directories') |
---|
393 | groups = dirtool.groups |
---|
394 | for delEntry in ('StudentManager',): |
---|
395 | if delEntry in groups.listEntryIds(): |
---|
396 | groups.deleteEntry(delEntry) |
---|
397 | for newEntry in ('Students',): |
---|
398 | if newEntry not in groups.listEntryIds(): |
---|
399 | groups.createEntry({'group': newEntry, |
---|
400 | 'members': []}) |
---|
401 | #groups.manage_setLocalGroupRoles(groupid = 'StudentManager',roles=('Manager',)) |
---|
402 | #groups.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',)) |
---|
403 | sections = getattr(self,'sections') |
---|
404 | waeup = getattr(sections,SRPP_ID,None) |
---|
405 | if not waeup: |
---|
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',), |
---|
410 | member_role='SectionReviewer', |
---|
411 | ) |
---|
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',), |
---|
416 | member_role='SectionReviewer', |
---|
417 | ) |
---|
418 | ## waeup.content_create(type_name='AcademicsFolder',title='academics') |
---|
419 | ## sections.waeup.folder_localrole_add(member_ids=('group:StudentManager',), |
---|
420 | ## member_role='SectionManager', |
---|
421 | ## ) |
---|
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',)) |
---|
438 | # portlets ###( |
---|
439 | # |
---|
440 | portlets = ( |
---|
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 | ## }, |
---|
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 | }, |
---|
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 | }, |
---|
465 | {'identifier': 'waeup_object_actions', |
---|
466 | 'type': 'Actions Portlet', |
---|
467 | 'slot': 'waeup_object_actions', |
---|
468 | 'order': 0, |
---|
469 | 'categories': ['object',], |
---|
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 | ) |
---|
480 | installer.verifyPortletContainer(waeup) |
---|
481 | installer.verifyPortlets(portlets,waeup) |
---|
482 | |
---|
483 | ###) |
---|
484 | |
---|
485 | return installer.logResult() |
---|
486 | |
---|
487 | def migrate(self): |
---|
488 | "update data" |
---|
489 | log = [] |
---|
490 | prlog = log.append |
---|
491 | |
---|
492 | def pr(msg, prlog=prlog): |
---|
493 | prlog('%s' % msg) |
---|
494 | |
---|
495 | sections = getattr(self,'sections') |
---|
496 | waeup = getattr(sections,SRPP_ID,None) |
---|
497 | pr( "Start migrate") |
---|
498 | pr("migrating courses") |
---|
499 | academics = getattr(waeup,'academics') |
---|
500 | for fac in [getattr(academics,f.id) for f in academics.contentValues(filter={'portal_type': ('Faculty',)})]: |
---|
501 | pr("Faculty: %s" % fac.title_or_id()) |
---|
502 | for dep in [getattr(fac,d.id) for d in fac.contentValues(filter={'portal_type': ('Department',)})]: |
---|
503 | pr("Department: %s" % dep.title_or_id()) |
---|
504 | for course in [getattr(dep,c.id) for c in dep.contentValues(filter={'portal_type': ('Course',)})]: |
---|
505 | pr("Course: %s" % course.title_or_id()) |
---|
506 | content = course.getContent() |
---|
507 | heading = getattr(content,'heading',course.id) |
---|
508 | pr("heading = %(heading)s" % vars()) |
---|
509 | content.edit(mapping={'Title': heading}) |
---|
510 | pr("migrating halls") |
---|
511 | for ac in [getattr(waeup,a.id) for a in waeup.contentValues(filter={'portal_type': ('AccoFolder',)})]: |
---|
512 | for hall in [getattr(ac,h.id) for h in ac.contentValues(filter={'portal_type': ('Accommodation',)})]: |
---|
513 | pr("Hall: %s" % hall.title_or_id()) |
---|
514 | content = hall.getContent() |
---|
515 | heading = getattr(content,'heading',hall.id) |
---|
516 | pr("heading = %(heading)s" % vars()) |
---|
517 | content.edit(mapping={'Title': heading}) |
---|
518 | return '\n'.join(log) |
---|
519 | |
---|