source: waeup_product/trunk/Extensions/install.py @ 181

Last change on this file since 181 was 181, checked in by Henrik Bettermann, 19 years ago

minor modifications

  • Property svn:keywords set to Id
File size: 29.5 KB
RevLine 
[60]1#-*- mode: python; mode: fold -*-
[72]2# $Id: install.py 181 2005-11-16 20:25:54Z henrik $
[139]3from Products.ExternalMethod.ExternalMethod import ExternalMethod
[19]4from Products.CPSInstaller.CPSInstaller import CPSInstaller
[139]5from Products.CMFCore.CMFCorePermissions import View, ModifyPortalContent,AccessContentsInformation
[84]6from Products.WAeUP.WAeUPPermissions import UniversityManage, StudentManage,FacultyManage,\
7                                            DepartmentManage,CourseManage
[19]8try:
[23]9  from Products.CPSSubscriptions.permissions import CanNotifyContent
[19]10  CPSSubscriptions = True
11except ImportError:
12  CPSSubscriptions = False
13try:
[23]14  from Products.CPSForum.CPSForumPermissions import ForumManageComments
[19]15  CPSForum = True
16except ImportError:
17  CPSForum = False
18
[60]19from Products.WAeUP.Students import addStudentsFolder
20
[139]21SRPP_ID = "demouni"
22SRPP_TITLE = "Demo University"
23
[19]24class 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                      },
[173]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##                      },
[173]266###)
267
[20]268                    )
[173]269        self.deleteActions({'portal_actions': [action['id'] for action in actions]})
[20]270        self.verifyActions(actions)
271        ##########################################
[60]272###)
273
[119]274        # skins
[20]275        ##########################################
[139]276        pr("Verifying %(product_name)s skinss" % vars())
[19]277        wskins = { 'waeup_default' : 'Products/WAeUP/skins/waeup_default',
[84]278                   'waeup_faculty' : 'Products/WAeUP/skins/waeup_faculty',
[19]279                   'waeup_student' : 'Products/WAeUP/skins/waeup_student',
280                 }
281        self.verifySkins(wskins)
282        self.resetSkinCache()
[119]283
[139]284        # Themes ###(
285        #
286        # Importing portal themes
287##        theme_container = getattr(portal, 'portal_themes')
288##            # the first theme in each category is the default theme.
289##        themes_list = {'WAeUP':    ({'id': 'waeup_plain_theme',
290##                                  'file': 'waeup_plain_theme.zexp',
291##                                  },
292##                                  {'id': 'waeup_management_theme',
293##                                   'file': 'waeup_management_theme.zexp',
294##                                  },
295##                                 ),
296##                      }
297##
[143]298##
[139]299##        theme_ids = theme_container.objectIds()
300##        theme_container.manage_delObjects(theme_ids)
301##        target_themes = themes_list[Target]
302##        for theme in target_themes:
303##            pr(" Importing %s theme" % theme['id'])
304##            zexppath = os.path.join(zexpdir, theme['file'])
305##            try:
306##                theme_container._importObjectFromFile(zexppath)
307##            except:
308##                pr("    Could not import theme  %s" % theme['id'])
309##
310##        # set the first theme in the list as the default one.
311##        theme_container.setDefaultTheme(target_themes[0]['id'])
312###)
[143]313
314
[19]315        ##########################################
[20]316        # portal types
[19]317        ##########################################
318        dtypes = portal.getWAeUPTypes()
319        self.verifyFlexibleTypes(dtypes)
[45]320        self.allowContentTypes('University', ('Workspace','Section',))
[19]321        ##########################################
[20]322        # Schemas
[19]323        ##########################################
[139]324        pr("Verifying %(product_name)s schemas" % vars())
[19]325        self.verifySchemas(portal.getWAeUPSchemas())
326        ##########################################
[20]327        # widgets
[19]328        ##########################################
[139]329        pr("Verifying %(product_name)s widgets" % vars())
[20]330        self.verifyWidgets(portal.getWAeUPWidgets())
331        ##########################################
332        # layouts
333        ##########################################
[139]334        pr("Verifying %(product_name)s layouts" % vars())
[19]335        self.verifyLayouts(portal.getWAeUPLayouts())
336        ##########################################
[20]337        # Vocabularies
[19]338        ##########################################
[139]339        pr("Verifying %(product_name)s vocabularies" % vars())
[19]340        self.verifyVocabularies(portal.getWAeUPVocabularies())
[60]341        ##########################################
342        # Groups
343        ##########################################
[119]344
[19]345        self.installCustomWorkflows()
346        self.verifyWorkflowAssociation()
[119]347
[139]348        pr("End of specific %(product_name)s install" % vars())
349        #return '\n'.join(log)
[19]350        self.finalize()
351
[119]352
[152]353    def verifyPortlets(self, portlets=(), object=None): ###(
354        """Verify the existence of given portet in the object's portlet
355        container. If not found, a portlet is instantiated.
356        Existing portlets are not affected.
357
358        'portlets' is a tuple with the dictionaries given by the export tab
359        as entries.
360        The default object is the portal itself.
361
362        return the list a new portlet ids.
363        """
364
365        if object is None:
366            object = self.portal
367
368        self.log('Verifying portlets on %s' % object.absolute_url(relative=1))
369
370        portlet_container = self.getPortletContainer(object, create=1)
371
372        ttool = self.getTool('portal_types')
373
374        returned = []
375        for new_portlet in portlets:
376            existing_portlets = portlet_container.listPortlets()
377            updated = 0
378
379            # Check if the portlet needs an update
380            identifier = new_portlet.get('identifier')
381            if identifier:
382                for portlet in existing_portlets:
383                    if identifier == portlet.identifier:
384                        self.log(" Update of portlet: %s" % portlet)
385                        portlet.edit(**new_portlet)
386                        portlet_id = portlet.getId()
387                        updated = 1
388                        continue
389            slot = new_portlet.get('slot')
390            if slot:
391                for portlet in existing_portlets:
392                    if slot == portlet.slot:
393                        self.log(" Update of portlet: %s" % portlet)
394                        portlet.edit(**new_portlet)
395                        portlet_id = portlet.getId()
396                        updated = 1
397                        continue
398
399            if not updated:
400                self.log("   Creation of portlet: %s" % new_portlet)
401                portlet_id = self.portal.portal_cpsportlets.createPortlet(
402                    ptype_id=new_portlet['type'],
403                    context=object,
404                    **new_portlet)
405            if portlet_id not in returned:
406                returned.append(portlet_id)
407        return returned
[173]408    ###)
[152]409
410    def installCustomWorkflows(self): ###(
[19]411        """Installs custom workflows
412        """
413        from Products.WAeUP.Workflows.WAeUPWorkflow import \
414             waeupWorkflowsInstall
415
416        waeupWorkflowsInstall(self.context)
417
[152]418###)
[19]419
[152]420    def verifyWorkflowAssociation(self): ###(
[19]421        """Verify workflow association
422        """
[119]423        ws_chains = {
[19]424                      'Student': 'waeup_workspace_wf',
425                      'Jamb': 'waeup_workspace_wf',
426                      }
427
[45]428        se_chains = { 'University': 'waeup_section_wf',
[113]429                      'AcademicsFolder': 'waeup_section_wf',
[152]430                      'StudentsFolder': 'waeup_student_wf',
431                      'Student': 'waeup_student_wf',
432                      'StudentPersonal': 'waeup_student_wf',
[179]433                      'StudentEligibility': 'waeup_student_wf',
[166]434                      'StudentDocuments': 'waeup_student_wf',
[19]435                      'Jamb': 'waeup_section_wf',
[25]436                      'ScratchCard': 'waeup_section_wf',
[68]437                      'Faculty': 'waeup_section_wf',
438                      'Department': 'waeup_section_wf',
439                      'Course': 'waeup_section_wf',
[152]440                      'StudyLevel': 'waeup_student_wf',
441                      'Semester': 'waeup_student_wf',
442                      'CourseTicket': 'waeup_student_wf',
[103]443                      'AccoFolder': 'waeup_section_wf',
444                      'Accommodation': 'waeup_section_wf',
[19]445                      }
446
447        self.verifyLocalWorkflowChains(self.portal['workspaces'],
448                                       ws_chains,
449                                       destructive=1)
450        self.verifyLocalWorkflowChains(self.portal['sections'],
451                                       se_chains,
452                                       destructive=1)
[173]453    ###)
[19]454
[173]455    def verifyFaculties(self, academics): ###(
456        """install Universityspecific Faculies with Departments"""
457        faculties = [
458##                     {'id': 'agri', ###(
459##                      'Title': 'Agriculture',
460##                      'departments': [
461##                                     { 'id': 'dep1', ###(
462##                                       'Title': 'One',
463##                                     },
464##                                     ],
465##                      },###)
466                      { 'id': 'science',
467                      'Title': 'Science',
468                      'departments': [
469                                     { 'id': 'bio', ###(
470                                       'Title': 'Biochemistry',
471                                     },
472                                     { 'id': 'bot',
473                                       'Title': 'Botany',
474                                     },
475                                     { 'id': 'che',
476                                       'Title': 'Chemistry',
477                                     },
478                                     { 'id': 'com',
479                                       'Title': 'Computer Science',
480                                     },
481                                     { 'id': 'geo',
482                                       'Title': 'Geologie',
483                                     },
484                                     { 'id': 'mat',
485                                       'Title': 'Mathematics',
486                                     },
487                                     { 'id': 'mic',
488                                       'Title': 'Microbiology',
489                                     },
490                                     { 'id': 'opt',
491                                       'Title': 'Optometry',
492                                     },
493                                     { 'id': 'phy',
494                                       'Title': 'Physics',
495                                     },
496                                     { 'id': 'zoo',
497                                       'Title': 'Zoology',
498                                     },
499                                     ],
500                      },###)
501                     ]###)
502        self.log('Verifying Faculties in %s' % academics.absolute_url(relative=1))
503        for faculty in faculties:
504            fid = faculty['id']
505            f = getattr(academics,fid,None)
506            self.log('Checking Faculty %(id)s = %(Title)s' % faculty)
507            if f is None:
508                self.log('Creating Faculty %(id)s = %(Title)s' % faculty)
509                academics.invokeFactory('Faculty', fid)
510                f = getattr(academics,fid)
511                f.getContent().edit(mapping=faculty)
512            for department in faculty['departments']:
513                self.log('Checking Department %(id)s = %(Title)s' % department)
514                did = department['id']
515                d = getattr(f,did,None)
516                if d is None:
517                    self.log('Creating Department %(id)s = %(Title)s' % department)
518                    f.invokeFactory('Department', did)
519                    d = getattr(f,did)
520                    d.getContent().edit(mapping=department)
521    ###)
[19]522
[152]523
[173]524
[152]525def install(self): ###(
[19]526    installer = WAeUPInstaller(self)
527    installer.install(self)
[60]528    dirtool = getattr(self,'portal_directories')
529    groups = dirtool.groups
[96]530    for delEntry in ('StudentManager',):
531        if delEntry in groups.listEntryIds():
[119]532            groups.deleteEntry(delEntry)
[96]533    for newEntry in ('Students',):
[60]534        if newEntry not in groups.listEntryIds():
[119]535            groups.createEntry({'group': newEntry,
536                                'members': []})
[96]537    #groups.manage_setLocalGroupRoles(groupid = 'StudentManager',roles=('Manager',))
[60]538    #groups.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',))
539    sections = getattr(self,'sections')
[139]540    waeup = getattr(sections,SRPP_ID,None)
[60]541    if not waeup:
[139]542        sections.invokeFactory('University',SRPP_ID)
543        waeup = getattr(sections,SRPP_ID)
544        waeup.getContent().edit(mapping={'Title':SRPP_TITLE})
545        waeup.folder_localrole_add(member_ids=('group:Students',),
[60]546                                            member_role='SectionReviewer',
547                                            )
[139]548        waeup.invokeFactory('StudentsFolder','students')
549        students = getattr(waeup,'students').getContent()
550        students.edit(mapping={'Title':'Students'})
551        waeup.folder_localrole_add(member_ids=('group:Students',),
[60]552                                            member_role='SectionReviewer',
553                                            )
[139]554##        waeup.content_create(type_name='AcademicsFolder',title='academics')
[87]555##        sections.waeup.folder_localrole_add(member_ids=('group:StudentManager',),
556##                                            member_role='SectionManager',
557##                                            )
[139]558        waeup.students.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',))
559        waeup.invokeFactory('AcademicsFolder','academics', title='Academics')
560        academics = getattr(waeup,'academics').getContent()
561        academics.edit(mapping={'Title':'Academics'})
562        waeup.invokeFactory('AccoFolder','accommodation', title='Accommodation')
563        accommodation = getattr(waeup,'accommodation').getContent()
564        accommodation.edit(mapping={'Title':'Accommodation'})
[173]565    academics = getattr(waeup,'academics',None)
566    if academics is None:
[139]567        waeup.invokeFactory('AcademicsFolder','academics')
[173]568        academics = getattr(waeup,'academics')
569        academics.getContent().edit(mapping={'Title':'Academics'})
570    installer.verifyFaculties(academics)
[139]571    if not hasattr(waeup,'accommodation'):
572        waeup.invokeFactory('AccoFolder','accommodation')
573        accommodation = getattr(waeup,'accommodation').getContent()
574        accommodation.edit(mapping={'Title':'Accommodation'})
575    waeup.manage_setLocalGroupRoles(groupid = 'role:Anonymous',roles=('SectionReader',))
[87]576    # portlets ###(
577    #
578    portlets = (
[100]579##              {'identifier': 'waeup_main_tabs',
580##              'type': 'Custom Portlet',
581##              'slot': 'main_tabs',
582##              'order': 0,
583##              'render_method': 'portlet_main_navigation',
584##              'Title': 'main tabs',
585##              },
[152]586              {#'identifier': 'waeup_breadcrumbs',
[87]587              'type': 'Breadcrumbs Portlet',
588              'slot': 'waeup_breadcrumbs',
[152]589              'first_item': 0,
[87]590              'display_site_root': 0,
591              'Title': 'waeup_breadcrumbs',
592              'display': 'horizontal_trail',
593              'display_hidden_folders': 0,
594              'order': 0,
595              },
[152]596              {#'identifier': 'waeup_main_tab_actions',
[100]597              'type': 'Actions Portlet',
598              'slot': 'main_tabs',
599              'order': 0,
600              'categories': ['main_tabs',],
601              'Title': 'waep_main_tab_actions',
602              },
[152]603              {#'identifier': 'waeup_object_actions',
[87]604              'type': 'Actions Portlet',
605              'slot': 'waeup_object_actions',
606              'order': 0,
[100]607              'categories': ['object',],
[87]608              'Title': 'waep_manager_actions',
609              },
[152]610              {#'identifier': 'waeup_left_top',
[87]611              'type': 'Custom Portlet',
612              'slot': 'left_top',
613              'order': 0,
614              'render_method': 'portlet_session_info',
615              'Title': 'Session Info',
616              },
617            )
[89]618    installer.verifyPortletContainer(waeup)
619    installer.verifyPortlets(portlets,waeup)
[87]620
621###)
[19]622    return installer.logResult()
[152]623    ###)
[139]624
[152]625def migrate(self): ###(
[139]626    "update data"
627    log = []
628    prlog = log.append
629
630    def pr(msg, prlog=prlog):
[140]631        prlog('%s' % msg)
[139]632
633    sections = getattr(self,'sections')
[140]634    waeup = getattr(sections,SRPP_ID,None)
[139]635    pr( "Start migrate")
[162]636    pr("migrating Students")
637    students = getattr(waeup,'students')
[139]638    pr("migrating courses")
[141]639    academics = getattr(waeup,'academics')
640    for fac in [getattr(academics,f.id) for f in academics.contentValues(filter={'portal_type': ('Faculty',)})]:
[139]641        pr("Faculty: %s" % fac.title_or_id())
642        for dep in [getattr(fac,d.id) for d in fac.contentValues(filter={'portal_type': ('Department',)})]:
643            pr("Department: %s" % dep.title_or_id())
644            for course in [getattr(dep,c.id) for c in dep.contentValues(filter={'portal_type': ('Course',)})]:
645                pr("Course: %s" % course.title_or_id())
646                content = course.getContent()
647                heading = getattr(content,'heading',course.id)
648                pr("heading = %(heading)s" % vars())
649                content.edit(mapping={'Title': heading})
650    pr("migrating halls")
651    for ac in [getattr(waeup,a.id) for a in waeup.contentValues(filter={'portal_type': ('AccoFolder',)})]:
652        for hall in [getattr(ac,h.id) for h in ac.contentValues(filter={'portal_type': ('Accommodation',)})]:
653            pr("Hall: %s" % hall.title_or_id())
654            content = hall.getContent()
655            heading = getattr(content,'heading',hall.id)
656            pr("heading = %(heading)s" % vars())
657            content.edit(mapping={'Title': heading})
658    return '\n'.join(log)
[169]659
[152]660###)
661
Note: See TracBrowser for help on using the repository browser.