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

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

bug fixes

  • Property svn:keywords set to Id
File size: 18.1 KB
Line 
1#-*- mode: python; mode: fold -*-
2# $Id: install.py 119 2005-10-28 19:44:25Z henrik $
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','AcademicsFolder'"
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'      : 'Students',
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'        : 'Academics',
154                        'name'      : 'Academics',
155                        'action'    : 'string:${portal_url}/sections/waeup/academics/academics_view',
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': (View),
165                        #'permissions': (ModifyPortalContent,UniversityManage,StudentManage),
166                        'category'  : 'main_tabs',
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                      'AcademicsFolder': 'waeup_section_wf',
294                      'StudentsFolder': 'waeup_section_wf',
295                      'Student': 'waeup_section_wf',
296                      'StudentPersonal': 'waeup_section_wf',
297                      'Jamb': 'waeup_section_wf',
298                      'ScratchCard': 'waeup_section_wf',
299                      'Faculty': 'waeup_section_wf',
300                      'Department': 'waeup_section_wf',
301                      'Course': 'waeup_section_wf',
302                      'AccoFolder': 'waeup_section_wf',
303                      'Accommodation': 'waeup_section_wf',
304                      }
305
306        self.verifyLocalWorkflowChains(self.portal['workspaces'],
307                                       ws_chains,
308                                       destructive=1)
309        self.verifyLocalWorkflowChains(self.portal['sections'],
310                                       se_chains,
311                                       destructive=1)
312
313
314def install(self):
315    installer = WAeUPInstaller(self)
316    installer.install(self)
317    dirtool = getattr(self,'portal_directories')
318    groups = dirtool.groups
319    for delEntry in ('StudentManager',):
320        if delEntry in groups.listEntryIds():
321            groups.deleteEntry(delEntry)
322    for newEntry in ('Students',):
323        if newEntry not in groups.listEntryIds():
324            groups.createEntry({'group': newEntry,
325                                'members': []})
326    #groups.manage_setLocalGroupRoles(groupid = 'StudentManager',roles=('Manager',))
327    #groups.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',))
328    sections = getattr(self,'sections')
329    waeup = getattr(sections,'waeup',None)
330    if not waeup:
331        sections.content_create(type_name='University',title='waeup')
332        sections.waeup.folder_localrole_add(member_ids=('group:Students',),
333                                            member_role='SectionReviewer',
334                                            )
335        sections.waeup.content_create(type_name='StudentsFolder',title='students')
336        sections.waeup.folder_localrole_add(member_ids=('group:Students',),
337                                            member_role='SectionReviewer',
338                                            )
339        sections.waeup.content_create(type_name='AcademicsFolder',title='academics')
340##        sections.waeup.folder_localrole_add(member_ids=('group:StudentManager',),
341##                                            member_role='SectionManager',
342##                                            )
343        sections.waeup.students.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',))
344    elif not hasattr(waeup,'academics'):
345        waeup.content_create(type_name='AcademicsFolder',title='academics')
346    sections.waeup.manage_setLocalGroupRoles(groupid = 'role:Anonymous',roles=('SectionReader',))
347    # portlets ###(
348    #
349    portlets = (
350##              {'identifier': 'waeup_main_tabs',
351##              'type': 'Custom Portlet',
352##              'slot': 'main_tabs',
353##              'order': 0,
354##              'render_method': 'portlet_main_navigation',
355##              'Title': 'main tabs',
356##              },
357              {'identifier': 'waeup_breadcrumbs',
358              'type': 'Breadcrumbs Portlet',
359              'slot': 'waeup_breadcrumbs',
360              'first_item': 2,
361              'display_site_root': 0,
362              'Title': 'waeup_breadcrumbs',
363              'display': 'horizontal_trail',
364              'display_hidden_folders': 0,
365              'order': 0,
366              },
367              {'identifier': 'waeup_main_tab_actions',
368              'type': 'Actions Portlet',
369              'slot': 'main_tabs',
370              'order': 0,
371              'categories': ['main_tabs',],
372              'Title': 'waep_main_tab_actions',
373              },
374              {'identifier': 'waeup_object_actions',
375              'type': 'Actions Portlet',
376              'slot': 'waeup_object_actions',
377              'order': 0,
378              'categories': ['object',],
379              'Title': 'waep_manager_actions',
380              },
381              {'identifier': 'waeup_left_top',
382              'type': 'Custom Portlet',
383              'slot': 'left_top',
384              'order': 0,
385              'render_method': 'portlet_session_info',
386              'Title': 'Session Info',
387              },
388            )
389    installer.verifyPortletContainer(waeup)
390    installer.verifyPortlets(portlets,waeup)
391
392###)
393
394    return installer.logResult()
Note: See TracBrowser for help on using the repository browser.