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

Last change on this file since 108 was 106, checked in by joachim, 19 years ago

=fixes for Henrik

  • Property svn:keywords set to Id
File size: 17.8 KB
Line 
1#-*- mode: python; mode: fold -*-
2# $Id: install.py 106 2005-10-27 19:30:56Z joachim $
3from Products.CPSInstaller.CPSInstaller import CPSInstaller
4from Products.CMFCore.CMFCorePermissions import View, ModifyPortalContent
5from Products.WAeUP.WAeUPPermissions import UniversityManage, StudentManage,FacultyManage,\
6                                            DepartmentManage,CourseManage
7try:
8  from Products.CPSSubscriptions.permissions import CanNotifyContent
9  CPSSubscriptions = True
10except ImportError:
11  CPSSubscriptions = False
12try:
13  from Products.CPSForum.CPSForumPermissions import ForumManageComments
14  CPSForum = True
15except ImportError:
16  CPSForum = False
17
18from Products.WAeUP.Students import addStudentsFolder
19
20class WAeUPInstaller(CPSInstaller):
21    """
22    WAeUP Installer
23    """
24    product_name = "WAeUP"
25
26    def install(self,portal):
27        "install"
28
29        product_name = self.product_name
30        self.log("Starting %(product_name)s install" % vars() )
31   
32        # Roles and Permissions ###(
33        #
34        self.verifyRoles((
35            # A role that can manage the University.
36            'UniversityManager',
37            # A role that can manage the StudentsRecords.
38            'StudentManager',
39            # A role that can manage a Faculty.
40            'FacultyManager',
41            # A role that can manage a department.
42            'DepartmentManager',
43            # A role that can manage a Course.
44            'CourseManager',
45            # The Student Role
46            'Student',
47        ))
48        waeup_perms = {
49            UniversityManage:
50                ('Manager', 'SectionManager','UniversityManager',
51                 ),
52            StudentManage:
53                ('Manager', 'SectionManager','UniversityManager', 'StudentManager'
54                 ),
55            FacultyManage:
56                ('Manager', 'SectionManager','UniversityManager', 'FacultyManager'
57                 ),
58            DepartmentManage:
59                ('Manager', 'SectionManager','UniversityManager', 'DepartmentManager'
60                 ),
61            CourseManage:
62                ('Manager', 'SectionManager','UniversityManager', 'CourseManager'
63                 ),
64        }
65        self.setupPortalPermissions(waeup_perms)
66
67###)
68
69        ##########################################
70        # Actions
71        ##########################################
72        waeup_ptypes = "'University','StudentsFolder','Student','Jamb','Faculty','Department','Course'"
73        waeup_ptypes += ",'AccoFolder','Accommodation','StudentPersonal'"
74        if CPSSubscriptions: ###(
75           
76            ptypes = "('Portal', 'CPSMailAccess Message', 'CPSMailAccess Box', 'CPSMailAccess Folder',"\
77                     + waeup_ptypes + ")"
78            condition = "object.portal_type not in %s" % ptypes
79   
80            action = {'id' : 'notify_content',
81                      'name' : 'action_notify_content',
82                      'action' : 'string:${object_url}/content_notify_email_form',
83                      'condition' : 'python:%s' % condition,
84                      'permission' :  (CanNotifyContent,),
85                      'category' : 'object',
86                      }
87            self.deleteActions({'portal_subscriptions': ['notify_content',]})
88            self.verifyAction('portal_subscriptions', **action)
89        if CPSForum:
90            condition = "object.portal_type not in (%s)" % waeup_ptypes
91   
92            action = {'id' : 'activate_comments',
93                      'name': 'action_activate_comments',
94                      'action': 'string:${object/absolute_url}/set_comment_mode?mode=1',
95                      'condition' : 'python:%s' % condition,
96                      'permission': (ForumManageComments,),
97                      'category' : 'object',
98                      }
99            self.deleteActions({'portal_subscriptions': ['activate_comments',]})
100            self.verifyAction('portal_subscriptions', **action)
101            # now portal_discussion
102            self.deleteActions({'portal_discussion': ['comment',
103                                                      'activate_comments',
104                                                      'deactivate_comments',
105                                                      'manage_comments']})
106            action = {'id' : 'comment',
107                      'name': 'action_comment',
108                      'action': "string:${object/absolute_url}/post_comment",
109                      'condition' : "python:getattr(object.getContent(), 'allow_discussion' , None) and object.hasCommentAction()",
110                      'permission': (View,),
111                      'category' : 'object',
112                      }
113            self.verifyAction('portal_discussion', **action)
114            action = {'id' : 'activate_comments',
115                      'name': 'action_activate_comments',
116                      'action': "string:${object/absolute_url}/set_comment_mode?mode=1",
117                      'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1",
118                      'permission': (ForumManageComments,),
119                      'category' : 'object',
120                      }
121            self.verifyAction('portal_discussion', **action)
122            action = {'id' : 'deactivate_comments',
123                      'name': 'action_deactivate_comments',
124                      'action': "string:${object/absolute_url}/set_comment_mode?mode=0",
125                      'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1",
126                      'permission': (ForumManageComments,),
127                      'category' : 'object',
128                      }
129            self.verifyAction('portal_discussion', **action)
130            action = {'id' : 'manage_comments',
131                      'name': 'action_manage_comments',
132                      'action': "string:${object/absolute_url}/manage_comment",
133                      'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1",
134                      'permission': (ForumManageComments,),
135                      'category' : 'object',
136                      }
137            self.verifyAction('portal_discussion', **action)
138       
139###)
140
141        ##########################################
142        # main_tab actions ###(
143        ##########################################
144        actions = ( { 'tool'      : 'portal_actions',
145                        'id'        : 'student_administration',
146                        'name'      : 'Student Administration',
147                        'action'    : 'string:${portal_url}/sections/waeup/students',
148                        'permission': (View, ),
149                        'category'  : 'main_tabs',
150                        'visible'   : 1,
151                      },
152                      { 'tool'      : 'portal_actions',
153                        'id'        : 'faculties',
154                        'name'      : 'Faculties',
155                        'action'    : 'string:${portal_url}/sections/waeup/faculties',
156                        'permission': (View ),
157                        'category'  : 'main_tabs',
158                        'visible'   : 1,
159                      },
160                      { 'tool'      : 'portal_actions',
161                        'id'        : 'accomodation',
162                        'name'      : 'Accommodation',
163                        'action'    : 'string:${portal_url}/sections/waeup/Accommodation/accommodation_index_html',
164                        'permissions': (ModifyPortalContent,UniversityManage,StudentManage),
165                        'category'  : 'main_tabs',
166                        'visible'   : 1,
167                      },
168##                      { 'tool'      : 'portal_actions',
169##                        'id'        : 'add_jamb',
170##                        'name'      : 'Add Student JAMB',
171##                        'action'    : 'string:${object/absolute_url}/create_jamb',
172##                        'permission': (),
173##                        'condition' : 'python: member and here.portal_type in ("StudentsFolder",) and "StudentManager" in member.getGroups()',
174##                        'category'  : 'student',
175##                        'visible'   : 1,
176##                      },
177##                      { 'tool'      : 'portal_actions',
178##                        'id'        : 'add_faculty',
179##                        'name'      : 'Add New Faculty',
180##                        'action'    : 'string:${object/absolute_url}/addFaculty',
181##                        'permission': (),
182##                        'condition' : 'python: member and here.portal_type in ("University",) and "StudentManager" in member.getGroups()',
183##                        'category'  : 'student',
184##                        'visible'   : 1,
185##                      },
186##                      { 'tool'      : 'portal_actions',
187##                        'id'        : 'add_department',
188##                        'name'      : 'Add New Department',
189##                        'action'    : 'string:${object/absolute_url}/addDepartment',
190##                        'permission': (),
191##                        'condition' : 'python: member and here.portal_type in ("Faculty",) and "StudentManager" in member.getGroups()',
192##                        'category'  : 'student',
193##                        'visible'   : 1,
194##                      },
195##                      { 'tool'      : 'portal_actions',
196##                        'id'        : 'add_course',
197##                        'name'      : 'Add New Course',
198##                        'action'    : 'string:${object/absolute_url}/addCourse',
199##                        'permission': (),
200##                        'condition' : 'python: member and here.portal_type in ("Department",) and "StudentManager" in member.getGroups()',
201##                        'category'  : 'student',
202##                        'visible'   : 1,
203##                      },
204##                      { 'tool'      : 'portal_actions',
205##                        'id'        : 'add_personal',
206##                        'name'      : 'Add personal Data',
207##                        'action'    : 'string:${object/absolute_url}/create_personal_form',
208##                        'permission': (),
209##                        'condition' : 'python: 0 and member and not here.portal_type in ("Jamb","StudentsFolder") and not "StudentManager" in member.getGroups()',
210##                        'category'  : 'student',
211##                        'visible'   : 1,
212##                      },
213##                      { 'tool'      : 'portal_actions',
214##                        'id'        : 'edit_jamb',
215##                        'name'      : 'Edit Jamb Data',
216##                        'action'    : 'cpsdocument_edit_form',
217##                        'permission': ( ),
218##                        'condition' : 'python: member and here.portal_type in ("Student",) and "StudentManager" in member.getGroups()',
219##                        'category'  : 'student',
220##                        'visible'   : 1,
221##                      },
222                    )
223        self.verifyActions(actions)
224        ##########################################
225###)
226
227        # skins
228        ##########################################
229        self.log("Verifying %(product_name)s skinss" % vars())
230        wskins = { 'waeup_default' : 'Products/WAeUP/skins/waeup_default',
231                   'waeup_faculty' : 'Products/WAeUP/skins/waeup_faculty',
232                   'waeup_student' : 'Products/WAeUP/skins/waeup_student',
233                 }
234        self.verifySkins(wskins)
235        self.resetSkinCache()
236       
237        ##########################################
238        # portal types
239        ##########################################
240        dtypes = portal.getWAeUPTypes()
241        self.verifyFlexibleTypes(dtypes)
242        self.allowContentTypes('University', ('Workspace','Section',))
243        ##########################################
244        # Schemas
245        ##########################################
246        self.log("Verifying %(product_name)s schemas" % vars())
247        self.verifySchemas(portal.getWAeUPSchemas())
248        ##########################################
249        # widgets
250        ##########################################
251        self.log("Verifying %(product_name)s widgets" % vars())
252        self.verifyWidgets(portal.getWAeUPWidgets())
253        ##########################################
254        # layouts
255        ##########################################
256        self.log("Verifying %(product_name)s layouts" % vars())
257        self.verifyLayouts(portal.getWAeUPLayouts())
258        ##########################################
259        # Vocabularies
260        ##########################################
261        self.log("Verifying %(product_name)s vocabularies" % vars())
262        self.verifyVocabularies(portal.getWAeUPVocabularies())
263        ##########################################
264        # Groups
265        ##########################################
266           
267        self.installCustomWorkflows()
268        self.verifyWorkflowAssociation()
269       
270        self.log("End of specific %(product_name)s install" % vars())
271        self.finalize()
272       
273
274    def installCustomWorkflows(self):
275        """Installs custom workflows
276        """
277        from Products.WAeUP.Workflows.WAeUPWorkflow import \
278             waeupWorkflowsInstall
279
280        waeupWorkflowsInstall(self.context)
281
282
283    def verifyWorkflowAssociation(self):
284        """Verify workflow association
285        """
286        ws_chains = {
287                      'Student': 'waeup_workspace_wf',
288                      'Jamb': 'waeup_workspace_wf',
289                      }
290
291        se_chains = { 'University': 'waeup_section_wf',
292                      'StudentsFolder': 'waeup_section_wf',
293                      'Student': 'waeup_section_wf',
294                      'StudentPersonal': 'waeup_section_wf',
295                      'Jamb': 'waeup_section_wf',
296                      'ScratchCard': 'waeup_section_wf',
297                      'Faculty': 'waeup_section_wf',
298                      'Department': 'waeup_section_wf',
299                      'Course': 'waeup_section_wf',
300                      'AccoFolder': 'waeup_section_wf',
301                      'Accommodation': 'waeup_section_wf',
302                      }
303
304        self.verifyLocalWorkflowChains(self.portal['workspaces'],
305                                       ws_chains,
306                                       destructive=1)
307        self.verifyLocalWorkflowChains(self.portal['sections'],
308                                       se_chains,
309                                       destructive=1)
310
311
312def install(self):
313    installer = WAeUPInstaller(self)
314    installer.install(self)
315    dirtool = getattr(self,'portal_directories')
316    groups = dirtool.groups
317    for delEntry in ('StudentManager',):
318        if delEntry in groups.listEntryIds():
319            groups.deleteEntry(delEntry) 
320    for newEntry in ('Students',):
321        if newEntry not in groups.listEntryIds():
322            groups.createEntry({'group': newEntry,
323                                'members': []}) 
324    #groups.manage_setLocalGroupRoles(groupid = 'StudentManager',roles=('Manager',))
325    #groups.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',))
326    sections = getattr(self,'sections')
327    waeup = getattr(sections,'waeup',None)
328    if not waeup:
329        sections.content_create(type_name='University',title='waeup')
330        sections.waeup.folder_localrole_add(member_ids=('group:Students',),
331                                            member_role='SectionReviewer',
332                                            )
333        sections.waeup.content_create(type_name='StudentsFolder',title='students')
334        sections.waeup.folder_localrole_add(member_ids=('group:Students',),
335                                            member_role='SectionReviewer',
336                                            )
337##        sections.waeup.folder_localrole_add(member_ids=('group:StudentManager',),
338##                                            member_role='SectionManager',
339##                                            )
340        sections.waeup.students.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',))
341    sections.waeup.manage_setLocalGroupRoles(groupid = 'role:Anonymous',roles=('SectionReader',))
342    # portlets ###(
343    #
344    portlets = (
345##              {'identifier': 'waeup_main_tabs',
346##              'type': 'Custom Portlet',
347##              'slot': 'main_tabs',
348##              'order': 0,
349##              'render_method': 'portlet_main_navigation',
350##              'Title': 'main tabs',
351##              },
352              {'identifier': 'waeup_breadcrumbs',
353              'type': 'Breadcrumbs Portlet',
354              'slot': 'waeup_breadcrumbs',
355              'first_item': 2,
356              'display_site_root': 0,
357              'Title': 'waeup_breadcrumbs',
358              'display': 'horizontal_trail',
359              'display_hidden_folders': 0,
360              'order': 0,
361              },
362              {'identifier': 'waeup_main_tab_actions',
363              'type': 'Actions Portlet',
364              'slot': 'main_tabs',
365              'order': 0,
366              'categories': ['main_tabs',],
367              'Title': 'waep_main_tab_actions',
368              },
369              {'identifier': 'waeup_object_actions',
370              'type': 'Actions Portlet',
371              'slot': 'waeup_object_actions',
372              'order': 0,
373              'categories': ['object',],
374              'Title': 'waep_manager_actions',
375              },
376              {'identifier': 'waeup_left_top',
377              'type': 'Custom Portlet',
378              'slot': 'left_top',
379              'order': 0,
380              'render_method': 'portlet_session_info',
381              'Title': 'Session Info',
382              },
383            )
384    installer.verifyPortletContainer(waeup)
385    installer.verifyPortlets(portlets,waeup)
386
387###)
388
389    return installer.logResult()
Note: See TracBrowser for help on using the repository browser.