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_form', |
---|
64 | 'permission': (View, ), |
---|
65 | 'condition' : 'not: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: 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' : 'edit_jamb', |
---|
98 | 'name' : 'Edit Jamb Data', |
---|
99 | 'action' : 'cpsdocument_edit_form', |
---|
100 | 'permission': ( ), |
---|
101 | 'condition' : 'python: here.portal_type == "Jamb"', |
---|
102 | 'category' : 'student', |
---|
103 | 'visible' : 1, |
---|
104 | }, |
---|
105 | ) |
---|
106 | self.verifyActions(actions) |
---|
107 | ########################################## |
---|
108 | # skins |
---|
109 | ########################################## |
---|
110 | self.log("Verifying %(product_name)s skinss" % vars()) |
---|
111 | wskins = { 'waeup_default' : 'Products/WAeUP/skins/waeup_default', |
---|
112 | 'waeup_student' : 'Products/WAeUP/skins/waeup_student', |
---|
113 | } |
---|
114 | self.verifySkins(wskins) |
---|
115 | self.resetSkinCache() |
---|
116 | ########################################## |
---|
117 | # portal types |
---|
118 | ########################################## |
---|
119 | dtypes = portal.getWAeUPTypes() |
---|
120 | self.verifyFlexibleTypes(dtypes) |
---|
121 | self.allowContentTypes('University', ('Workspace','Section',)) |
---|
122 | #self.allowContentTypes('Student', ('Workspace', 'Section')) |
---|
123 | ## ptypes = { |
---|
124 | ## 'University' : { |
---|
125 | ## 'allowed_content_types': ('StudentsFolder',), |
---|
126 | ## 'typeinfo_name': 'University', |
---|
127 | ## 'add_meta_type': 'Factory-based Type Information', |
---|
128 | ## }, |
---|
129 | ## 'StudentsFolder' : { |
---|
130 | ## 'allowed_content_types': ('Student',), |
---|
131 | ## 'typeinfo_name': 'StudentFolder', |
---|
132 | ## 'add_meta_type': 'Factory-based Type Information', |
---|
133 | ## }, |
---|
134 | ## 'Student' : { |
---|
135 | ## 'allowed_content_types': ('Jamb',), |
---|
136 | ## 'typeinfo_name': 'Student', |
---|
137 | ## 'add_meta_type': 'Factory-based Type Information', |
---|
138 | ## }, |
---|
139 | ## } |
---|
140 | ## self.verifyContentTypes(ptypes) |
---|
141 | ########################################## |
---|
142 | # Schemas |
---|
143 | ########################################## |
---|
144 | self.log("Verifying %(product_name)s schemas" % vars()) |
---|
145 | self.verifySchemas(portal.getWAeUPSchemas()) |
---|
146 | ########################################## |
---|
147 | # widgets |
---|
148 | ########################################## |
---|
149 | self.log("Verifying %(product_name)s widgets" % vars()) |
---|
150 | self.verifyWidgets(portal.getWAeUPWidgets()) |
---|
151 | ########################################## |
---|
152 | # layouts |
---|
153 | ########################################## |
---|
154 | self.log("Verifying %(product_name)s layouts" % vars()) |
---|
155 | self.verifyLayouts(portal.getWAeUPLayouts()) |
---|
156 | ########################################## |
---|
157 | # Vocabularies |
---|
158 | ########################################## |
---|
159 | self.log("Verifying %(product_name)s vocabularies" % vars()) |
---|
160 | self.verifyVocabularies(portal.getWAeUPVocabularies()) |
---|
161 | |
---|
162 | self.installCustomWorkflows() |
---|
163 | self.verifyWorkflowAssociation() |
---|
164 | |
---|
165 | self.log("End of specific %(product_name)s install" % vars()) |
---|
166 | self.finalize() |
---|
167 | |
---|
168 | |
---|
169 | def installCustomWorkflows(self): |
---|
170 | """Installs custom workflows |
---|
171 | """ |
---|
172 | from Products.WAeUP.Workflows.WAeUPWorkflow import \ |
---|
173 | waeupWorkflowsInstall |
---|
174 | |
---|
175 | waeupWorkflowsInstall(self.context) |
---|
176 | |
---|
177 | |
---|
178 | def verifyWorkflowAssociation(self): |
---|
179 | """Verify workflow association |
---|
180 | """ |
---|
181 | ws_chains = { |
---|
182 | 'Student': 'waeup_workspace_wf', |
---|
183 | 'Jamb': 'waeup_workspace_wf', |
---|
184 | } |
---|
185 | |
---|
186 | se_chains = { 'University': 'waeup_section_wf', |
---|
187 | 'StudentsFolder': 'waeup_section_wf', |
---|
188 | 'Student': 'waeup_section_wf', |
---|
189 | 'Jamb': 'waeup_section_wf', |
---|
190 | 'ScratchCard': 'waeup_section_wf', |
---|
191 | } |
---|
192 | |
---|
193 | self.verifyLocalWorkflowChains(self.portal['workspaces'], |
---|
194 | ws_chains, |
---|
195 | destructive=1) |
---|
196 | self.verifyLocalWorkflowChains(self.portal['sections'], |
---|
197 | se_chains, |
---|
198 | destructive=1) |
---|
199 | |
---|
200 | |
---|
201 | def install(self): |
---|
202 | installer = WAeUPInstaller(self) |
---|
203 | installer.install(self) |
---|
204 | return installer.logResult() |
---|