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