1 | #-*- mode: python; mode: fold -*- |
---|
2 | # $Id: install.py 124 2005-10-29 10:45:10Z henrik $ |
---|
3 | from Products.CPSInstaller.CPSInstaller import CPSInstaller |
---|
4 | from Products.CMFCore.CMFCorePermissions import View, ModifyPortalContent |
---|
5 | from Products.WAeUP.WAeUPPermissions import UniversityManage, StudentManage,FacultyManage,\ |
---|
6 | DepartmentManage,CourseManage |
---|
7 | try: |
---|
8 | from Products.CPSSubscriptions.permissions import CanNotifyContent |
---|
9 | CPSSubscriptions = True |
---|
10 | except ImportError: |
---|
11 | CPSSubscriptions = False |
---|
12 | try: |
---|
13 | from Products.CPSForum.CPSForumPermissions import ForumManageComments |
---|
14 | CPSForum = True |
---|
15 | except ImportError: |
---|
16 | CPSForum = False |
---|
17 | |
---|
18 | from Products.WAeUP.Students import addStudentsFolder |
---|
19 | |
---|
20 | class 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:$folder_url/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 | 'action' : 'string:$folder_url/academics', |
---|
157 | 'permission': (View ), |
---|
158 | 'category' : 'main_tabs', |
---|
159 | 'visible' : 1, |
---|
160 | }, |
---|
161 | { 'tool' : 'portal_actions', |
---|
162 | 'id' : 'accomodation', |
---|
163 | 'name' : 'Accommodation', |
---|
164 | #'action' : 'string:${portal_url}/sections/waeup/accommodation/accommodation_index_html', |
---|
165 | 'action' : 'string:$folder_url/accommodation', |
---|
166 | 'permissions': (View), |
---|
167 | #'permissions': (ModifyPortalContent,UniversityManage,StudentManage), |
---|
168 | 'category' : 'main_tabs', |
---|
169 | 'visible' : 1, |
---|
170 | }, |
---|
171 | ## { 'tool' : 'portal_actions', |
---|
172 | ## 'id' : 'add_jamb', |
---|
173 | ## 'name' : 'Add Student JAMB', |
---|
174 | ## 'action' : 'string:${object/absolute_url}/create_jamb', |
---|
175 | ## 'permission': (), |
---|
176 | ## 'condition' : 'python: member and here.portal_type in ("StudentsFolder",) and "StudentManager" in member.getGroups()', |
---|
177 | ## 'category' : 'student', |
---|
178 | ## 'visible' : 1, |
---|
179 | ## }, |
---|
180 | ## { 'tool' : 'portal_actions', |
---|
181 | ## 'id' : 'add_faculty', |
---|
182 | ## 'name' : 'Add New Faculty', |
---|
183 | ## 'action' : 'string:${object/absolute_url}/addFaculty', |
---|
184 | ## 'permission': (), |
---|
185 | ## 'condition' : 'python: member and here.portal_type in ("University",) and "StudentManager" in member.getGroups()', |
---|
186 | ## 'category' : 'student', |
---|
187 | ## 'visible' : 1, |
---|
188 | ## }, |
---|
189 | ## { 'tool' : 'portal_actions', |
---|
190 | ## 'id' : 'add_department', |
---|
191 | ## 'name' : 'Add New Department', |
---|
192 | ## 'action' : 'string:${object/absolute_url}/addDepartment', |
---|
193 | ## 'permission': (), |
---|
194 | ## 'condition' : 'python: member and here.portal_type in ("Faculty",) and "StudentManager" in member.getGroups()', |
---|
195 | ## 'category' : 'student', |
---|
196 | ## 'visible' : 1, |
---|
197 | ## }, |
---|
198 | ## { 'tool' : 'portal_actions', |
---|
199 | ## 'id' : 'add_course', |
---|
200 | ## 'name' : 'Add New Course', |
---|
201 | ## 'action' : 'string:${object/absolute_url}/addCourse', |
---|
202 | ## 'permission': (), |
---|
203 | ## 'condition' : 'python: member and here.portal_type in ("Department",) and "StudentManager" in member.getGroups()', |
---|
204 | ## 'category' : 'student', |
---|
205 | ## 'visible' : 1, |
---|
206 | ## }, |
---|
207 | ## { 'tool' : 'portal_actions', |
---|
208 | ## 'id' : 'add_personal', |
---|
209 | ## 'name' : 'Add personal Data', |
---|
210 | ## 'action' : 'string:${object/absolute_url}/create_personal_form', |
---|
211 | ## 'permission': (), |
---|
212 | ## 'condition' : 'python: 0 and member and not here.portal_type in ("Jamb","StudentsFolder") and not "StudentManager" in member.getGroups()', |
---|
213 | ## 'category' : 'student', |
---|
214 | ## 'visible' : 1, |
---|
215 | ## }, |
---|
216 | ## { 'tool' : 'portal_actions', |
---|
217 | ## 'id' : 'edit_jamb', |
---|
218 | ## 'name' : 'Edit Jamb Data', |
---|
219 | ## 'action' : 'cpsdocument_edit_form', |
---|
220 | ## 'permission': ( ), |
---|
221 | ## 'condition' : 'python: member and here.portal_type in ("Student",) and "StudentManager" in member.getGroups()', |
---|
222 | ## 'category' : 'student', |
---|
223 | ## 'visible' : 1, |
---|
224 | ## }, |
---|
225 | ) |
---|
226 | self.verifyActions(actions) |
---|
227 | ########################################## |
---|
228 | ###) |
---|
229 | |
---|
230 | # skins |
---|
231 | ########################################## |
---|
232 | self.log("Verifying %(product_name)s skinss" % vars()) |
---|
233 | wskins = { 'waeup_default' : 'Products/WAeUP/skins/waeup_default', |
---|
234 | 'waeup_faculty' : 'Products/WAeUP/skins/waeup_faculty', |
---|
235 | 'waeup_student' : 'Products/WAeUP/skins/waeup_student', |
---|
236 | } |
---|
237 | self.verifySkins(wskins) |
---|
238 | self.resetSkinCache() |
---|
239 | |
---|
240 | ########################################## |
---|
241 | # portal types |
---|
242 | ########################################## |
---|
243 | dtypes = portal.getWAeUPTypes() |
---|
244 | self.verifyFlexibleTypes(dtypes) |
---|
245 | self.allowContentTypes('University', ('Workspace','Section',)) |
---|
246 | ########################################## |
---|
247 | # Schemas |
---|
248 | ########################################## |
---|
249 | self.log("Verifying %(product_name)s schemas" % vars()) |
---|
250 | self.verifySchemas(portal.getWAeUPSchemas()) |
---|
251 | ########################################## |
---|
252 | # widgets |
---|
253 | ########################################## |
---|
254 | self.log("Verifying %(product_name)s widgets" % vars()) |
---|
255 | self.verifyWidgets(portal.getWAeUPWidgets()) |
---|
256 | ########################################## |
---|
257 | # layouts |
---|
258 | ########################################## |
---|
259 | self.log("Verifying %(product_name)s layouts" % vars()) |
---|
260 | self.verifyLayouts(portal.getWAeUPLayouts()) |
---|
261 | ########################################## |
---|
262 | # Vocabularies |
---|
263 | ########################################## |
---|
264 | self.log("Verifying %(product_name)s vocabularies" % vars()) |
---|
265 | self.verifyVocabularies(portal.getWAeUPVocabularies()) |
---|
266 | ########################################## |
---|
267 | # Groups |
---|
268 | ########################################## |
---|
269 | |
---|
270 | self.installCustomWorkflows() |
---|
271 | self.verifyWorkflowAssociation() |
---|
272 | |
---|
273 | self.log("End of specific %(product_name)s install" % vars()) |
---|
274 | self.finalize() |
---|
275 | |
---|
276 | |
---|
277 | def installCustomWorkflows(self): |
---|
278 | """Installs custom workflows |
---|
279 | """ |
---|
280 | from Products.WAeUP.Workflows.WAeUPWorkflow import \ |
---|
281 | waeupWorkflowsInstall |
---|
282 | |
---|
283 | waeupWorkflowsInstall(self.context) |
---|
284 | |
---|
285 | |
---|
286 | def verifyWorkflowAssociation(self): |
---|
287 | """Verify workflow association |
---|
288 | """ |
---|
289 | ws_chains = { |
---|
290 | 'Student': 'waeup_workspace_wf', |
---|
291 | 'Jamb': 'waeup_workspace_wf', |
---|
292 | } |
---|
293 | |
---|
294 | se_chains = { 'University': 'waeup_section_wf', |
---|
295 | 'AcademicsFolder': 'waeup_section_wf', |
---|
296 | 'StudentsFolder': 'waeup_section_wf', |
---|
297 | 'Student': 'waeup_section_wf', |
---|
298 | 'StudentPersonal': 'waeup_section_wf', |
---|
299 | 'Jamb': 'waeup_section_wf', |
---|
300 | 'ScratchCard': 'waeup_section_wf', |
---|
301 | 'Faculty': 'waeup_section_wf', |
---|
302 | 'Department': 'waeup_section_wf', |
---|
303 | 'Course': 'waeup_section_wf', |
---|
304 | 'AccoFolder': 'waeup_section_wf', |
---|
305 | 'Accommodation': 'waeup_section_wf', |
---|
306 | } |
---|
307 | |
---|
308 | self.verifyLocalWorkflowChains(self.portal['workspaces'], |
---|
309 | ws_chains, |
---|
310 | destructive=1) |
---|
311 | self.verifyLocalWorkflowChains(self.portal['sections'], |
---|
312 | se_chains, |
---|
313 | destructive=1) |
---|
314 | |
---|
315 | |
---|
316 | def install(self): |
---|
317 | installer = WAeUPInstaller(self) |
---|
318 | installer.install(self) |
---|
319 | dirtool = getattr(self,'portal_directories') |
---|
320 | groups = dirtool.groups |
---|
321 | for delEntry in ('StudentManager',): |
---|
322 | if delEntry in groups.listEntryIds(): |
---|
323 | groups.deleteEntry(delEntry) |
---|
324 | for newEntry in ('Students',): |
---|
325 | if newEntry not in groups.listEntryIds(): |
---|
326 | groups.createEntry({'group': newEntry, |
---|
327 | 'members': []}) |
---|
328 | #groups.manage_setLocalGroupRoles(groupid = 'StudentManager',roles=('Manager',)) |
---|
329 | #groups.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',)) |
---|
330 | sections = getattr(self,'sections') |
---|
331 | waeup = getattr(sections,'waeup',None) |
---|
332 | if not waeup: |
---|
333 | sections.content_create(type_name='University',title='waeup') |
---|
334 | sections.waeup.folder_localrole_add(member_ids=('group:Students',), |
---|
335 | member_role='SectionReviewer', |
---|
336 | ) |
---|
337 | sections.waeup.content_create(type_name='StudentsFolder',title='students') |
---|
338 | sections.waeup.folder_localrole_add(member_ids=('group:Students',), |
---|
339 | member_role='SectionReviewer', |
---|
340 | ) |
---|
341 | sections.waeup.content_create(type_name='AcademicsFolder',title='academics') |
---|
342 | ## sections.waeup.folder_localrole_add(member_ids=('group:StudentManager',), |
---|
343 | ## member_role='SectionManager', |
---|
344 | ## ) |
---|
345 | sections.waeup.students.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',)) |
---|
346 | elif not hasattr(waeup,'academics'): |
---|
347 | waeup.content_create(type_name='AcademicsFolder',title='academics') |
---|
348 | sections.waeup.manage_setLocalGroupRoles(groupid = 'role:Anonymous',roles=('SectionReader',)) |
---|
349 | # portlets ###( |
---|
350 | # |
---|
351 | portlets = ( |
---|
352 | ## {'identifier': 'waeup_main_tabs', |
---|
353 | ## 'type': 'Custom Portlet', |
---|
354 | ## 'slot': 'main_tabs', |
---|
355 | ## 'order': 0, |
---|
356 | ## 'render_method': 'portlet_main_navigation', |
---|
357 | ## 'Title': 'main tabs', |
---|
358 | ## }, |
---|
359 | {'identifier': 'waeup_breadcrumbs', |
---|
360 | 'type': 'Breadcrumbs Portlet', |
---|
361 | 'slot': 'waeup_breadcrumbs', |
---|
362 | 'first_item': 2, |
---|
363 | 'display_site_root': 0, |
---|
364 | 'Title': 'waeup_breadcrumbs', |
---|
365 | 'display': 'horizontal_trail', |
---|
366 | 'display_hidden_folders': 0, |
---|
367 | 'order': 0, |
---|
368 | }, |
---|
369 | {'identifier': 'waeup_main_tab_actions', |
---|
370 | 'type': 'Actions Portlet', |
---|
371 | 'slot': 'main_tabs', |
---|
372 | 'order': 0, |
---|
373 | 'categories': ['main_tabs',], |
---|
374 | 'Title': 'waep_main_tab_actions', |
---|
375 | }, |
---|
376 | {'identifier': 'waeup_object_actions', |
---|
377 | 'type': 'Actions Portlet', |
---|
378 | 'slot': 'waeup_object_actions', |
---|
379 | 'order': 0, |
---|
380 | 'categories': ['object',], |
---|
381 | 'Title': 'waep_manager_actions', |
---|
382 | }, |
---|
383 | {'identifier': 'waeup_left_top', |
---|
384 | 'type': 'Custom Portlet', |
---|
385 | 'slot': 'left_top', |
---|
386 | 'order': 0, |
---|
387 | 'render_method': 'portlet_session_info', |
---|
388 | 'Title': 'Session Info', |
---|
389 | }, |
---|
390 | ) |
---|
391 | installer.verifyPortletContainer(waeup) |
---|
392 | installer.verifyPortlets(portlets,waeup) |
---|
393 | |
---|
394 | ###) |
---|
395 | |
---|
396 | return installer.logResult() |
---|