1 | from Products.CPSInstaller.CPSInstaller import CPSInstaller |
---|
2 | from Products.CMFCore.CMFCorePermissions import View, ModifyPortalContent |
---|
3 | try: |
---|
4 | from Products.CPSSubscriptions.CPSSubscriptionsPermissions import \ |
---|
5 | CanNotifyContent |
---|
6 | CPSSubscriptions = True |
---|
7 | except ImportError: |
---|
8 | CPSSubscriptions = False |
---|
9 | try: |
---|
10 | from Products.CPSForum.CPSForumPermissions import \ |
---|
11 | ForumManageComments |
---|
12 | CPSForum = True |
---|
13 | except ImportError: |
---|
14 | CPSForum = False |
---|
15 | |
---|
16 | class WAeUPInstaller(CPSInstaller): |
---|
17 | """ |
---|
18 | WAeUP Installer |
---|
19 | """ |
---|
20 | product_name = "WAeUP" |
---|
21 | |
---|
22 | def install(self,portal): |
---|
23 | "install" |
---|
24 | |
---|
25 | product_name = self.product_name |
---|
26 | self.log("Starting %(product_name)s install" % vars() ) |
---|
27 | |
---|
28 | ########################################## |
---|
29 | # Actions |
---|
30 | ########################################## |
---|
31 | if CPSSubscriptions: |
---|
32 | ptypes = "('Portal', 'CPSMailAccess Message', 'CPSMailAccess Box', 'CPSMailAccess Folder',"\ |
---|
33 | + "'StudentFolder', 'Student', 'Jamb')" |
---|
34 | condition = "object.portal_type not in %s" % ptypes |
---|
35 | |
---|
36 | action = {'id' : 'notify_content', |
---|
37 | 'name' : 'action_notify_content', |
---|
38 | 'action' : 'string:${object_url}/content_notify_email_form', |
---|
39 | 'condition' : 'python:%s' % condition, |
---|
40 | 'permission' : (CanNotifyContent,), |
---|
41 | 'category' : 'object', |
---|
42 | } |
---|
43 | self.deleteActions({'portal_subscriptions': ['notify_content',]}) |
---|
44 | self.verifyAction('portal_subscriptions', **action) |
---|
45 | if CPSForum: |
---|
46 | ptypes = "('StudentFolder', 'Student', 'Jamb')" |
---|
47 | condition = "object.portal_type not in %s" % ptypes |
---|
48 | |
---|
49 | action = {'id' : 'activate_comments', |
---|
50 | 'name': 'action_activate_comments', |
---|
51 | 'action': 'string:${object/absolute_url}/set_comment_mode?mode=1', |
---|
52 | 'condition' : 'python:%s' % condition, |
---|
53 | 'permission': (ForumManageComments,), |
---|
54 | 'category' : 'object', |
---|
55 | } |
---|
56 | self.deleteActions({'portal_discussion': ['activate_comments',]}) |
---|
57 | self.verifyAction('portal_subscriptions', **action) |
---|
58 | |
---|
59 | ########################################## |
---|
60 | # actions |
---|
61 | ########################################## |
---|
62 | actions = ( { 'tool' : 'portal_actions', |
---|
63 | 'id' : 'checkadmission', |
---|
64 | 'name' : 'Check Admission', |
---|
65 | 'action' : 'string:${portal_url}/check_admission_form', |
---|
66 | 'permission': (View, ), |
---|
67 | 'condition' : '', |
---|
68 | 'category' : 'ostudent', |
---|
69 | 'visible' : 1, |
---|
70 | }, |
---|
71 | { 'tool' : 'portal_actions', |
---|
72 | 'id' : 'new_student', |
---|
73 | 'name' : 'Add Student', |
---|
74 | 'action' : 'folder_factories', |
---|
75 | 'permission': (View, ), |
---|
76 | 'condition' : 'python: here.portal_type == "StudentFolder"', |
---|
77 | 'category' : 'student', |
---|
78 | 'visible' : 1, |
---|
79 | }, |
---|
80 | { 'tool' : 'portal_actions', |
---|
81 | 'id' : 'edit_student', |
---|
82 | 'name' : 'Edit Student', |
---|
83 | 'action' : 'cpsdocument_edit_form', |
---|
84 | 'permission': (ModifyPortalContent, ), |
---|
85 | 'condition' : 'python: here.portal_type == "Student"', |
---|
86 | 'category' : 'student', |
---|
87 | 'visible' : 1, |
---|
88 | }, |
---|
89 | { 'tool' : 'portal_actions', |
---|
90 | 'id' : 'edit_student', |
---|
91 | 'name' : 'Add Jamb Data', |
---|
92 | 'action' : 'folder_factories', |
---|
93 | 'permission': (ModifyPortalContent, ), |
---|
94 | 'condition' : 'python:len(object.contentItems()) == 0', |
---|
95 | 'category' : 'student', |
---|
96 | 'visible' : 1, |
---|
97 | }, |
---|
98 | ) |
---|
99 | self.verifyActions(actions) |
---|
100 | ########################################## |
---|
101 | # skins |
---|
102 | ########################################## |
---|
103 | self.log("Verifying %(product_name)s skinss" % vars()) |
---|
104 | wskins = { 'waeup_default' : 'Products/WAeUP/skins/waeup_default', |
---|
105 | 'waeup_student' : 'Products/WAeUP/skins/waeup_student', |
---|
106 | } |
---|
107 | self.verifySkins(wskins) |
---|
108 | self.resetSkinCache() |
---|
109 | ########################################## |
---|
110 | # portal types |
---|
111 | ########################################## |
---|
112 | dtypes = portal.getWAeUPTypes() |
---|
113 | self.verifyFlexibleTypes(dtypes) |
---|
114 | self.allowContentTypes('StudentFolder', ('Workspace','Section',)) |
---|
115 | #self.allowContentTypes('Student', ('Workspace', 'Section')) |
---|
116 | ptypes = { |
---|
117 | 'StudentFolder' : { |
---|
118 | 'allowed_content_types': ('Student',), |
---|
119 | 'typeinfo_name': 'WAeUP: StudentFolder', |
---|
120 | 'add_meta_type': 'Factory-based Type Information', |
---|
121 | }, |
---|
122 | 'Student' : { |
---|
123 | 'allowed_content_types': ('Jamb',), |
---|
124 | 'typeinfo_name': 'WAeUP: Student', |
---|
125 | 'add_meta_type': 'Factory-based Type Information', |
---|
126 | }, |
---|
127 | } |
---|
128 | self.verifyContentTypes(ptypes) |
---|
129 | ########################################## |
---|
130 | # Schemas |
---|
131 | ########################################## |
---|
132 | self.log("Verifying %(product_name)s schemas" % vars()) |
---|
133 | self.verifySchemas(portal.getWAeUPSchemas()) |
---|
134 | ########################################## |
---|
135 | # widgets |
---|
136 | ########################################## |
---|
137 | self.log("Verifying %(product_name)s widgets" % vars()) |
---|
138 | self.verifyWidgets(portal.getWAeUPWidgets()) |
---|
139 | ########################################## |
---|
140 | # layouts |
---|
141 | ########################################## |
---|
142 | self.log("Verifying %(product_name)s layouts" % vars()) |
---|
143 | self.verifyLayouts(portal.getWAeUPLayouts()) |
---|
144 | ########################################## |
---|
145 | # Vocabularies |
---|
146 | ########################################## |
---|
147 | self.log("Verifying %(product_name)s vocabularies" % vars()) |
---|
148 | self.verifyVocabularies(portal.getWAeUPVocabularies()) |
---|
149 | |
---|
150 | self.installCustomWorkflows() |
---|
151 | self.verifyWorkflowAssociation() |
---|
152 | |
---|
153 | self.log("End of specific %(product_name)s install" % vars()) |
---|
154 | self.finalize() |
---|
155 | |
---|
156 | |
---|
157 | def installCustomWorkflows(self): |
---|
158 | """Installs custom workflows |
---|
159 | """ |
---|
160 | from Products.WAeUP.Workflows.WAeUPWorkflow import \ |
---|
161 | waeupWorkflowsInstall |
---|
162 | |
---|
163 | waeupWorkflowsInstall(self.context) |
---|
164 | |
---|
165 | |
---|
166 | def verifyWorkflowAssociation(self): |
---|
167 | """Verify workflow association |
---|
168 | """ |
---|
169 | ws_chains = { |
---|
170 | 'Student': 'waeup_workspace_wf', |
---|
171 | 'Jamb': 'waeup_workspace_wf', |
---|
172 | } |
---|
173 | |
---|
174 | se_chains = { 'StudentFolder': 'waeup_section_wf', |
---|
175 | 'Student': 'waeup_section_wf', |
---|
176 | 'Jamb': 'waeup_section_wf', |
---|
177 | } |
---|
178 | |
---|
179 | self.verifyLocalWorkflowChains(self.portal['workspaces'], |
---|
180 | ws_chains, |
---|
181 | destructive=1) |
---|
182 | self.verifyLocalWorkflowChains(self.portal['sections'], |
---|
183 | se_chains, |
---|
184 | destructive=1) |
---|
185 | |
---|
186 | |
---|
187 | def install(self): |
---|
188 | installer = WAeUPInstaller(self) |
---|
189 | installer.install(self) |
---|
190 | return installer.logResult() |
---|