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_discussion': ['activate_comments',]}) |
---|
55 | self.verifyAction('portal_subscriptions', **action) |
---|
56 | |
---|
57 | ########################################## |
---|
58 | # actions |
---|
59 | ########################################## |
---|
60 | actions = ( { 'tool' : 'portal_actions', |
---|
61 | 'id' : 'checkadmission', |
---|
62 | 'name' : 'Check Admission', |
---|
63 | 'action' : 'string:${object/absolute_url}/check_admission', |
---|
64 | 'permission': (View, ), |
---|
65 | 'condition' : 'member', |
---|
66 | 'category' : 'student', |
---|
67 | 'visible' : 1, |
---|
68 | }, |
---|
69 | { 'tool' : 'portal_actions', |
---|
70 | 'id' : 'new_student', |
---|
71 | 'name' : 'Add Student', |
---|
72 | 'action' : 'string:${object/absolute_url}/create_student_form', |
---|
73 | 'permission': (View), |
---|
74 | 'condition' : 'python: member and here.portal_type == "StudentsFolder"', |
---|
75 | 'category' : 'student', |
---|
76 | 'visible' : 1, |
---|
77 | }, |
---|
78 | { 'tool' : 'portal_actions', |
---|
79 | 'id' : 'edit_student', |
---|
80 | 'name' : 'Edit Student', |
---|
81 | 'action' : 'cpsdocument_edit_form', |
---|
82 | 'permission': ( ), |
---|
83 | 'condition' : 'python: member and here.portal_type == "Student"', |
---|
84 | 'category' : 'student', |
---|
85 | 'visible' : 1, |
---|
86 | }, |
---|
87 | { 'tool' : 'portal_actions', |
---|
88 | 'id' : 'add_jamb', |
---|
89 | 'name' : 'Add Jamb Data', |
---|
90 | 'action' : 'string:${object/absolute_url}/create_jamb_form', |
---|
91 | 'permission': (), |
---|
92 | 'condition' : 'python:not here.portal_type in ("Jamb","StudentsFolder") and len(object.contentItems()) == 0', |
---|
93 | 'category' : 'student', |
---|
94 | 'visible' : 1, |
---|
95 | }, |
---|
96 | { 'tool' : 'portal_actions', |
---|
97 | 'id' : 'add_personal', |
---|
98 | 'name' : 'Add personal Data', |
---|
99 | 'action' : 'string:${object/absolute_url}/create_personal_form', |
---|
100 | 'permission': (), |
---|
101 | 'condition' : 'python:not here.portal_type in ("Jamb","StudentsFolder")', |
---|
102 | 'category' : 'student', |
---|
103 | 'visible' : 1, |
---|
104 | }, |
---|
105 | { 'tool' : 'portal_actions', |
---|
106 | 'id' : 'edit_jamb', |
---|
107 | 'name' : 'Edit Jamb Data', |
---|
108 | 'action' : 'cpsdocument_edit_form', |
---|
109 | 'permission': ( ), |
---|
110 | 'condition' : 'python: here.portal_type == "Jamb"', |
---|
111 | 'category' : 'student', |
---|
112 | 'visible' : 1, |
---|
113 | }, |
---|
114 | ) |
---|
115 | self.verifyActions(actions) |
---|
116 | ########################################## |
---|
117 | # skins |
---|
118 | ########################################## |
---|
119 | self.log("Verifying %(product_name)s skinss" % vars()) |
---|
120 | wskins = { 'waeup_default' : 'Products/WAeUP/skins/waeup_default', |
---|
121 | 'waeup_student' : 'Products/WAeUP/skins/waeup_student', |
---|
122 | } |
---|
123 | self.verifySkins(wskins) |
---|
124 | self.resetSkinCache() |
---|
125 | ########################################## |
---|
126 | # portal types |
---|
127 | ########################################## |
---|
128 | dtypes = portal.getWAeUPTypes() |
---|
129 | self.verifyFlexibleTypes(dtypes) |
---|
130 | self.allowContentTypes('University', ('Workspace','Section',)) |
---|
131 | #self.allowContentTypes('Student', ('Workspace', 'Section')) |
---|
132 | ## ptypes = { |
---|
133 | ## 'University' : { |
---|
134 | ## 'allowed_content_types': ('StudentsFolder',), |
---|
135 | ## 'typeinfo_name': 'University', |
---|
136 | ## 'add_meta_type': 'Factory-based Type Information', |
---|
137 | ## }, |
---|
138 | ## 'StudentsFolder' : { |
---|
139 | ## 'allowed_content_types': ('Student',), |
---|
140 | ## 'typeinfo_name': 'StudentFolder', |
---|
141 | ## 'add_meta_type': 'Factory-based Type Information', |
---|
142 | ## }, |
---|
143 | ## 'Student' : { |
---|
144 | ## 'allowed_content_types': ('Jamb',), |
---|
145 | ## 'typeinfo_name': 'Student', |
---|
146 | ## 'add_meta_type': 'Factory-based Type Information', |
---|
147 | ## }, |
---|
148 | ## } |
---|
149 | ## self.verifyContentTypes(ptypes) |
---|
150 | ########################################## |
---|
151 | # Schemas |
---|
152 | ########################################## |
---|
153 | self.log("Verifying %(product_name)s schemas" % vars()) |
---|
154 | self.verifySchemas(portal.getWAeUPSchemas()) |
---|
155 | ########################################## |
---|
156 | # widgets |
---|
157 | ########################################## |
---|
158 | self.log("Verifying %(product_name)s widgets" % vars()) |
---|
159 | self.verifyWidgets(portal.getWAeUPWidgets()) |
---|
160 | ########################################## |
---|
161 | # layouts |
---|
162 | ########################################## |
---|
163 | self.log("Verifying %(product_name)s layouts" % vars()) |
---|
164 | self.verifyLayouts(portal.getWAeUPLayouts()) |
---|
165 | ########################################## |
---|
166 | # Vocabularies |
---|
167 | ########################################## |
---|
168 | self.log("Verifying %(product_name)s vocabularies" % vars()) |
---|
169 | self.verifyVocabularies(portal.getWAeUPVocabularies()) |
---|
170 | |
---|
171 | self.installCustomWorkflows() |
---|
172 | self.verifyWorkflowAssociation() |
---|
173 | |
---|
174 | self.log("End of specific %(product_name)s install" % vars()) |
---|
175 | self.finalize() |
---|
176 | |
---|
177 | |
---|
178 | def installCustomWorkflows(self): |
---|
179 | """Installs custom workflows |
---|
180 | """ |
---|
181 | from Products.WAeUP.Workflows.WAeUPWorkflow import \ |
---|
182 | waeupWorkflowsInstall |
---|
183 | |
---|
184 | waeupWorkflowsInstall(self.context) |
---|
185 | |
---|
186 | |
---|
187 | def verifyWorkflowAssociation(self): |
---|
188 | """Verify workflow association |
---|
189 | """ |
---|
190 | ws_chains = { |
---|
191 | 'Student': 'waeup_workspace_wf', |
---|
192 | 'Jamb': 'waeup_workspace_wf', |
---|
193 | } |
---|
194 | |
---|
195 | se_chains = { 'University': 'waeup_section_wf', |
---|
196 | 'StudentsFolder': 'waeup_section_wf', |
---|
197 | 'Student': 'waeup_section_wf', |
---|
198 | 'StudentPersonal': 'waeup_section_wf', |
---|
199 | 'Jamb': 'waeup_section_wf', |
---|
200 | 'ScratchCard': 'waeup_section_wf', |
---|
201 | } |
---|
202 | |
---|
203 | self.verifyLocalWorkflowChains(self.portal['workspaces'], |
---|
204 | ws_chains, |
---|
205 | destructive=1) |
---|
206 | self.verifyLocalWorkflowChains(self.portal['sections'], |
---|
207 | se_chains, |
---|
208 | destructive=1) |
---|
209 | |
---|
210 | |
---|
211 | def install(self): |
---|
212 | installer = WAeUPInstaller(self) |
---|
213 | installer.install(self) |
---|
214 | return installer.logResult() |
---|