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

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

=fixed install break

  • Property svn:keywords set to Id
File size: 17.4 KB
Line 
1#-*- mode: python; mode: fold -*-
2# $Id: install.py 87 2005-10-26 06:35:43Z 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        if CPSSubscriptions: ###(
73            ptypes = "('Portal', 'CPSMailAccess Message', 'CPSMailAccess Box', 'CPSMailAccess Folder',"\
74                     +  "'University', 'StudentsFolder', 'Student', 'Jamb')"
75            condition = "object.portal_type not in %s" % ptypes
76   
77            action = {'id' : 'notify_content',
78                      'name' : 'action_notify_content',
79                      'action' : 'string:${object_url}/content_notify_email_form',
80                      'condition' : 'python:%s' % condition,
81                      'permission' :  (CanNotifyContent,),
82                      'category' : 'object',
83                      }
84            self.deleteActions({'portal_subscriptions': ['notify_content',]})
85            self.verifyAction('portal_subscriptions', **action)
86        if CPSForum:
87            ptypes = "('University', 'StudentsFolder', 'Student', 'Jamb')"
88            condition = "object.portal_type not in %s" % ptypes
89   
90            action = {'id' : 'activate_comments',
91                      'name': 'action_activate_comments',
92                      'action': 'string:${object/absolute_url}/set_comment_mode?mode=1',
93                      'condition' : 'python:%s' % condition,
94                      'permission': (ForumManageComments,),
95                      'category' : 'object',
96                      }
97            self.deleteActions({'portal_subscriptions': ['activate_comments',]})
98            self.verifyAction('portal_subscriptions', **action)
99            # now portal_discussion
100            self.deleteActions({'portal_discussion': ['comment',
101                                                      'activate_comments',
102                                                      'deactivate_comments',
103                                                      'manage_comments']})
104            action = {'id' : 'comment',
105                      'name': 'action_comment',
106                      'action': "string:${object/absolute_url}/post_comment",
107                      'condition' : "python:getattr(object.getContent(), 'allow_discussion' , None) and object.hasCommentAction()",
108                      'permission': (View,),
109                      'category' : 'object',
110                      }
111            self.verifyAction('portal_discussion', **action)
112            action = {'id' : 'activate_comments',
113                      'name': 'action_activate_comments',
114                      'action': "string:${object/absolute_url}/set_comment_mode?mode=1",
115                      'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1",
116                      'permission': (ForumManageComments,),
117                      'category' : 'object',
118                      }
119            self.verifyAction('portal_discussion', **action)
120            action = {'id' : 'deactivate_comments',
121                      'name': 'action_deactivate_comments',
122                      'action': "string:${object/absolute_url}/set_comment_mode?mode=0",
123                      'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1",
124                      'permission': (ForumManageComments,),
125                      'category' : 'object',
126                      }
127            self.verifyAction('portal_discussion', **action)
128            action = {'id' : 'manage_comments',
129                      'name': 'action_manage_comments',
130                      'action': "string:${object/absolute_url}/manage_comment",
131                      'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1",
132                      'permission': (ForumManageComments,),
133                      'category' : 'object',
134                      }
135            self.verifyAction('portal_discussion', **action)
136       
137###)
138
139        ##########################################
140        # student actions ###(
141        ##########################################
142        actions = ( { 'tool'      : 'portal_actions',
143                        'id'        : 'checkadmission',
144                        'name'      : 'Check Admission',
145                        'action'    : 'string:${object/absolute_url}/check_admission',
146                        'permission': (View, ),
147                        'condition' : 'python: not member',
148                        'category'  : 'student',
149                        'visible'   : 1,
150                      },
151##                      { 'tool'      : 'portal_actions',
152##                        'id'        : 'new_student',
153##                        'name'      : 'Add Student',
154##                        'action'    : 'string:${object/absolute_url}/create_student_form',
155##                        'permission': (View),
156##                        'condition' : 'python: 0 and member and here.portal_type == "StudentsFolder"',
157##                        'category'  : 'student',
158##                        'visible'   : 1,
159##                      },
160                      { 'tool'      : 'portal_actions',
161                        'id'        : 'edit_student',
162                        'name'      : 'Edit Student',
163                        'action'    : 'cpsdocument_edit_form',
164                        'permission': ( ),
165                        'condition' : 'python: 0 and member and  here.portal_type == "Student"',
166                        'category'  : 'student',
167                        'visible'   : 1,
168                      },
169                      { 'tool'      : 'portal_actions',
170                        'id'        : 'add_jamb',
171                        'name'      : 'Add Student JAMB',
172                        'action'    : 'string:${object/absolute_url}/create_jamb',
173                        'permission': (),
174                        'condition' : 'python: member and here.portal_type in ("StudentsFolder",) and "StudentManager" in member.getGroups()',
175                        'category'  : 'student',
176                        'visible'   : 1,
177                      },
178                      { 'tool'      : 'portal_actions',
179                        'id'        : 'add_faculty',
180                        'name'      : 'Add New Faculty',
181                        'action'    : 'string:${object/absolute_url}/addFaculty',
182                        'permission': (),
183                        'condition' : 'python: member and here.portal_type in ("University",) and "StudentManager" in member.getGroups()',
184                        'category'  : 'student',
185                        'visible'   : 1,
186                      },
187                      { 'tool'      : 'portal_actions',
188                        'id'        : 'add_department',
189                        'name'      : 'Add New Department',
190                        'action'    : 'string:${object/absolute_url}/addDepartment',
191                        'permission': (),
192                        'condition' : 'python: member and here.portal_type in ("Faculty",) and "StudentManager" in member.getGroups()',
193                        'category'  : 'student',
194                        'visible'   : 1,
195                      },
196                      { 'tool'      : 'portal_actions',
197                        'id'        : 'add_course',
198                        'name'      : 'Add New Course',
199                        'action'    : 'string:${object/absolute_url}/addCourse',
200                        'permission': (),
201                        'condition' : 'python: member and here.portal_type in ("Department",) and "StudentManager" in member.getGroups()',
202                        'category'  : 'student',
203                        'visible'   : 1,
204                      },
205                      { 'tool'      : 'portal_actions',
206                        'id'        : 'add_personal',
207                        'name'      : 'Add personal Data',
208                        'action'    : 'string:${object/absolute_url}/create_personal_form',
209                        'permission': (),
210                        'condition' : 'python: 0 and member and not here.portal_type in ("Jamb","StudentsFolder") and not "StudentManager" in member.getGroups()',
211                        'category'  : 'student',
212                        'visible'   : 1,
213                      },
214                      { 'tool'      : 'portal_actions',
215                        'id'        : 'edit_jamb',
216                        'name'      : 'Edit Jamb Data',
217                        'action'    : 'cpsdocument_edit_form',
218                        'permission': ( ),
219                        'condition' : 'python: member and here.portal_type in ("Student",) and "StudentManager" in member.getGroups()',
220                        'category'  : 'student',
221                        'visible'   : 1,
222                      },
223                    )
224        self.verifyActions(actions)
225        ##########################################
226###)
227
228        # skins
229        ##########################################
230        self.log("Verifying %(product_name)s skinss" % vars())
231        wskins = { 'waeup_default' : 'Products/WAeUP/skins/waeup_default',
232                   'waeup_faculty' : 'Products/WAeUP/skins/waeup_faculty',
233                   'waeup_student' : 'Products/WAeUP/skins/waeup_student',
234                 }
235        self.verifySkins(wskins)
236        self.resetSkinCache()
237       
238        ##########################################
239        # portal types
240        ##########################################
241        dtypes = portal.getWAeUPTypes()
242        self.verifyFlexibleTypes(dtypes)
243        self.allowContentTypes('University', ('Workspace','Section',))
244        ##########################################
245        # Schemas
246        ##########################################
247        self.log("Verifying %(product_name)s schemas" % vars())
248        self.verifySchemas(portal.getWAeUPSchemas())
249        ##########################################
250        # widgets
251        ##########################################
252        self.log("Verifying %(product_name)s widgets" % vars())
253        self.verifyWidgets(portal.getWAeUPWidgets())
254        ##########################################
255        # layouts
256        ##########################################
257        self.log("Verifying %(product_name)s layouts" % vars())
258        self.verifyLayouts(portal.getWAeUPLayouts())
259        ##########################################
260        # Vocabularies
261        ##########################################
262        self.log("Verifying %(product_name)s vocabularies" % vars())
263        self.verifyVocabularies(portal.getWAeUPVocabularies())
264        ##########################################
265        # Groups
266        ##########################################
267           
268        self.installCustomWorkflows()
269        self.verifyWorkflowAssociation()
270       
271        self.log("End of specific %(product_name)s install" % vars())
272        self.finalize()
273       
274
275    def installCustomWorkflows(self):
276        """Installs custom workflows
277        """
278        from Products.WAeUP.Workflows.WAeUPWorkflow import \
279             waeupWorkflowsInstall
280
281        waeupWorkflowsInstall(self.context)
282
283
284    def verifyWorkflowAssociation(self):
285        """Verify workflow association
286        """
287        ws_chains = {
288                      'Student': 'waeup_workspace_wf',
289                      'Jamb': 'waeup_workspace_wf',
290                      }
291
292        se_chains = { 'University': 'waeup_section_wf',
293                      'StudentsFolder': 'waeup_section_wf',
294                      'Student': 'waeup_section_wf',
295                      'StudentPersonal': 'waeup_section_wf',
296                      'Jamb': 'waeup_section_wf',
297                      'ScratchCard': 'waeup_section_wf',
298                      'Faculty': 'waeup_section_wf',
299                      'Department': 'waeup_section_wf',
300                      'Course': 'waeup_section_wf',
301                      }
302
303        self.verifyLocalWorkflowChains(self.portal['workspaces'],
304                                       ws_chains,
305                                       destructive=1)
306        self.verifyLocalWorkflowChains(self.portal['sections'],
307                                       se_chains,
308                                       destructive=1)
309
310
311def install(self):
312    installer = WAeUPInstaller(self)
313    installer.install(self)
314    dirtool = getattr(self,'portal_directories')
315    groups = dirtool.groups
316    for newEntry in ('Students','StudentManager'):
317        if newEntry not in groups.listEntryIds():
318            groups.createEntry({'group': newEntry,
319                                'members': []}) 
320    groups.manage_setLocalGroupRoles(groupid = 'StudentManager',roles=('Manager',))
321    #groups.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',))
322    sections = getattr(self,'sections')
323    waeup = getattr(sections,'waeup',None)
324    if not waeup:
325        sections.content_create(type_name='University',title='waeup')
326        sections.waeup.folder_localrole_add(member_ids=('group:Students',),
327                                            member_role='SectionReviewer',
328                                            )
329        sections.waeup.content_create(type_name='StudentsFolder',title='students')
330        sections.waeup.folder_localrole_add(member_ids=('group:Students',),
331                                            member_role='SectionReviewer',
332                                            )
333##        sections.waeup.folder_localrole_add(member_ids=('group:StudentManager',),
334##                                            member_role='SectionManager',
335##                                            )
336        sections.waeup.students.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',))
337    sections.waeup.manage_setLocalGroupRoles(groupid = 'role:Anonymous',roles=('SectionReader',))
338    # portlets ###(
339    #
340    portlets = (
341              {'identifier': 'waeup_main_tabs',
342              'type': 'Custom Portlet',
343              'slot': 'main_tabs',
344              'order': 0,
345              'render_method': 'portlet_main_navigation',
346              'Title': 'main tabs',
347              },
348              {'identifier': 'waeup_breadcrumbs',
349              'type': 'Breadcrumbs Portlet',
350              'slot': 'waeup_breadcrumbs',
351              'first_item': 2,
352              'display_site_root': 0,
353              'Title': 'waeup_breadcrumbs',
354              'display': 'horizontal_trail',
355              'display_hidden_folders': 0,
356              'order': 0,
357              },
358              {'identifier': 'waeup_object_actions',
359              'type': 'Actions Portlet',
360              'slot': 'waeup_object_actions',
361              'order': 0,
362              'categories': ['object'],
363              'Title': 'waep_manager_actions',
364              },
365              {'identifier': 'waeup_left_top',
366              'type': 'Custom Portlet',
367              'slot': 'left_top',
368              'order': 0,
369              'render_method': 'portlet_session_info',
370              'Title': 'Session Info',
371              },
372            )
373    installer.verifyPortletContainer(self.portal.sections.waeup)
374    installer.verifyPortlets(portlets, self.portal.sections.waeup)
375
376###)
377
378    return installer.logResult()
Note: See TracBrowser for help on using the repository browser.