1 | from Products.CPSInstaller.CPSInstaller import CPSInstaller |
---|
2 | from Products.CMFCore.CMFCorePermissions import View, ModifyPortalContent |
---|
3 | try: |
---|
4 | from Products.CPSSubscriptions.permissions import CanNotifyContent |
---|
5 | CPSSubscriptions = True |
---|
6 | except ImportError: |
---|
7 | CPSSubscriptions = False |
---|
8 | try: |
---|
9 | from Products.CPSForum.CPSForumPermissions import ForumManageComments |
---|
10 | CPSForum = True |
---|
11 | except ImportError: |
---|
12 | CPSForum = False |
---|
13 | |
---|
14 | class WAeUPInstaller(CPSInstaller): |
---|
15 | """ |
---|
16 | WAeUP Installer |
---|
17 | """ |
---|
18 | product_name = "WAeUP" |
---|
19 | |
---|
20 | def install(self,portal): |
---|
21 | "install" |
---|
22 | |
---|
23 | product_name = self.product_name |
---|
24 | self.log("Starting %(product_name)s install" % vars() ) |
---|
25 | |
---|
26 | ########################################## |
---|
27 | # Actions |
---|
28 | ########################################## |
---|
29 | if CPSSubscriptions: |
---|
30 | ptypes = "('Portal', 'CPSMailAccess Message', 'CPSMailAccess Box', 'CPSMailAccess Folder',"\ |
---|
31 | + "'University', 'StudentsFolder', 'Student', 'Jamb')" |
---|
32 | condition = "object.portal_type not in %s" % ptypes |
---|
33 | |
---|
34 | action = {'id' : 'notify_content', |
---|
35 | 'name' : 'action_notify_content', |
---|
36 | 'action' : 'string:${object_url}/content_notify_email_form', |
---|
37 | 'condition' : 'python:%s' % condition, |
---|
38 | 'permission' : (CanNotifyContent,), |
---|
39 | 'category' : 'object', |
---|
40 | } |
---|
41 | self.deleteActions({'portal_subscriptions': ['notify_content',]}) |
---|
42 | self.verifyAction('portal_subscriptions', **action) |
---|
43 | if CPSForum: |
---|
44 | ptypes = "('University', 'StudentsFolder', 'Student', 'Jamb')" |
---|
45 | condition = "object.portal_type not in %s" % ptypes |
---|
46 | |
---|
47 | action = {'id' : 'activate_comments', |
---|
48 | 'name': 'action_activate_comments', |
---|
49 | 'action': 'string:${object/absolute_url}/set_comment_mode?mode=1', |
---|
50 | 'condition' : 'python:%s' % condition, |
---|
51 | 'permission': (ForumManageComments,), |
---|
52 | 'category' : 'object', |
---|
53 | } |
---|
54 | self.deleteActions({'portal_subscriptions': ['activate_comments',]}) |
---|
55 | self.verifyAction('portal_subscriptions', **action) |
---|
56 | # now portal_discussion |
---|
57 | self.deleteActions({'portal_discussion': ['comment', |
---|
58 | 'activate_comments', |
---|
59 | 'deactivate_comments', |
---|
60 | 'manage_comments']}) |
---|
61 | action = {'id' : 'comment', |
---|
62 | 'name': 'action_comment', |
---|
63 | 'action': "string:${object/absolute_url}/post_comment", |
---|
64 | 'condition' : "python:getattr(object.getContent(), 'allow_discussion' , None) and object.hasCommentAction()", |
---|
65 | 'permission': (View,), |
---|
66 | 'category' : 'object', |
---|
67 | } |
---|
68 | self.verifyAction('portal_discussion', **action) |
---|
69 | action = {'id' : 'activate_comments', |
---|
70 | 'name': 'action_activate_comments', |
---|
71 | 'action': "string:${object/absolute_url}/set_comment_mode?mode=1", |
---|
72 | 'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1", |
---|
73 | 'permission': (ForumManageComments,), |
---|
74 | 'category' : 'object', |
---|
75 | } |
---|
76 | self.verifyAction('portal_discussion', **action) |
---|
77 | action = {'id' : 'deactivate_comments', |
---|
78 | 'name': 'action_deactivate_comments', |
---|
79 | 'action': "string:${object/absolute_url}/set_comment_mode?mode=0", |
---|
80 | 'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1", |
---|
81 | 'permission': (ForumManageComments,), |
---|
82 | 'category' : 'object', |
---|
83 | } |
---|
84 | self.verifyAction('portal_discussion', **action) |
---|
85 | action = {'id' : 'manage_comments', |
---|
86 | 'name': 'action_manage_comments', |
---|
87 | 'action': "string:${object/absolute_url}/manage_comment", |
---|
88 | 'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1", |
---|
89 | 'permission': (ForumManageComments,), |
---|
90 | 'category' : 'object', |
---|
91 | } |
---|
92 | self.verifyAction('portal_discussion', **action) |
---|
93 | |
---|
94 | ########################################## |
---|
95 | # actions |
---|
96 | ########################################## |
---|
97 | actions = ( { 'tool' : 'portal_actions', |
---|
98 | 'id' : 'checkadmission', |
---|
99 | 'name' : 'Check Admission', |
---|
100 | 'action' : 'string:${object/absolute_url}/check_admission', |
---|
101 | 'permission': (View, ), |
---|
102 | 'condition' : 'python: not member', |
---|
103 | 'category' : 'student', |
---|
104 | 'visible' : 1, |
---|
105 | }, |
---|
106 | ## { 'tool' : 'portal_actions', |
---|
107 | ## 'id' : 'new_student', |
---|
108 | ## 'name' : 'Add Student', |
---|
109 | ## 'action' : 'string:${object/absolute_url}/create_student_form', |
---|
110 | ## 'permission': (View), |
---|
111 | ## 'condition' : 'python: 0 and member and here.portal_type == "StudentsFolder"', |
---|
112 | ## 'category' : 'student', |
---|
113 | ## 'visible' : 1, |
---|
114 | ## }, |
---|
115 | { 'tool' : 'portal_actions', |
---|
116 | 'id' : 'edit_student', |
---|
117 | 'name' : 'Edit Student', |
---|
118 | 'action' : 'cpsdocument_edit_form', |
---|
119 | 'permission': ( ), |
---|
120 | 'condition' : 'python: 0 and member and here.portal_type == "Student"', |
---|
121 | 'category' : 'student', |
---|
122 | 'visible' : 1, |
---|
123 | }, |
---|
124 | { 'tool' : 'portal_actions', |
---|
125 | 'id' : 'add_jamb', |
---|
126 | 'name' : 'Add Student JAMB', |
---|
127 | 'action' : 'string:${object/absolute_url}/create_jamb', |
---|
128 | 'permission': (), |
---|
129 | 'condition' : 'python: member and here.portal_type in ("StudentsFolder",) and "StudentManager" in member.getGroups()', |
---|
130 | 'category' : 'student', |
---|
131 | 'visible' : 1, |
---|
132 | }, |
---|
133 | { 'tool' : 'portal_actions', |
---|
134 | 'id' : 'add_personal', |
---|
135 | 'name' : 'Add personal Data', |
---|
136 | 'action' : 'string:${object/absolute_url}/create_personal_form', |
---|
137 | 'permission': (), |
---|
138 | 'condition' : 'python: 0 and member and not here.portal_type in ("Jamb","StudentsFolder") and not "StudentManager" in member.getGroups()', |
---|
139 | 'category' : 'student', |
---|
140 | 'visible' : 1, |
---|
141 | }, |
---|
142 | { 'tool' : 'portal_actions', |
---|
143 | 'id' : 'edit_jamb', |
---|
144 | 'name' : 'Edit Jamb Data', |
---|
145 | 'action' : 'cpsdocument_edit_form', |
---|
146 | 'permission': ( ), |
---|
147 | 'condition' : 'python: member and here.portal_type in ("Student",) and "StudentManager" in member.getGroups()', |
---|
148 | 'category' : 'student', |
---|
149 | 'visible' : 1, |
---|
150 | }, |
---|
151 | ) |
---|
152 | self.verifyActions(actions) |
---|
153 | ########################################## |
---|
154 | # skins |
---|
155 | ########################################## |
---|
156 | self.log("Verifying %(product_name)s skinss" % vars()) |
---|
157 | wskins = { 'waeup_default' : 'Products/WAeUP/skins/waeup_default', |
---|
158 | 'waeup_student' : 'Products/WAeUP/skins/waeup_student', |
---|
159 | } |
---|
160 | self.verifySkins(wskins) |
---|
161 | self.resetSkinCache() |
---|
162 | ########################################## |
---|
163 | # portal types |
---|
164 | ########################################## |
---|
165 | dtypes = portal.getWAeUPTypes() |
---|
166 | self.verifyFlexibleTypes(dtypes) |
---|
167 | self.allowContentTypes('University', ('Workspace','Section',)) |
---|
168 | ########################################## |
---|
169 | # Schemas |
---|
170 | ########################################## |
---|
171 | self.log("Verifying %(product_name)s schemas" % vars()) |
---|
172 | self.verifySchemas(portal.getWAeUPSchemas()) |
---|
173 | ########################################## |
---|
174 | # widgets |
---|
175 | ########################################## |
---|
176 | self.log("Verifying %(product_name)s widgets" % vars()) |
---|
177 | self.verifyWidgets(portal.getWAeUPWidgets()) |
---|
178 | ########################################## |
---|
179 | # layouts |
---|
180 | ########################################## |
---|
181 | self.log("Verifying %(product_name)s layouts" % vars()) |
---|
182 | self.verifyLayouts(portal.getWAeUPLayouts()) |
---|
183 | ########################################## |
---|
184 | # Vocabularies |
---|
185 | ########################################## |
---|
186 | self.log("Verifying %(product_name)s vocabularies" % vars()) |
---|
187 | self.verifyVocabularies(portal.getWAeUPVocabularies()) |
---|
188 | |
---|
189 | self.installCustomWorkflows() |
---|
190 | self.verifyWorkflowAssociation() |
---|
191 | |
---|
192 | self.log("End of specific %(product_name)s install" % vars()) |
---|
193 | self.finalize() |
---|
194 | |
---|
195 | |
---|
196 | def installCustomWorkflows(self): |
---|
197 | """Installs custom workflows |
---|
198 | """ |
---|
199 | from Products.WAeUP.Workflows.WAeUPWorkflow import \ |
---|
200 | waeupWorkflowsInstall |
---|
201 | |
---|
202 | waeupWorkflowsInstall(self.context) |
---|
203 | |
---|
204 | |
---|
205 | def verifyWorkflowAssociation(self): |
---|
206 | """Verify workflow association |
---|
207 | """ |
---|
208 | ws_chains = { |
---|
209 | 'Student': 'waeup_workspace_wf', |
---|
210 | 'Jamb': 'waeup_workspace_wf', |
---|
211 | } |
---|
212 | |
---|
213 | se_chains = { 'University': 'waeup_section_wf', |
---|
214 | 'StudentsFolder': 'waeup_section_wf', |
---|
215 | 'Student': 'waeup_section_wf', |
---|
216 | 'StudentPersonal': 'waeup_section_wf', |
---|
217 | 'Jamb': 'waeup_section_wf', |
---|
218 | 'ScratchCard': 'waeup_section_wf', |
---|
219 | } |
---|
220 | |
---|
221 | self.verifyLocalWorkflowChains(self.portal['workspaces'], |
---|
222 | ws_chains, |
---|
223 | destructive=1) |
---|
224 | self.verifyLocalWorkflowChains(self.portal['sections'], |
---|
225 | se_chains, |
---|
226 | destructive=1) |
---|
227 | |
---|
228 | |
---|
229 | def install(self): |
---|
230 | installer = WAeUPInstaller(self) |
---|
231 | installer.install(self) |
---|
232 | return installer.logResult() |
---|